------------------------------------------------------------ revno: 13248 revision-id: squid3@treenet.co.nz-20140127052741-amned6pcglxzq6p7 parent: squid3@treenet.co.nz-20140127030615-4rqcfxecjz05pp2b fixes bug(s): http://bugs.squid-cache.org/show_bug.cgi?id=3608 committer: Amos Jeffries branch nick: trunk timestamp: Sun 2014-01-26 22:27:41 -0700 message: Bug 3608: part 1 - per-service name for workers UDS sockets Separate the UDS socket names used by SMP workers by the -n service_name label assigned to the Squid instance being run. TODO: separate shared memory blocks per-service. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140127052741-amned6pcglxzq6p7 # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 59af73c700f063d36a179596fc103cd09fd10975 # timestamp: 2014-01-27 05:30:23 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140127030615-\ # 4rqcfxecjz05pp2b # # Begin patch === modified file 'src/CollapsedForwarding.cc' --- src/CollapsedForwarding.cc 2014-01-10 19:01:04 +0000 +++ src/CollapsedForwarding.cc 2014-01-27 05:27:41 +0000 @@ -87,7 +87,7 @@ Ipc::TypedMsgHdr msg; msg.setType(Ipc::mtCollapsedForwardingNotification); msg.putInt(KidIdentifier); - const String addr = Ipc::Port::MakeAddr(Ipc::strandAddrPfx, workerId); + const String addr = Ipc::Port::MakeAddr(Ipc::strandAddrLabel, workerId); Ipc::SendMessage(addr, msg); } === modified file 'src/DiskIO/IpcIo/IpcIoFile.cc' --- src/DiskIO/IpcIo/IpcIoFile.cc 2013-12-31 18:49:41 +0000 +++ src/DiskIO/IpcIo/IpcIoFile.cc 2014-01-27 05:27:41 +0000 @@ -114,7 +114,7 @@ ann.strand.tag = dbName; Ipc::TypedMsgHdr message; ann.pack(message); - SendMessage(Ipc::coordinatorAddr, message); + SendMessage(Ipc::Port::CoordinatorAddr(), message); ioRequestor->ioCompletedNotification(); return; @@ -126,7 +126,7 @@ Ipc::TypedMsgHdr msg; request.pack(msg); - Ipc::SendMessage(Ipc::coordinatorAddr, msg); + Ipc::SendMessage(Ipc::Port::CoordinatorAddr(), msg); WaitingForOpen.push_back(this); @@ -460,7 +460,7 @@ Ipc::TypedMsgHdr msg; msg.setType(Ipc::mtIpcIoNotification); // TODO: add proper message type? msg.putInt(KidIdentifier); - const String addr = Ipc::Port::MakeAddr(Ipc::strandAddrPfx, peerId); + const String addr = Ipc::Port::MakeAddr(Ipc::strandAddrLabel, peerId); Ipc::SendMessage(addr, msg); } === modified file 'src/ipc/Coordinator.cc' --- src/ipc/Coordinator.cc 2013-01-21 07:15:09 +0000 +++ src/ipc/Coordinator.cc 2014-01-27 05:27:41 +0000 @@ -28,7 +28,7 @@ Ipc::Coordinator* Ipc::Coordinator::TheInstance = NULL; Ipc::Coordinator::Coordinator(): - Port(coordinatorAddr) + Port(Ipc::Port::CoordinatorAddr()) { } @@ -136,7 +136,7 @@ // send back an acknowledgement; TODO: remove as not needed? TypedMsgHdr message; msg.pack(message); - SendMessage(MakeAddr(strandAddrPfx, msg.strand.kidId), message); + SendMessage(MakeAddr(strandAddrLabel, msg.strand.kidId), message); } void @@ -156,7 +156,7 @@ SharedListenResponse response(c->fd, errNo, request.mapId); TypedMsgHdr message; response.pack(message); - SendMessage(MakeAddr(strandAddrPfx, request.requestorId), message); + SendMessage(MakeAddr(strandAddrLabel, request.requestorId), message); } void @@ -181,7 +181,7 @@ Mgr::Response response(request.requestId); TypedMsgHdr message; response.pack(message); - SendMessage(MakeAddr(strandAddrPfx, request.requestorId), message); + SendMessage(MakeAddr(strandAddrLabel, request.requestorId), message); } @@ -221,7 +221,7 @@ const StrandSearchResponse response(strand); TypedMsgHdr message; response.pack(message); - SendMessage(MakeAddr(strandAddrPfx, request.requestorId), message); + SendMessage(MakeAddr(strandAddrLabel, request.requestorId), message); } #if SQUID_SNMP @@ -233,7 +233,7 @@ Snmp::Response response(request.requestId); TypedMsgHdr message; response.pack(message); - SendMessage(MakeAddr(strandAddrPfx, request.requestorId), message); + SendMessage(MakeAddr(strandAddrLabel, request.requestorId), message); AsyncJob::Start(new Snmp::Inquirer(request, strands_)); } === modified file 'src/ipc/Forwarder.cc' --- src/ipc/Forwarder.cc 2012-09-01 14:38:36 +0000 +++ src/ipc/Forwarder.cc 2014-01-27 05:27:41 +0000 @@ -59,7 +59,7 @@ handleError(); } - SendMessage(coordinatorAddr, message); + SendMessage(Ipc::Port::CoordinatorAddr(), message); eventAdd("Ipc::Forwarder::requestTimedOut", &Forwarder::RequestTimedOut, this, timeout, 0, false); } === modified file 'src/ipc/Inquirer.cc' --- src/ipc/Inquirer.cc 2012-09-01 14:38:36 +0000 +++ src/ipc/Inquirer.cc 2014-01-27 05:27:41 +0000 @@ -72,7 +72,7 @@ TheRequestsMap[request->requestId] = callback; TypedMsgHdr message; request->pack(message); - SendMessage(Port::MakeAddr(strandAddrPfx, kidId), message); + SendMessage(Port::MakeAddr(strandAddrLabel, kidId), message); eventAdd("Ipc::Inquirer::requestTimedOut", &Inquirer::RequestTimedOut, this, timeout, 0, false); } === modified file 'src/ipc/Port.cc' --- src/ipc/Port.cc 2013-10-25 00:13:46 +0000 +++ src/ipc/Port.cc 2014-01-27 05:27:41 +0000 @@ -7,10 +7,12 @@ #include "comm.h" #include "comm/Connection.h" #include "CommCalls.h" +#include "globals.h" #include "ipc/Port.h" -const char Ipc::coordinatorAddr[] = DEFAULT_STATEDIR "/coordinator.ipc"; -const char Ipc::strandAddrPfx[] = DEFAULT_STATEDIR "/kid"; +static const char channelPathPfx[] = DEFAULT_STATEDIR "/"; +static const char coordinatorAddrLabel[] = "-coordinator"; +const char Ipc::strandAddrLabel[] = "-kid"; Ipc::Port::Port(const String& aListenAddr): UdsOp(aListenAddr) @@ -39,16 +41,31 @@ return false; // listen forever } -String Ipc::Port::MakeAddr(const char* pathAddr, int id) +String Ipc::Port::MakeAddr(const char* processLabel, int id) { assert(id >= 0); - String addr = pathAddr; + String addr = channelPathPfx; + addr.append(service_name); + addr.append(processLabel); addr.append('-'); addr.append(xitoa(id)); addr.append(".ipc"); return addr; } +String +Ipc::Port::CoordinatorAddr() +{ + static String coordinatorAddr; + if (!coordinatorAddr.size()) { + coordinatorAddr= channelPathPfx; + coordinatorAddr.append(service_name); + coordinatorAddr.append(coordinatorAddrLabel); + coordinatorAddr.append(".ipc"); + } + return coordinatorAddr; +} + void Ipc::Port::noteRead(const CommIoCbParams& params) { debugs(54, 6, HERE << params.conn << " flag " << params.flag << === modified file 'src/ipc/Port.h' --- src/ipc/Port.h 2013-10-25 00:13:46 +0000 +++ src/ipc/Port.h 2014-01-27 05:27:41 +0000 @@ -17,8 +17,11 @@ { public: Port(const String &aListenAddr); - /// calculates IPC message address for strand #id at path - static String MakeAddr(const char *path, int id); + /// calculates IPC message address for strand #id of processLabel type + static String MakeAddr(const char *proccessLabel, int id); + + /// get the IPC message address for coordinator process + static String CoordinatorAddr(); protected: virtual void start() = 0; // UdsOp (AsyncJob) API; has body @@ -37,8 +40,7 @@ TypedMsgHdr buf; ///< msghdr struct filled by Comm }; -extern const char coordinatorAddr[]; ///< where coordinator listens -extern const char strandAddrPfx[]; ///< strand's listening address prefix +extern const char strandAddrLabel[]; ///< strand's listening address unique label } // namespace Ipc === modified file 'src/ipc/SharedListen.cc' --- src/ipc/SharedListen.cc 2013-10-25 00:13:46 +0000 +++ src/ipc/SharedListen.cc 2014-01-27 05:27:41 +0000 @@ -117,7 +117,7 @@ TypedMsgHdr message; request.pack(message); - SendMessage(coordinatorAddr, message); + SendMessage(Ipc::Port::CoordinatorAddr(), message); } void Ipc::SharedListenJoined(const SharedListenResponse &response) === modified file 'src/ipc/Strand.cc' --- src/ipc/Strand.cc 2013-12-06 23:52:26 +0000 +++ src/ipc/Strand.cc 2014-01-27 05:27:41 +0000 @@ -32,7 +32,7 @@ CBDATA_NAMESPACED_CLASS_INIT(Ipc, Strand); Ipc::Strand::Strand(): - Port(MakeAddr(strandAddrPfx, KidIdentifier)), + Port(MakeAddr(strandAddrLabel, KidIdentifier)), isRegistered(false) { } @@ -51,7 +51,7 @@ HereIamMessage ann(StrandCoord(KidIdentifier, getpid())); TypedMsgHdr message; ann.pack(message); - SendMessage(coordinatorAddr, message); + SendMessage(Port::CoordinatorAddr(), message); setTimeout(6, "Ipc::Strand::timeoutHandler"); // TODO: make 6 configurable? } === modified file 'src/mgr/Action.cc' --- src/mgr/Action.cc 2014-01-20 01:11:58 +0000 +++ src/mgr/Action.cc 2014-01-27 05:27:41 +0000 @@ -79,7 +79,7 @@ Response response(requestId, this); Ipc::TypedMsgHdr message; response.pack(message); - Ipc::SendMessage(Ipc::coordinatorAddr, message); + Ipc::SendMessage(Ipc::Port::CoordinatorAddr(), message); } void === modified file 'src/snmp/Forwarder.cc' --- src/snmp/Forwarder.cc 2013-10-25 00:13:46 +0000 +++ src/snmp/Forwarder.cc 2014-01-27 05:27:41 +0000 @@ -101,5 +101,5 @@ } Ipc::TypedMsgHdr message; response.pack(message); - Ipc::SendMessage(Ipc::coordinatorAddr, message); + Ipc::SendMessage(Ipc::Port::CoordinatorAddr(), message); } === modified file 'src/tests/stub_Port.cc' --- src/tests/stub_Port.cc 2012-01-20 18:55:04 +0000 +++ src/tests/stub_Port.cc 2014-01-27 05:27:41 +0000 @@ -4,7 +4,7 @@ #define STUB_API "ipc/Port.cc" #include "tests/STUB.h" -const char Ipc::coordinatorAddr[] = ""; -const char Ipc::strandAddrPfx[] = ""; +const char Ipc::strandAddrLabel[] = "-kid"; String Ipc::Port::MakeAddr(char const*, int) STUB_RETVAL("") +String Ipc::Port::CoordinatorAddr() STUB_RETVAL("")