From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladislav Shpilevoy Subject: [PATCH v2 09/11] coio: fix file descriptor leak on accept Date: Wed, 5 Dec 2018 00:28:56 +0300 Message-Id: <61d6866f5e2977d45c67fb8be0c1131071e382a0.1543958698.git.v.shpilevoy@tarantool.org> In-Reply-To: References: In-Reply-To: References: To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com List-ID: coio_accept() calls evio_setsockopt_client, which throws an exception and just accepted socket leaks. Yes, server socket is protected, but not new client socket. The bug existed even before exceptions are removed from evio. --- src/coio.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/coio.cc b/src/coio.cc index 82bf72e69..c45e72507 100644 --- a/src/coio.cc +++ b/src/coio.cc @@ -256,8 +256,10 @@ coio_accept(struct ev_io *coio, struct sockaddr *addr, int fd = sio_accept(coio->fd, addr, &addrlen); if (fd >= 0) { if (evio_setsockopt_client(fd, addr->sa_family, - SOCK_STREAM) != 0) + SOCK_STREAM) != 0) { + close(fd); diag_raise(); + } return fd; } if (sio_is_error_fatal(fd)) -- 2.17.2 (Apple Git-113)