bitcoin icon indicating copy to clipboard operation
bitcoin copied to clipboard

refactor: replace RecursiveMutex `cs_sendProcessing` with Mutex

Open theStack opened this issue 3 years ago • 4 comments

The mutex cs_sendProcessing is currently only acquired at one location in the code:

https://github.com/bitcoin/bitcoin/blob/7d258ee8bc3bff439881064dd6234f7b04982783/src/net.cpp#L1998-L2001

apparently with the intention to execute the method for sending messages (NetEventsInterface::SendMessages(...)) in serial order, in the case that we ever had more than one message handling thread. With no possibility to re-acquire the mutex in the same thread, there is no reason for it to be a RecursiveMutex, so we can change it to an ordinary Mutex instead.

(An alternative would be to just get rid of the mutex, as it currently doesn't serve any purpose, as long as we only have one message handling thread.)

theStack avatar Jul 12 '22 15:07 theStack

See also https://github.com/bitcoin/bitcoin/pull/24474/commits/b1af785346cd2c932fd1310df10f757ba1346c2b (https://github.com/bitcoin/bitcoin/pull/24474/commits/b1af785346cd2c932fd1310df10f757ba1346c2b)

maflcko avatar Jul 12 '22 15:07 maflcko

See also b1af785 (https://github.com/bitcoin/bitcoin/pull/24474/commits/b1af785346cd2c932fd1310df10f757ba1346c2b)

Or #26036 more broadly

ajtowns avatar Sep 09 '22 08:09 ajtowns

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26036 (net: add NetEventsInterface::g_msgproc_mutex by ajtowns)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

DrahtBot avatar Sep 13 '22 19:09 DrahtBot

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

DrahtBot avatar Sep 20 '22 13:09 DrahtBot

Are you still working on this?

achow101 avatar Oct 12 '22 19:10 achow101

This mutex no longer exists since #26036 / bf12abe4542f2cf658516ea7e7fbbff6864c2208. Closing.

glozow avatar Oct 12 '22 19:10 glozow