]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Port.cc
2 * DEBUG: section 54 Interprocess Communication
8 #include "comm/Connection.h"
10 #include "CommCalls.h"
14 static const char channelPathPfx
[] = DEFAULT_STATEDIR
"/";
15 static const char coordinatorAddrLabel
[] = "-coordinator";
16 const char Ipc::strandAddrLabel
[] = "-kid";
18 Ipc::Port::Port(const String
& aListenAddr
):
21 setOptions(COMM_NONBLOCKING
| COMM_DOBIND
);
24 void Ipc::Port::start()
30 void Ipc::Port::doListen()
34 typedef CommCbMemFunT
<Port
, CommIoCbParams
> Dialer
;
35 AsyncCall::Pointer readHandler
= JobCallback(54, 6,
36 Dialer
, this, Port::noteRead
);
37 comm_read(conn(), buf
.raw(), buf
.size(), readHandler
);
40 bool Ipc::Port::doneAll() const
42 return false; // listen forever
45 String
Ipc::Port::MakeAddr(const char* processLabel
, int id
)
48 String addr
= channelPathPfx
;
49 addr
.append(service_name
);
50 addr
.append(processLabel
);
52 addr
.append(xitoa(id
));
58 Ipc::Port::CoordinatorAddr()
60 static String coordinatorAddr
;
61 if (!coordinatorAddr
.size()) {
62 coordinatorAddr
= channelPathPfx
;
63 coordinatorAddr
.append(service_name
);
64 coordinatorAddr
.append(coordinatorAddrLabel
);
65 coordinatorAddr
.append(".ipc");
67 return coordinatorAddr
;
70 void Ipc::Port::noteRead(const CommIoCbParams
& params
)
72 debugs(54, 6, HERE
<< params
.conn
<< " flag " << params
.flag
<<
74 if (params
.flag
== Comm::OK
) {
75 assert(params
.buf
== buf
.raw());
78 // TODO: if there was a fatal error on our socket, close the socket before
79 // trying to listen again and print a level-1 error message.