From 883a30a7f309871674a87aa332a519b4daa81c17 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 9 May 2016 10:06:07 +0200 Subject: [PATCH] Return false if `setsockopt()` failed in `setTCPNoDelay()` --- pdns/misc.cc | 12 ++++++------ pdns/misc.hh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) 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); -- 2.47.2