From: Remi Gacogne Date: Mon, 9 May 2016 08:06:07 +0000 (+0200) Subject: Return false if `setsockopt()` failed in `setTCPNoDelay()` X-Git-Tag: rec-4.0.0-alpha3~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=883a30a7f309871674a87aa332a519b4daa81c17;p=thirdparty%2Fpdns.git Return false if `setsockopt()` failed in `setTCPNoDelay()` --- diff --git a/pdns/misc.cc b/pdns/misc.cc index a009fb4e63..c51fe961c2 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -1005,14 +1005,14 @@ bool setSocketTimestamps(int fd) return true; // we pretend this happened. } -void setTCPNoDelay(int sock) +bool setTCPNoDelay(int sock) { int flag = 1; - setsockopt(sock, /* socket affected */ - IPPROTO_TCP, /* set option at TCP level */ - TCP_NODELAY, /* name of option */ - (char *) &flag, /* the cast is historical cruft */ - sizeof(flag)); /* length of option value */ + return setsockopt(sock, /* socket affected */ + IPPROTO_TCP, /* set option at TCP level */ + TCP_NODELAY, /* name of option */ + (char *) &flag, /* the cast is historical cruft */ + sizeof(flag)) == 0; /* length of option value */ } diff --git a/pdns/misc.hh b/pdns/misc.hh index 252df85e68..890fb6487a 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -596,7 +596,7 @@ bool setBlocking( int sock ); //! Sets the socket into non-blocking mode. bool setNonBlocking( int sock ); -void setTCPNoDelay(int sock); +bool setTCPNoDelay(int sock); bool isNonBlocking(int sock); int closesocket(int fd); bool setCloseOnExec(int sock);