From d6f6dba660ebaf8ff9920d1c60905b764bdff66e Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Tue, 22 Dec 2015 15:02:37 +0100 Subject: [PATCH] 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;