4201 | @@ -4186,6 +4202,10 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
4202 | }
4203 | }
4204 |
4205 | + TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState()
As IsInitialBlockDownload gets its own LOCK(cs_main), is this necessary? (I really prefer to keep the amount of time cs_main is locked minimal, as it's likely the most common cause for latency in processing)
It's not strictly necessary (it would get the lock either way), however, what is the use of a TRY_LOCK if a few lines before we do a non-try LOCK() of the same lock? That's why I moved the TRY_LOCK up, so that if the try fails it won't do IsInitialBlockDownload either...
I agree that keeping the time that cs_main is locked down would be good.It's even worse than the Big Kernel Lock :) Finer-grained locking would be in order.
In the meantime: We could do TRY_LOCK and release the lock again multiple times?
Let's do that in a different PR, if needed.