← Back to Pull requests

[Windows] Share muxnotes for write-first I/O sources #975

Open
unknown opened this pull request with 254 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 04, 2026 12:23 UTC
Author

When a Windows write source is registered before a read source on the same handle, _dispatch_muxnote_create() stores EVFILT_WRITE, but _dispatch_unote_muxnote_find() canonicalizes both filters to EVFILT_READ. Neither subsequent lookup can find the original writer's muxnote.

For sockets this creates independent muxnotes that each call WSAEventSelect(). A later registration replaces the socket's previous event object and mask, and cancelling one source can disable notifications for the surviving source. See the WSAEventSelect documentation.

Canonicalize the filter at creation too, matching the lookup key and the existing epoll backend. Extend dispatch_io_muxed with a regression that waits for writer registration, then reader registration, then writer cancellation, sends one byte from the peer, and verifies that the reader receives it. The test uses registration/cancellation handlers and the existing bounded group waits; it needs no sleeps or send-buffer-size assumptions.

Related: https://github.com/swiftlang/swift-corelibs-foundation/issues/5532. FoundationNetworking's curl integration uses read/write Dispatch sources, so this is relevant to the reported upload stall. This PR fixes the demonstrated Dispatch registration bug; the URLSession upload symptom has not yet been verified before/after with the rebuilt runtime.

Validation:

  • git diff --check and clean application against current main (2078b9d).

  • macOS arm64: the modified dispatch_io_muxed test passes against system Dispatch; this does not execute the Windows backend.

  • Windows x64 and ARM64: native CMake/Clang builds; the new regression fails on the unmodified backend after sending the byte, then passes after applying the runtime fix. Before/after workflow and logs. The validation workflow lives on a separate branch of my fork and is not part of this PR.
  • Diff: 254 lines (+190 / -64) across 3 files Reviewer: compnerd Review duration: 4233m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 254 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Real PR Conversation Timeline
    1 comments
    "Review active on #975"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.8% · Safe to merge
    20.8%