Skip to content

Commit ec80c15

Browse files
committed
Fix double unsubscribe from TCPConnection event on non-Windows systems
Closes #4639
1 parent 6e97b89 commit ec80c15

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/net/tcp_connection.pony

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,18 @@ actor TCPConnection is AsioEventNotify
636636
@pony_asio_event_unsubscribe(event)
637637
end
638638
@pony_os_socket_close(fd)
639-
_try_shutdown()
639+
ifdef windows then
640+
// Fix for windows happy-eyeballs related hang from
641+
// 95a06bb290150d13b5764de70c1332a6d7b237cf.
642+
// This should not be called on non-IOCP as that can result in
643+
// issue #4639 where we call `pony_asio_event_unsubscribe` more than
644+
// once which can result in an actor that is already marked
645+
// for destruction getting a message sent to it.
646+
// This might be a race condition on Windows (I think it could be)
647+
// but Windows is so slow closing down connections that we don't
648+
// to ever hit it if it is indeed a race condition.
649+
_try_shutdown()
650+
end
640651
end
641652
else
642653
// It's not our event.

0 commit comments

Comments
 (0)