Skip to content

Commit 7818f58

Browse files
committed
Update comments to clarify the impact of the AFD_IOCTL_POLL bug
1 parent f9c3b54 commit 7818f58

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

notes-to-self/afd-lab.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#
1515
# ...then the SEND poll operation completes with the RECEIVE flag set.
1616
#
17+
# (This bug is why our Windows backend jumps through hoops to avoid ever
18+
# issuing multiple polls simultaneously for the same socket.)
19+
#
1720
# This script's output on my machine:
1821
#
1922
# -- Iteration start --

trio/_core/_io_windows.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@
125125
# which events happened, and uses IOCP as normal to notify us that this
126126
# operation has completed.
127127
#
128-
# There's some trickiness required to handle multiple tasks that are waiting
129-
# on the same socket simultaneously, so instead of using the wait_overlapped
130-
# machinery, we have some dedicated code to handle these operations, and a
128+
# Unfortunately, the Windows kernel seems to have bugs if you try to issue
129+
# multiple simultaneous IOCTL_AFD_POLL operations on the same socket (see
130+
# notes-to-self/afd-lab.py). So if a user calls wait_readable and
131+
# wait_writable at the same time, we have to combine those into a single
132+
# IOCTL_AFD_POLL. This means we can't just use the wait_overlapped machinery.
133+
# Instead we have some dedicated code to handle these operations, and a
131134
# dedicated completion key CKeys.AFD_POLL.
132135
#
133136
# Sources of information:
@@ -139,7 +142,8 @@
139142
# https://github.com/pustladi/Windows-2000/blob/661d000d50637ed6fab2329d30e31775046588a9/private/net/sockets/winsock2/wsp/msafd/select.c#L59-L655
140143
# https://github.com/metoo10987/WinNT4/blob/f5c14e6b42c8f45c20fe88d14c61f9d6e0386b8e/private/ntos/afd/poll.c#L68-L707
141144
# - The WSAEventSelect docs (this exposes a finer-grained set of events than
142-
# select())
145+
# select(), so if you squint you can treat it as a source of information on
146+
# the fine-grained AFD poll types)
143147
#
144148
#
145149
# == Everything else ==

0 commit comments

Comments
 (0)