Commit a675fdd
committed
Fix kqueue false connect success from stale EVFILT_WRITE
The kqueue backend registers sockets for EVFILT_WRITE at open() time.
A freshly created socket is writable, so kqueue fires a stale event
before connect() completes. If the reactor processes this before the
kernel delivers the connect result (e.g. RST for ECONNREFUSED),
getsockopt(SO_ERROR) returns 0 and the connect falsely reports success.
Fix by adding a getpeername() check in connect perform_io() to verify
the connection is actually established when SO_ERROR is 0, returning
EAGAIN to re-park the op if not. Add EAGAIN handling for connect ops
in descriptor_state::operator()() to match the existing read/write
pattern.1 parent 504d294 commit a675fdd
File tree
2 files changed
+50
-3
lines changed- include/boost/corosio/native/detail/kqueue
2 files changed
+50
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
285 | 300 | | |
286 | 301 | | |
287 | 302 | | |
| |||
Lines changed: 35 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
607 | | - | |
608 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
609 | 617 | | |
610 | 618 | | |
611 | 619 | | |
| |||
630 | 638 | | |
631 | 639 | | |
632 | 640 | | |
633 | | - | |
| 641 | + | |
634 | 642 | | |
635 | 643 | | |
636 | 644 | | |
| |||
661 | 669 | | |
662 | 670 | | |
663 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
664 | 685 | | |
665 | 686 | | |
666 | 687 | | |
| |||
688 | 709 | | |
689 | 710 | | |
690 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
691 | 723 | | |
692 | 724 | | |
693 | 725 | | |
| |||
0 commit comments