lightningdevkit / lightning-liquidity

Other
27 stars 17 forks source link

Fix more potential deadlock scenarios #125

Closed tnull closed 7 months ago

tnull commented 7 months ago

While we previously already fixed some potential deadlock issues, some more remained in the LSPS1/LSPS2 implementations due to holding the peer locks when enqueuing request/response messages as the latter would trigger PeerManager::process_events could result in circular waits. Here, we make sure to always drop the locks first, before enqueuing request/response messages.

tnull commented 7 months ago

LGTM

I was wondering whether we can extract enqueueing the message and not repeat it, but that might only be easy for the handle_* methods.

Yeah, we could eventually consider a larger refactor to some structure that would prohibit us from ever holding the lock while enqueueing. This might be a good idea, but if we do that however, I'd like to share it across LSPS1/2 at least, which might require some more prefactors to make them more uniform.

Landing this for now.