Skip to content

Commit d6f6dba

Browse files
author
Toon Schoenmakers
committed
Better to set multiple socket flags at once
1 parent 226ef47 commit d6f6dba

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/tcpresolver.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,9 @@ class TcpResolver : public TcpState
112112
// connection succeeded, mark socket as non-blocking
113113
if (_socket >= 0)
114114
{
115-
// turn socket into a non-blocking socket
116-
fcntl(_socket, F_SETFL, O_NONBLOCK);
115+
// turn socket into a non-blocking socket and set the close-on-exec bit
116+
fcntl(_socket, F_SETFL, O_NONBLOCK | O_CLOEXEC);
117117

118-
// switch on the close-on-exec bit
119-
fcntl(_socket, F_SETFL, O_CLOEXEC);
120-
121118
// we want to enable "nodelay" on sockets (otherwise all send operations are s-l-o-w
122119
int optval = 1;
123120

0 commit comments

Comments
 (0)