forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit498a29d
committed
Make WaitLatchOrSocket's timeout detection more robust.
In the previous coding, timeout would be noticed and reported only whenpoll() or socket() returned zero (or the equivalent behavior on Windows).Ordinarily that should work well enough, but it seems conceivable that wecould get into a state where poll() always returns a nonzero value --- forexample, if it is noticing a condition on one of the file descriptors thatwe do not think is reason to exit the loop. If that happened, we'd be in abusy-wait loop that would fail to terminate even when the timeout expires.We can make this more robust at essentially no cost, by deciding to exitof our own accord if we compute a zero or negative time-remaining-to-wait.Previously the code noted this but just clamped the time-remaining to zero,expecting that we'd detect timeout on the next loop iteration.Back-patch to 9.2. While 9.1 had a version of WaitLatchOrSocket, it wasprimitive compared to later versions, and did not guarantee reliabledetection of timeouts anyway. (Essentially, this is a refinement ofcommit3e7fdcf, which was back-patched only as far as 9.2.)1 parent7319c05 commit498a29d
2 files changed
+19
-10
lines changedLines changed: 13 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
442 | 442 |
| |
443 | 443 |
| |
444 | 444 |
| |
445 |
| - | |
| 445 | + | |
| 446 | + | |
446 | 447 |
| |
447 | 448 |
| |
448 | 449 |
| |
| |||
461 | 462 |
| |
462 | 463 |
| |
463 | 464 |
| |
464 |
| - | |
| 465 | + | |
465 | 466 |
| |
466 | 467 |
| |
467 | 468 |
| |
468 | 469 |
| |
469 |
| - | |
470 |
| - | |
471 |
| - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
472 | 475 |
| |
473 |
| - | |
474 |
| - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
475 | 481 |
| |
476 | 482 |
| |
477 | 483 |
| |
|
Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
259 | 259 |
| |
260 | 260 |
| |
261 | 261 |
| |
262 |
| - | |
| 262 | + | |
263 | 263 |
| |
264 | 264 |
| |
265 | 265 |
| |
266 | 266 |
| |
267 |
| - | |
268 |
| - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
269 | 272 |
| |
270 | 273 |
| |
271 | 274 |
| |
|
0 commit comments
Comments
(0)