- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit90e61df
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 to 9.5. The code is wrong all the way back, AFAICS, butsince it's relatively harmless in earlier branches we'll leave it alone.1 parentb416c0b commit90e61df
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)