From: Otto Moerbeek Date: Fri, 16 Dec 2022 08:24:44 +0000 (+0100) Subject: For setting socket buf size not decreasing is not an error X-Git-Tag: rec-4.8.2~8^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F12345%2Fhead;p=thirdparty%2Fpdns.git For setting socket buf size not decreasing is not an error (cherry picked from commit fe65dec04f3fadaca8f5319cf02f4b302463afe9) --- diff --git a/pdns/iputils.cc b/pdns/iputils.cc index 528ae90149..1226368738 100644 --- a/pdns/iputils.cc +++ b/pdns/iputils.cc @@ -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()); } }