/*
- * 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"
#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);
}
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);
}
{
debugs(54, 5, HERE << params.conn << " flag " << params.flag << " retries " << retries << " [" << this << ']');
writing = false;
- if (params.flag != COMM_OK && retries-- > 0) {
+ if (params.flag != Comm::OK && retries-- > 0) {
// perhaps a fresh connection and more time will help?
conn()->close();
- sleep();
+ startSleep();
}
}
/// pause for a while before resending the message
-void Ipc::UdsSender::sleep()
+void Ipc::UdsSender::startSleep()
{
Must(!sleeping);
sleeping = true;
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;
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;
}
+