Skip to content

Commit 13f63e0

Browse files
committed
Make sure UDP handles are cleaned-up properly
1 parent ce84b7e commit 13f63e0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

uvloop/handles/udp.pyx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cdef class UDPTransport(UVBaseTransport):
2020
self.poll = UVPoll.new(loop, sock.fileno())
2121
self._finish_init()
2222
except:
23+
self._free()
2324
self._abort_init()
2425
raise
2526

@@ -102,6 +103,7 @@ cdef class UDPTransport(UVBaseTransport):
102103
cdef _dealloc_impl(self):
103104
if self._closed == 0:
104105
self._warn_unclosed()
106+
self._close()
105107

106108
# It is unsafe to call `self.poll._close()` here as
107109
# we might be at the stage where all CPython objects
@@ -110,7 +112,7 @@ cdef class UDPTransport(UVBaseTransport):
110112

111113
UVHandle._dealloc_impl(self)
112114

113-
cdef _close(self):
115+
cdef _free(self):
114116
if self.poll is not None:
115117
self.poll._close()
116118
self.poll = None
@@ -122,6 +124,11 @@ cdef class UDPTransport(UVBaseTransport):
122124
finally:
123125
self.sock = None
124126

127+
UVBaseTransport._free(self)
128+
129+
cdef _close(self):
130+
self._free()
131+
125132
if UVLOOP_DEBUG:
126133
self._loop._debug_handles_closed.update([
127134
self.__class__.__name__])

0 commit comments

Comments
 (0)