Skip to content

Commit 5d532fc

Browse files
kulikjakmiss-islington
authored andcommitted
gh-145030: Fix asyncio write pipe transport for named FIFOs on Solaris (GH-155110)
(cherry picked from commit 910e584) Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
1 parent 0e10534 commit 5d532fc

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

Lib/asyncio/unix_events.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -657,19 +657,19 @@ def __init__(self, loop, pipe, protocol, waiter=None, extra=None):
657657
# On AIX, the reader trick (to be notified when the read end of the
658658
# socket is closed) only works for sockets. On other platforms it
659659
# works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.)
660-
# On macOS, the trick misfires for named FIFOs (but not for pipes
661-
# created with os.pipe(), which have st_nlink == 0): the write end
662-
# polls as readable whenever unread data sits in the FIFO, and no
660+
# On macOS and Solaris, the trick misfires for named FIFOs (but not for
661+
# pipes created with os.pipe(), which have st_nlink == 0): the write
662+
# end polls as readable whenever unread data sits in the FIFO, and no
663663
# event is delivered when the read end is closed, so it can only
664-
# ever report a false disconnection (gh-145030). The same xnu
664+
# ever report a false disconnection (gh-145030). The same XNU
665665
# behaviour applies on iOS/tvOS/watchOS (sys.platform is not
666666
# "darwin" there).
667-
is_named_fifo_on_apple = (
668-
sys.platform in {"darwin", "ios", "tvos", "watchos"}
667+
is_named_fifo_without_close_event = (
668+
sys.platform in {"darwin", "ios", "tvos", "watchos", "sunos5"}
669669
and is_fifo and pipe_stat.st_nlink > 0)
670670
if is_socket or (is_fifo
671671
and not sys.platform.startswith("aix")
672-
and not is_named_fifo_on_apple):
672+
and not is_named_fifo_without_close_event):
673673
# only start reading when connection_made() has been called
674674
self._loop.call_soon(self._loop._add_reader,
675675
self._fileno, self._read_ready)

Lib/test/test_asyncio/test_events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,9 @@ def reader(data):
17291729
"Don't support pipes for Windows")
17301730
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'requires os.mkfifo()')
17311731
def test_write_named_fifo_unread_data(self):
1732-
# gh-145030: on macOS, the write end of a named FIFO polls as
1733-
# readable while unread data sits in the FIFO, which made the
1734-
# transport misinterpret the event as the reader hanging up
1732+
# gh-145030: on macOS and Solaris, the write end of a named FIFO
1733+
# polls as readable while unread data sits in the FIFO, which made
1734+
# the transport misinterpret the event as the reader hanging up
17351735
# and close itself.
17361736
path = os_helper.TESTFN
17371737
os.mkfifo(path)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Fix :mod:`asyncio` write pipe transports for named FIFOs on macOS. Unread
2-
data sitting in the FIFO made the transport misinterpret a poll event as
3-
the reader disconnecting, wrongly closing the transport.
1+
Fix :mod:`asyncio` write pipe transports for named FIFOs on macOS and Solaris.
2+
Unread data sitting in the FIFO made the transport misinterpret a poll event
3+
as the reader disconnecting, wrongly closing the transport.

0 commit comments

Comments
 (0)