Commit 6a39d2d
committed
Fix epoll async cancellation, TLS test corruption, and SIGPIPE handling
This commit addresses several correctness and portability issues in the
epoll backend and TLS implementations.
epoll completion/cancellation race:
- Add atomic `registered` flag to epoll_op as a claim token
- Scheduler and cancel() now race to atomically exchange the flag
- Whoever wins owns the completion, preventing double-completion bugs
- cancel() properly unregisters fd from epoll and posts to completion queue
- close_socket() calls cancel() first to ensure pending ops complete
SIGPIPE handling:
- Replace writev() with sendmsg() using MSG_NOSIGNAL flag
- Matches Boost.Asio's per-syscall approach instead of global signal handler
- Avoids process-wide side effects from signal(SIGPIPE, SIG_IGN)
Empty buffer handling:
- Extend checks to handle single zero-length buffers, not just empty iovec
WolfSSL deferred context initialization:
- Cache separate client_ctx_ and server_ctx_ in wolfssl_native_context
- Defer SSL object creation until handshake when role is known
- Works with standard WolfSSL builds without --enable-opensslextra
- Single tls::context can now be shared across client and server streams
TLS test lambda capture fix:
- Store coroutine lambdas in named variables before invocation
- Fixes dangling reference when temporary lambda is destroyed before
coroutine completes, which caused client/server to share captures
Add high-level overview comments to epoll implementation files explaining
architecture, completion/cancellation race handling, and design rationale.1 parent e9d9abd commit 6a39d2d
14 files changed
Lines changed: 1250 additions & 1064 deletions
File tree
- include/boost/corosio/tls
- src
- corosio/src/detail/epoll
- openssl/src
- wolfssl/src
- test/unit
- test
- tls
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
41 | 81 | | |
42 | 82 | | |
43 | 83 | | |
44 | 84 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 85 | | |
52 | 86 | | |
53 | 87 | | |
| |||
67 | 101 | | |
68 | 102 | | |
69 | 103 | | |
| 104 | + | |
70 | 105 | | |
71 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
72 | 111 | | |
73 | 112 | | |
74 | 113 | | |
| |||
81 | 120 | | |
82 | 121 | | |
83 | 122 | | |
| 123 | + | |
| 124 | + | |
84 | 125 | | |
85 | 126 | | |
86 | 127 | | |
| |||
94 | 135 | | |
95 | 136 | | |
96 | 137 | | |
97 | | - | |
98 | | - | |
99 | 138 | | |
100 | | - | |
101 | 139 | | |
102 | 140 | | |
103 | 141 | | |
104 | 142 | | |
105 | 143 | | |
106 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
107 | 148 | | |
108 | 149 | | |
109 | 150 | | |
110 | 151 | | |
111 | 152 | | |
112 | 153 | | |
113 | 154 | | |
| 155 | + | |
114 | 156 | | |
115 | 157 | | |
116 | 158 | | |
| |||
133 | 175 | | |
134 | 176 | | |
135 | 177 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | 178 | | |
141 | 179 | | |
142 | 180 | | |
| |||
148 | 186 | | |
149 | 187 | | |
150 | 188 | | |
151 | | - | |
152 | 189 | | |
153 | 190 | | |
154 | 191 | | |
155 | 192 | | |
156 | | - | |
| 193 | + | |
157 | 194 | | |
158 | 195 | | |
159 | 196 | | |
| |||
164 | 201 | | |
165 | 202 | | |
166 | 203 | | |
167 | | - | |
168 | 204 | | |
169 | 205 | | |
170 | 206 | | |
171 | 207 | | |
172 | 208 | | |
173 | | - | |
174 | | - | |
175 | 209 | | |
176 | 210 | | |
177 | | - | |
178 | 211 | | |
179 | 212 | | |
180 | 213 | | |
| |||
199 | 232 | | |
200 | 233 | | |
201 | 234 | | |
202 | | - | |
203 | 235 | | |
204 | 236 | | |
205 | 237 | | |
| |||
214 | 246 | | |
215 | 247 | | |
216 | 248 | | |
217 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
218 | 254 | | |
219 | 255 | | |
220 | 256 | | |
| |||
224 | 260 | | |
225 | 261 | | |
226 | 262 | | |
227 | | - | |
228 | 263 | | |
229 | 264 | | |
230 | 265 | | |
| |||
241 | 276 | | |
242 | 277 | | |
243 | 278 | | |
244 | | - | |
245 | 279 | | |
246 | 280 | | |
247 | 281 | | |
| |||
302 | 336 | | |
303 | 337 | | |
304 | 338 | | |
305 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
306 | 343 | | |
307 | 344 | | |
308 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
32 | 73 | | |
33 | 74 | | |
34 | 75 | | |
| |||
84 | 125 | | |
85 | 126 | | |
86 | 127 | | |
87 | | - | |
88 | 128 | | |
89 | 129 | | |
90 | 130 | | |
| |||
119 | 159 | | |
120 | 160 | | |
121 | 161 | | |
122 | | - | |
123 | 162 | | |
124 | 163 | | |
125 | 164 | | |
126 | 165 | | |
127 | 166 | | |
128 | 167 | | |
129 | 168 | | |
130 | | - | |
131 | | - | |
132 | 169 | | |
133 | 170 | | |
134 | 171 | | |
| |||
357 | 394 | | |
358 | 395 | | |
359 | 396 | | |
360 | | - | |
361 | 397 | | |
362 | 398 | | |
363 | 399 | | |
| |||
379 | 415 | | |
380 | 416 | | |
381 | 417 | | |
382 | | - | |
383 | 418 | | |
384 | 419 | | |
385 | 420 | | |
386 | 421 | | |
387 | | - | |
388 | 422 | | |
389 | 423 | | |
390 | 424 | | |
| |||
459 | 493 | | |
460 | 494 | | |
461 | 495 | | |
462 | | - | |
463 | 496 | | |
464 | 497 | | |
465 | 498 | | |
466 | 499 | | |
467 | 500 | | |
468 | 501 | | |
469 | 502 | | |
470 | | - | |
471 | 503 | | |
472 | 504 | | |
473 | 505 | | |
474 | 506 | | |
475 | 507 | | |
476 | 508 | | |
477 | | - | |
478 | 509 | | |
479 | 510 | | |
480 | 511 | | |
481 | 512 | | |
482 | 513 | | |
483 | 514 | | |
484 | 515 | | |
485 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
486 | 520 | | |
487 | 521 | | |
488 | 522 | | |
| |||
521 | 555 | | |
522 | 556 | | |
523 | 557 | | |
524 | | - | |
525 | 558 | | |
526 | 559 | | |
527 | 560 | | |
| |||
0 commit comments