forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0f527f7
committed
Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition.
pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()as being a reason to block ever since the current implementation wasintroduced in commita4c40f1. However, so far as one can tellfrom Microsoft's documentation, that is just wrong: what it means isgraceful connection closure (in stream protocols) or receipt of azero-length message (in message protocols), and neither case should resultin blocking here. The only reason the code worked at all was that controlthen fell into the retry loop, which did *not* treat zero bytes specially,so we'd get out after only wasting some cycles. But as of 9.5 we do notnormally reach the retry loop and so the bug is exposed, as reported byShay Rojansky and diagnosed by Andres Freund.Remove the unnecessary test on the byte count, and rearrange the codein the retry loop so that it looks identical to the initial sequence.Back-patch of commit90e61df. Theoriginal plan was to apply this only to 9.5 and up, but after discussionand buildfarm testing, it seems better to back-patch. The noblock codepath has been at risk of this problem since it was introduced (in 9.0);if it did happen in pre-9.5 branches, the symptom would be that a walsenderwould wait indefinitely rather than noticing a loss of connection. Whilewe lack proof that the case has been seen in the field, it seems possiblethat it's happened without being reported.1 parent6a0d63d commit0f527f7
1 file changed
+16
-21
lines changedLines changed: 16 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
323 | 323 |
| |
324 | 324 |
| |
325 | 325 |
| |
326 |
| - | |
327 |
| - | |
328 |
| - | |
| 326 | + | |
| 327 | + | |
329 | 328 |
| |
330 |
| - | |
331 |
| - | |
| 329 | + | |
332 | 330 |
| |
333 | 331 |
| |
334 | 332 |
| |
| |||
344 | 342 |
| |
345 | 343 |
| |
346 | 344 |
| |
347 |
| - | |
| 345 | + | |
348 | 346 |
| |
349 | 347 |
| |
350 | 348 |
| |
| |||
353 | 351 |
| |
354 | 352 |
| |
355 | 353 |
| |
356 |
| - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
357 | 357 |
| |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 |
| - | |
364 |
| - | |
365 |
| - | |
366 |
| - | |
367 |
| - | |
368 |
| - | |
369 |
| - | |
370 |
| - | |
371 | 358 |
| |
372 | 359 |
| |
373 | 360 |
| |
374 |
| - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
375 | 370 |
| |
376 | 371 |
| |
377 | 372 |
| |
|
0 commit comments
Comments
(0)