Skip to content

Commit 44b655c

Browse files
[3.13] gh-145030: Fix asyncio write pipe transport for named FIFOs on Solaris (GH-155110) (#155129)
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 02befc8 commit 44b655c

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
@@ -668,19 +668,19 @@ def __init__(self, loop, pipe, protocol, waiter=None, extra=None):
668668
# On AIX, the reader trick (to be notified when the read end of the
669669
# socket is closed) only works for sockets. On other platforms it
670670
# works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.)
671-
# On macOS, the trick misfires for named FIFOs (but not for pipes
672-
# created with os.pipe(), which have st_nlink == 0): the write end
673-
# polls as readable whenever unread data sits in the FIFO, and no
671+
# On macOS and Solaris, the trick misfires for named FIFOs (but not for
672+
# pipes created with os.pipe(), which have st_nlink == 0): the write
673+
# end polls as readable whenever unread data sits in the FIFO, and no
674674
# event is delivered when the read end is closed, so it can only
675-
# ever report a false disconnection (gh-145030). The same xnu
675+
# ever report a false disconnection (gh-145030). The same XNU
676676
# behaviour applies on iOS/tvOS/watchOS (sys.platform is not
677677
# "darwin" there).
678-
is_named_fifo_on_apple = (
679-
sys.platform in {"darwin", "ios", "tvos", "watchos"}
678+
is_named_fifo_without_close_event = (
679+
sys.platform in {"darwin", "ios", "tvos", "watchos", "sunos5"}
680680
and is_fifo and pipe_stat.st_nlink > 0)
681681
if is_socket or (is_fifo
682682
and not sys.platform.startswith("aix")
683-
and not is_named_fifo_on_apple):
683+
and not is_named_fifo_without_close_event):
684684
# only start reading when connection_made() has been called
685685
self._loop.call_soon(self._loop._add_reader,
686686
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
@@ -1613,9 +1613,9 @@ def reader(data):
16131613
"Don't support pipes for Windows")
16141614
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'requires os.mkfifo()')
16151615
def test_write_named_fifo_unread_data(self):
1616-
# gh-145030: on macOS, the write end of a named FIFO polls as
1617-
# readable while unread data sits in the FIFO, which made the
1618-
# transport misinterpret the event as the reader hanging up
1616+
# gh-145030: on macOS and Solaris, the write end of a named FIFO
1617+
# polls as readable while unread data sits in the FIFO, which made
1618+
# the transport misinterpret the event as the reader hanging up
16191619
# and close itself.
16201620
path = os_helper.TESTFN
16211621
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)