iothread: fix epollfd leak in the process of delIOThread
PATCH 1/1 iothread: fix epollfd leak in the process of delIOThread
When we call addIOThread, the epollfd created in aio_context_setup, but not close it in the process of delIOThread, so the epollfd will leak.
--- iothread.c | 1 + 1 file changed, 1 insertion(+)
iothread.c +1 -0
@@ -128,6 +128,7 @@ static void iothread_instance_finalize(Object *obj)* GSources first before destroying any GMainContext. */ if (iothread->ctx) { +close (iothread->ctx->epollfd);aio_context_unref (iothread->ctx); iothread->ctx =NULL ; }
Signature · 1 line
1.8.3.1
Quoted 23 lines · Jie Wang
When we call addIOThread, the epollfd created in
aio_context_setup, but not close it in the process of delIOThread, so the epollfd will leak.Signed-off-by Jie Wang <[email protected]>--- iothread.c | 1 + 1 file changed, 1 insertion(+)iothread.c +1
-0@@ -128,6 +128,7 @@ static void iothread_instance_finalize(Object *obj)* GSources first before destroying any GMainContext. */ if (iothread->ctx) { +close (iothread->ctx->epollfd);aio_context_unref (iothread->ctx); iothread->ctx =NULL ; }Signature · 1 line
1.8.3.1
Please add an aio_context_destroy() function in aio-posix.c and call it from aio_context_finalize(). IOThread code should not touch AioContext internals. Also please remember to wrap the close() code in CONFIG_EPOLL_CREATE1. An empty function may need to be added to aio-win32.c, too.
Fam
Quoted 19 lines · Fam Zheng
Quoted 18 lines · Jie Wang
When we call addIOThread, the epollfd created in
aio_context_setup, but not close it in the process of delIOThread, so the epollfd will leak.Signed-off-by Jie Wang <[email protected]>--- iothread.c | 1 + 1 file changed, 1 insertion(+)iothread.c +1
-0@@ -128,6 +128,7 @@ static void iothread_instance_finalize(Object *obj)* GSources first before destroying any GMainContext. */ if (iothread->ctx) { +close (iothread->ctx->epollfd);aio_context_unref (iothread->ctx);
Quoted 8 lines
Quoted 5 lines
iothread.c +0
-0iothread->ctx =NULL ; }Signature · 1 line
1.8.3.1Please add an
aio_context_destroy()function inaio-posix.cand call it fromaio_context_finalize(). IOThread code should not touch AioContext internals.
I believe Fam means aio_ctx_finalize().
Quoted 2 lines
Also please remember to wrap the
close()code inCONFIG_EPOLL_CREATE1. An empty function may need to be added toaio-win32.c, too.
Agreed.
Signature · 1 line
Peter Xu