]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
For setting socket buf size not decreasing is not an error 12333/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 16 Dec 2022 08:24:44 +0000 (09:24 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 16 Dec 2022 08:27:45 +0000 (09:27 +0100)
pdns/iputils.cc

index ea5180b8564b188a23b59565ef7f1deb64546e3d..e0c7218f775c6400bc34f9aeaa4c41aacdc1d482 100644 (file)
@@ -516,11 +516,13 @@ void setSocketBuffer(int fd, int optname, uint32_t size)
   uint32_t psize = 0;
   socklen_t len = sizeof(psize);
 
-  if (!getsockopt(fd, SOL_SOCKET, optname, &psize, &len) && psize > size) {
-    throw std::runtime_error("Not decreasing socket buffer size from " + std::to_string(psize) + " to " + std::to_string(size));
+  if (getsockopt(fd, SOL_SOCKET, optname, &psize, &len) != 0) {
+    throw std::runtime_error("Unable to retrieve socket buffer size:" + stringerror());
   }
-
-  if (setsockopt(fd, SOL_SOCKET, optname, &size, sizeof(size)) < 0) {
+  if (psize >= size) {
+    return;
+  }
+  if (setsockopt(fd, SOL_SOCKET, optname, &size, sizeof(size)) != 0) {
     throw std::runtime_error("Unable to raise socket buffer size to " + std::to_string(size) + ": " + stringerror());
   }
 }