Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files

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.
  • Loading branch information...
bnoordhuis committed Aug 25, 2012
1 parent 0ac2fdc commit ad7b48aeec39ba90a9817aaf07abcaf3f9ebf462
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/unix/udp.c
@@ -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)
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)
req->bufs = NULL;

if (req->send_cb == NULL)

0 comments on commit ad7b48a

Please sign in to comment.
You can’t perform that action at this time.