mirror of https://github.com/MagicStack/uvloop.git
Correctly dealloc detached handlers
This is a different fix for issue #37. The original fix that removed dynamic memory allocation of uv_handles had to be reverted.
This commit is contained in:
parent
7b0b195d10
commit
2af7b2adbe
|
@ -17,7 +17,7 @@ cdef class UVHandle:
|
|||
cdef _error(self, exc, throw)
|
||||
cdef _fatal_error(self, exc, throw, reason=?)
|
||||
|
||||
cdef _free(self)
|
||||
cdef inline _free(self)
|
||||
cdef _close(self)
|
||||
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ cdef class UVHandle:
|
|||
self._closed = 1
|
||||
self._free()
|
||||
|
||||
|
||||
cdef _free(self):
|
||||
cdef inline _free(self):
|
||||
PyMem_Free(self._handle)
|
||||
self._handle = NULL
|
||||
|
||||
|
@ -303,17 +302,17 @@ cdef void __uv_close_handle_cb(uv.uv_handle_t* handle) with gil:
|
|||
PyMem_Free(handle)
|
||||
return
|
||||
|
||||
if <object>handle.data is not __NOHANDLE__:
|
||||
if <object>handle.data is __NOHANDLE__:
|
||||
# The original UVHandle is long dead. Just free the mem of
|
||||
# the uv_handle_t* handler.
|
||||
PyMem_Free(handle)
|
||||
else:
|
||||
h = <UVHandle>handle.data
|
||||
h._handle = NULL
|
||||
IF DEBUG:
|
||||
h._loop._debug_handles_closed.update([
|
||||
h.__class__.__name__])
|
||||
h._free()
|
||||
Py_DECREF(h) # Was INCREFed in UVHandle._close
|
||||
return
|
||||
|
||||
PyMem_Free(handle)
|
||||
|
||||
|
||||
cdef void __close_all_handles(Loop loop):
|
||||
|
|
|
@ -177,7 +177,7 @@ cdef class UVProcess(UVHandle):
|
|||
'UVProcess._close_after_spawn called after uv_spawn')
|
||||
self._fds_to_close.add(fd)
|
||||
|
||||
cdef _free(self):
|
||||
def __dealloc__(self):
|
||||
if self.uv_opt_env is not NULL:
|
||||
PyMem_Free(self.uv_opt_env)
|
||||
self.uv_opt_env = NULL
|
||||
|
@ -186,8 +186,6 @@ cdef class UVProcess(UVHandle):
|
|||
PyMem_Free(self.uv_opt_args)
|
||||
self.uv_opt_args = NULL
|
||||
|
||||
UVHandle._free(self)
|
||||
|
||||
cdef char** __to_cstring_array(self, list arr):
|
||||
cdef:
|
||||
int i
|
||||
|
|
Loading…
Reference in New Issue