]> granicus.if.org Git - pdns/commitdiff
Return false if `setsockopt()` failed in `setTCPNoDelay()`
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 May 2016 08:06:07 +0000 (10:06 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 May 2016 08:06:07 +0000 (10:06 +0200)
pdns/misc.cc
pdns/misc.hh

index a009fb4e63cf50588c82d989176172db079d8e2e..c51fe961c2ed97cd56340ade340499744282424b 100644 (file)
@@ -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 */
 }
 
 
index 252df85e6819cda8c7e8577c5d10336aa2d4b735..890fb6487a1dc0c1aefb81a7068b62d73a99f464 100644 (file)
@@ -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);