As an alternative to req #1493, this set of commits pushes the lock down into each RPC function itself.
From there, locking may be improved on a case-by-case basis.
No behavior changes. Simply pushes lock down into each RPC function.
Now that locks have been pushed down, we may remove locks in some obvious
cases (help, stop), move the lock-taking down below initial param parsing in
several cases, and correct a bug in one case (use cs_vNodes).
I like this one a lot better.
This is the way we used to do it (each RPC command acquired the locks it needed), and we were constantly battling people adding new RPC commands that worked in testing and then blew up in production, because they didn't acquire the right locks, or they acquired the right locks in the wrong order.
I like the other approach: make the default safe, but if you know what you're doing you can do your own locking.
543 | @@ -531,6 +544,8 @@ Value getinfo(const Array& params, bool fHelp) 544 | "getinfo\n" 545 | "Returns an object containing various state info."); 546 | 547 | + LOCK2(cs_main, pwalletMain->cs_wallet);
Also need cs_vNodes a few lines down.
The other pull is safer. It allows for a slow transition to finer-grained locking, optimizing where it matters. This is a big change at once, and it's easy to forget one or two locks.
Automatic sanity-testing: FAILED MERGE, see http://jenkins.bluematt.me/pull-tester/957f0899fc5ecefd2f63fdb0a65527b3252e2bed for binaries and test log.
This pull does not merge cleanly onto current master
Closing. We're going with the table driven approach for now (#1493).