]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Port.cc
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 54 Interprocess Communication */
13 #include "comm/Connection.h"
14 #include "comm/Read.h"
15 #include "CommCalls.h"
20 static const char channelPathPfx
[] = DEFAULT_STATEDIR
"/";
21 static const char coordinatorAddrLabel
[] = "-coordinator";
22 const char Ipc::strandAddrLabel
[] = "-kid";
24 Ipc::Port::Port(const String
& aListenAddr
):
27 setOptions(COMM_NONBLOCKING
| COMM_DOBIND
);
30 void Ipc::Port::start()
36 void Ipc::Port::doListen()
40 typedef CommCbMemFunT
<Port
, CommIoCbParams
> Dialer
;
41 AsyncCall::Pointer readHandler
= JobCallback(54, 6,
42 Dialer
, this, Port::noteRead
);
43 comm_read(conn(), buf
.raw(), buf
.size(), readHandler
);
46 bool Ipc::Port::doneAll() const
48 return false; // listen forever
51 String
Ipc::Port::MakeAddr(const char* processLabel
, int id
)
54 String addr
= channelPathPfx
;
55 addr
.append(service_name
.c_str());
56 addr
.append(processLabel
);
58 addr
.append(xitoa(id
));
64 Ipc::Port::CoordinatorAddr()
66 static String coordinatorAddr
;
67 if (!coordinatorAddr
.size()) {
68 coordinatorAddr
= channelPathPfx
;
69 coordinatorAddr
.append(service_name
.c_str());
70 coordinatorAddr
.append(coordinatorAddrLabel
);
71 coordinatorAddr
.append(".ipc");
73 return coordinatorAddr
;
76 void Ipc::Port::noteRead(const CommIoCbParams
& params
)
78 debugs(54, 6, HERE
<< params
.conn
<< " flag " << params
.flag
<<
80 if (params
.flag
== Comm::OK
) {
81 assert(params
.buf
== buf
.raw());
84 // TODO: if there was a fatal error on our socket, close the socket before
85 // trying to listen again and print a level-1 error message.