]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ipc/UdsOp.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / ipc / UdsOp.cc
index 5393dd2ce79aea913cbd32bfbf0093792d0f6559..726443ade05204f85c2b64fecfae1d7838592bbc 100644 (file)
@@ -1,8 +1,13 @@
 /*
- * DEBUG: section 54    Interprocess Communication
+ * Copyright (C) 1996-2020 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.
  */
 
+/* DEBUG: section 54    Interprocess Communication */
+
 #include "squid.h"
 #include "base/TextException.h"
 #include "comm.h"
@@ -12,9 +17,9 @@
 #include "ipc/UdsOp.h"
 
 Ipc::UdsOp::UdsOp(const String& pathAddr):
-        AsyncJob("Ipc::UdsOp"),
-        address(PathToAddress(pathAddr)),
-        options(COMM_NONBLOCKING)
+    AsyncJob("Ipc::UdsOp"),
+    address(PathToAddress(pathAddr)),
+    options(COMM_NONBLOCKING)
 {
     debugs(54, 5, HERE << '[' << this << "] pathAddr=" << pathAddr);
 }
@@ -77,12 +82,12 @@ Ipc::PathToAddress(const String& pathAddr) {
 CBDATA_NAMESPACED_CLASS_INIT(Ipc, UdsSender);
 
 Ipc::UdsSender::UdsSender(const String& pathAddr, const TypedMsgHdr& aMessage):
-        UdsOp(pathAddr),
-        message(aMessage),
-        retries(10), // TODO: make configurable?
-        timeout(10), // TODO: make configurable?
-        sleeping(false),
-        writing(false)
+    UdsOp(pathAddr),
+    message(aMessage),
+    retries(10), // TODO: make configurable?
+    timeout(10), // TODO: make configurable?
+    sleeping(false),
+    writing(false)
 {
     message.address(address);
 }
@@ -188,7 +193,7 @@ void Ipc::SendMessage(const String& toAddress, const TypedMsgHdr &message)
 const Comm::ConnectionPointer &
 Ipc::ImportFdIntoComm(const Comm::ConnectionPointer &conn, int socktype, int protocol, Ipc::FdNoteId noteId)
 {
-    struct sockaddr_in addr;
+    struct sockaddr_storage addr;
     socklen_t len = sizeof(addr);
     if (getsockname(conn->fd, reinterpret_cast<sockaddr*>(&addr), &len) == 0) {
         conn->remote = addr;
@@ -197,10 +202,12 @@ Ipc::ImportFdIntoComm(const Comm::ConnectionPointer &conn, int socktype, int pro
         addr_info->ai_socktype = socktype;
         addr_info->ai_protocol = protocol;
         comm_import_opened(conn, Ipc::FdNote(noteId), addr_info);
-        Ip::Address::FreeAddrInfo(addr_info);
+        Ip::Address::FreeAddr(addr_info);
     } else {
-        debugs(54, DBG_CRITICAL, "ERROR: Ipc::ImportFdIntoComm: " << conn << ' ' << xstrerror());
+        int xerrno = errno;
+        debugs(54, DBG_CRITICAL, "ERROR: Ipc::ImportFdIntoComm: " << conn << ' ' << xstrerr(xerrno));
         conn->close();
     }
     return conn;
 }
+