Repository navigation
System.Native: Stop using EV_RECEIPT in the kevent code - #130372
Conversation
…king The EV_RECEIPT is used for two reasons: 1. If we want to know specifically which events from changelist have failed to register. This is not the case for us, as we're passing eventlist=NULL and nevents=0 2. If we want to stop processing changelist after the first error encountered. This is achieved by passing nevents=0, like this code does, but it doesn't really want that. Avoiding passing EV_RECEIPT allows to remove the FreeBSD/OpenBSD hack that was trying to accomodate for the behavior caused by passing the flag. This solution is explained in dotnet#26633 (comment) and https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229741#c6
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
|
Should we unlock and reopen #26633 and mark this PR as closing it? |
|
That makes sense to me, yes. |
|
Workflow state for the Holistic Review Orchestrator. {
"version": 5,
"last_dispatched_commit": "43f932ca212493ef9e151772c4a5f1512ab81606",
"last_dispatched_base_ref": "main",
"last_dispatched_base_sha": "7abe5f60c079129a57c358451cfe01ee198fa40f",
"last_reviewed_commit": "43f932ca212493ef9e151772c4a5f1512ab81606",
"last_reviewed_base_ref": "main",
"last_reviewed_base_sha": "7abe5f60c079129a57c358451cfe01ee198fa40f",
"last_recorded_worker_run_id": "29680701695",
"review_attempt_commit": "",
"review_attempt_base_ref": "",
"review_attempt_count": 0,
"max_review_attempts": 5,
"review_history_format": "holistic-review-disclosure-v1",
"review_history": [
{
"commit": "43f932ca212493ef9e151772c4a5f1512ab81606",
"review_id": 4730521945
}
]
} |
There was a problem hiding this comment.
Holistic Review
Motivation: Justified. The EV_RECEIPT flag provides no benefit here because the code passes eventlist=NULL and nevents=0, and it was the direct cause of the FreeBSD/OpenBSD arming bug (#30698) that required the special-cased split kevent() workaround. Removing it addresses the root cause rather than the symptom, and the reasoning is well-documented via the linked FreeBSD bug and #26633 discussion.
Approach: Correct. Dropping EV_RECEIPT from AddFlags/RemoveFlags lets the read and write filters be armed in a single kevent() call again, which allows the #if defined(__FreeBSD__) || defined(__OpenBSD__) split-call hack to be removed entirely. The remaining logic (building up to two struct kevent entries and issuing one kevent() with EINTR retry) is unchanged and internally consistent. No dangling references to EV_RECEIPT remain in the file.
Summary: EV_RECEIPT into the flags. With nevents=0/eventlist=NULL, EV_RECEIPT was effectively inert on those platforms (there is no event list for it to populate), so removal should be behavior-neutral there, but a maintainer familiar with the macOS socket async path should confirm error-propagation semantics are unaffected. No blocking issues found; the community contributor's explanation is convincing.
Detailed Findings
✅ Correctness: The changelist is still processed atomically in a single kevent() call, and error handling (EINTR retry loop, SystemNative_ConvertErrorPlatformToPal(errno)) is preserved. Removing the FreeBSD/OpenBSD split-call path eliminates the code that reset i = 0 mid-function, simplifying control flow without altering the general path.
✅ Scope / cleanliness: Change is tightly scoped to the two flag constants and the platform-specific hack. No unrelated edits.
💡 Verification: Since this affects async connect-completion delivery, it would be worth confirming via CI or a manual run that FreeBSD async connect no longer hangs and macOS socket event registration still reports registration errors as before.
Note
This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.
Generated by Holistic Review · 44.7 AIC · ⌖ 10.4 AIC · ⊞ 10K
The EV_RECEIPT is used for two reasons:
This solution is explained in #26633 (comment) and https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229741#c6
@sec @buzuka @wfurt