]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Port.cc
2 * DEBUG: section 54 Interprocess Communication
8 #include "comm/Connection.h"
13 static const char channelPathPfx
[] = DEFAULT_STATEDIR
"/";
14 static const char coordinatorAddrLabel
[] = "-coordinator";
15 const char Ipc::strandAddrLabel
[] = "-kid";
17 Ipc::Port::Port(const String
& aListenAddr
):
20 setOptions(COMM_NONBLOCKING
| COMM_DOBIND
);
23 void Ipc::Port::start()
29 void Ipc::Port::doListen()
33 typedef CommCbMemFunT
<Port
, CommIoCbParams
> Dialer
;
34 AsyncCall::Pointer readHandler
= JobCallback(54, 6,
35 Dialer
, this, Port::noteRead
);
36 comm_read(conn(), buf
.raw(), buf
.size(), readHandler
);
39 bool Ipc::Port::doneAll() const
41 return false; // listen forever
44 String
Ipc::Port::MakeAddr(const char* processLabel
, int id
)
47 String addr
= channelPathPfx
;
48 addr
.append(service_name
);
49 addr
.append(processLabel
);
51 addr
.append(xitoa(id
));
57 Ipc::Port::CoordinatorAddr()
59 static String coordinatorAddr
;
60 if (!coordinatorAddr
.size()) {
61 coordinatorAddr
= channelPathPfx
;
62 coordinatorAddr
.append(service_name
);
63 coordinatorAddr
.append(coordinatorAddrLabel
);
64 coordinatorAddr
.append(".ipc");
66 return coordinatorAddr
;
69 void Ipc::Port::noteRead(const CommIoCbParams
& params
)
71 debugs(54, 6, HERE
<< params
.conn
<< " flag " << params
.flag
<<
73 if (params
.flag
== COMM_OK
) {
74 assert(params
.buf
== buf
.raw());
77 // TODO: if there was a fatal error on our socket, close the socket before
78 // trying to listen again and print a level-1 error message.