Commit 082ebde
committed
Introduce
Previously, when enqueuing new messages to the `MessageQueue`, we'd
directly attempt to call back into `PeerHandler::process_events` (via
the `process_msgs_callback`), which always held the risk of deadlocks on
re-entrancy, i.e., when we would still hold the peer state mutexes when
doing so. To mitigate this we had to always implement ~ugly patterns
ensuring we don't hold the `Mutex` when we call `MessageQueue::enqueue`.
Here, we instead introduce a `MessageQueueNotifier` RAII type that will
call `process_msgs_callback` when dropped, which allows us to clean up
the code and reduces the risk of reintroducing such deadlock bugs: we
now simply have to ensure that any method calling `enqueue` holds the
notifier before retrieving any locks.MessageQueueNotifier RAII type1 parent 85d1e5f commit 082ebde
File tree
6 files changed
+195
-258
lines changed- lightning-liquidity/src
- lsps0
- lsps1
- lsps2
6 files changed
+195
-258
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
206 | 201 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
213 | 208 | | |
214 | 209 | | |
215 | 210 | | |
| |||
310 | 305 | | |
311 | 306 | | |
312 | 307 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
322 | 314 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
| 315 | + | |
| 316 | + | |
328 | 317 | | |
329 | | - | |
330 | | - | |
331 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
332 | 321 | | |
333 | 322 | | |
334 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| 155 | + | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| |||
0 commit comments