]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/snmp/Request.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / snmp / Request.cc
index b204f8c2e90f1a09ca45a62287b78becfed214e7..b21aa3958e4775101fca5d57daad4396c2fe9d67 100644 (file)
@@ -1,33 +1,27 @@
 /*
- * $Id$
- *
- * DEBUG: section 49    SNMP Interface
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
-#include "config.h"
+/* DEBUG: section 49    SNMP Interface */
+
+#include "squid.h"
 #include "ipc/Messages.h"
 #include "ipc/TypedMsgHdr.h"
 #include "snmp/Request.h"
 
-
-Snmp::Request::Request(int aRequestorId, unsigned int aRequestId,
+Snmp::Request::Request(const int aRequestorId, const Ipc::RequestId aRequestId,
                        const Pdu& aPdu, const Session& aSession,
                        int aFd, const Ip::Address& anAddress):
-        Ipc::Request(aRequestorId, aRequestId),
-        pdu(aPdu), session(aSession), fd(aFd), address(anAddress)
+    Ipc::Request(aRequestorId, aRequestId),
+    pdu(aPdu), session(aSession), fd(aFd), address(anAddress)
 {
 }
 
-Snmp::Request::Request(const Request& request):
-        Ipc::Request(request.requestorId, request.requestId),
-        pdu(request.pdu), session(request.session),
-        fd(request.fd), address(request.address)
-{
-}
-
-Snmp::Request::Request(const Ipc::TypedMsgHdr& msg):
-        Ipc::Request(0, 0)
+Snmp::Request::Request(const Ipc::TypedMsgHdr &msg)
 {
     msg.checkType(Ipc::mtSnmpRequest);
     msg.getPod(requestorId);
@@ -36,7 +30,8 @@ Snmp::Request::Request(const Ipc::TypedMsgHdr& msg):
     session.unpack(msg);
     msg.getPod(address);
 
-    fd = msg.getFd();
+    // Requests from strands have FDs. Requests from Coordinator do not.
+    fd = msg.hasFd() ? msg.getFd() : -1;
 }
 
 void
@@ -49,7 +44,9 @@ Snmp::Request::pack(Ipc::TypedMsgHdr& msg) const
     session.pack(msg);
     msg.putPod(address);
 
-    msg.putFd(fd);
+    // Requests sent to Coordinator have FDs. Requests sent to strands do not.
+    if (fd >= 0)
+        msg.putFd(fd);
 }
 
 Ipc::Request::Pointer
@@ -57,3 +54,4 @@ Snmp::Request::clone() const
 {
     return new Request(*this);
 }
+