From 226ef47beb597e9355b94550454f0ec9b6e9f4df Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Mon, 14 Dec 2015 20:20:03 +0100 Subject: [PATCH 1/3] socket connections have close-on-exit bit set --- src/tcpresolver.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tcpresolver.h b/src/tcpresolver.h index e16d626..35475a8 100644 --- a/src/tcpresolver.h +++ b/src/tcpresolver.h @@ -114,6 +114,9 @@ private: { // turn socket into a non-blocking socket fcntl(_socket, F_SETFL, O_NONBLOCK); + + // switch on the close-on-exec bit + fcntl(_socket, F_SETFL, O_CLOEXEC); // we want to enable "nodelay" on sockets (otherwise all send operations are s-l-o-w int optval = 1; From d6f6dba660ebaf8ff9920d1c60905b764bdff66e Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Tue, 22 Dec 2015 15:02:37 +0100 Subject: [PATCH 2/3] Better to set multiple socket flags at once --- src/tcpresolver.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/tcpresolver.h b/src/tcpresolver.h index 35475a8..162dfd8 100644 --- a/src/tcpresolver.h +++ b/src/tcpresolver.h @@ -112,12 +112,9 @@ private: // connection succeeded, mark socket as non-blocking if (_socket >= 0) { - // turn socket into a non-blocking socket - fcntl(_socket, F_SETFL, O_NONBLOCK); + // turn socket into a non-blocking socket and set the close-on-exec bit + fcntl(_socket, F_SETFL, O_NONBLOCK | O_CLOEXEC); - // switch on the close-on-exec bit - fcntl(_socket, F_SETFL, O_CLOEXEC); - // we want to enable "nodelay" on sockets (otherwise all send operations are s-l-o-w int optval = 1; From 09ad7b6cf4cec5a89e67aef7360fc290945847f1 Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Wed, 30 Dec 2015 16:04:34 +0100 Subject: [PATCH 3/3] How about we include libev before using the structs from libev? --- include/libev.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/libev.h b/include/libev.h index 41672ee..a1442ae 100644 --- a/include/libev.h +++ b/include/libev.h @@ -16,6 +16,11 @@ */ #pragma once +/** + * Dependencies + */ +#include + /** * Set up namespace */