Skip to content

Commit

Permalink
Fix for unexpected socket closures and data leakage under heavy load
Browse files Browse the repository at this point in the history
  • Loading branch information
todddialpad committed Nov 25, 2024
1 parent 7bb12a1 commit 752f7c1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions uvloop/loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,7 @@ cdef class Loop:
AddrInfo ai_local = None
AddrInfo ai_remote
TCPTransport tr
int sockfd

system.addrinfo *rai = NULL
system.addrinfo *lai = NULL
Expand Down Expand Up @@ -2060,8 +2061,10 @@ cdef class Loop:
waiter = self._new_future()
tr = TCPTransport.new(self, protocol, None, waiter, context)
try:
# Take ownership of the file descriptor
sockfd = sock.detach()
# libuv will make socket non-blocking
tr._open(sock.fileno())
tr._open(sockfd)
tr._init_protocol()
await waiter
except (KeyboardInterrupt, SystemExit):
Expand All @@ -2075,8 +2078,6 @@ cdef class Loop:
tr._close()
raise

tr._attach_fileobj(sock)

if ssl:
app_transport = protocol._get_app_transport(context)
try:
Expand Down

0 comments on commit 752f7c1

Please sign in to comment.