unix: fix memory leak in udp.c
Some memory was leaked when the uv_udp_t handle was closed when there were in-flight send requests with a heap allocated buffer list. That doesn't happen much in practice. In the common case (writing < 5 buffers), the buffer list is stored inside the uv_udp_send_t structure, not allocated on the heap.
This commit is contained in:
parent
0ac2fdc554
commit
ad7b48aeec
@ -86,6 +86,10 @@ void uv__udp_finish_close(uv_udp_t* handle) {
|
||||
req = ngx_queue_data(q, uv_udp_send_t, queue);
|
||||
uv__req_unregister(handle->loop, req);
|
||||
|
||||
if (req->bufs != req->bufsml)
|
||||
free(req->bufs);
|
||||
req->bufs = NULL;
|
||||
|
||||
if (req->send_cb) {
|
||||
/* FIXME proper error code like UV_EABORTED */
|
||||
uv__set_artificial_error(handle->loop, UV_EINTR);
|
||||
@ -171,6 +175,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) {
|
||||
|
||||
if (req->bufs != req->bufsml)
|
||||
free(req->bufs);
|
||||
req->bufs = NULL;
|
||||
|
||||
if (req->send_cb == NULL)
|
||||
continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user