This repository was archived by the owner on May 4, 2018. It is now read-only.
Commit b3ab332
committed
unix: fix EMFILE error handling
On Linux, the accept() and accept4() system calls checks for EMFILE
before checking for EAGAIN. Refine our EMFILE error handling tactic
to deal with that. Here is what used to happen:
1. The event loop calls accept() and sees EMFILE.
2. Libuv switches to EMFILE error handling mode. It closes a stashed
file descriptor and calls accept() again.
3. The accept() system call fails with EAGAIN.
4. Libuv reopens the stashed file descriptor (reaching RLIMIT_NOFILE
again) and returns control to the regular event loop.
5. The regular event loop calls accept(), sees EMFILE and jumps to
step 2 again. Effectively an infinite loop.
Avoid that by not calling accept() again when we've seen EAGAIN.
Fixes nodejs/node-v0.x-archive#5389.1 parent 67f9b91 commit b3ab332
1 file changed
+17
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | 444 | | |
446 | 445 | | |
447 | 446 | | |
| |||
459 | 458 | | |
460 | 459 | | |
461 | 460 | | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
| 461 | + | |
| 462 | + | |
470 | 463 | | |
471 | 464 | | |
472 | 465 | | |
| |||
479 | 472 | | |
480 | 473 | | |
481 | 474 | | |
482 | | - | |
483 | 475 | | |
| 476 | + | |
484 | 477 | | |
485 | | - | |
486 | 478 | | |
487 | 479 | | |
488 | 480 | | |
| |||
497 | 489 | | |
498 | 490 | | |
499 | 491 | | |
| 492 | + | |
500 | 493 | | |
501 | 494 | | |
502 | 495 | | |
503 | 496 | | |
504 | | - | |
505 | 497 | | |
| 498 | + | |
506 | 499 | | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
| 500 | + | |
| 501 | + | |
524 | 502 | | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
| 503 | + | |
| 504 | + | |
532 | 505 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
539 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
540 | 515 | | |
541 | 516 | | |
542 | 517 | | |
543 | | - | |
544 | 518 | | |
545 | 519 | | |
546 | 520 | | |
| |||
0 commit comments