[PATCH v2 09/11] coio: fix file descriptor leak on accept
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed Dec 5 00:28:56 MSK 2018
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)
More information about the Tarantool-patches
mailing list