]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Port.cc
Bug #2583 fix: pure virtual method called
[thirdparty/squid.git] / src / ipc / Port.cc
1 /*
2 * $Id$
3 *
4 * DEBUG: section 54 Interprocess Communication
5 *
6 */
7
8
9 #include "config.h"
10 #include "CommCalls.h"
11 #include "ipc/Port.h"
12
13 const char Ipc::coordinatorAddr[] = DEFAULT_PREFIX "/var/run/coordinator.ipc";
14 const char Ipc::strandAddrPfx[] = DEFAULT_PREFIX "/var/run/squid";
15
16
17 Ipc::Port::Port(const String& aListenAddr):
18 UdsOp(aListenAddr)
19 {
20 setOptions(COMM_NONBLOCKING | COMM_DOBIND);
21 }
22
23 void Ipc::Port::start()
24 {
25 UdsOp::start();
26 listen();
27 }
28
29 void Ipc::Port::listen()
30 {
31 debugs(54, 6, HERE);
32 buf.prepForReading();
33 typedef CommCbMemFunT<Port, CommIoCbParams> Dialer;
34 AsyncCall::Pointer readHandler = JobCallback(54, 6,
35 Dialer, this, Port::noteRead);
36 comm_read(fd(), buf.raw(), buf.size(), readHandler);
37 }
38
39 bool Ipc::Port::doneAll() const
40 {
41 return false; // listen forever
42 }
43
44 String Ipc::Port::MakeAddr(const char* pathAddr, int id)
45 {
46 assert(id >= 0);
47 String addr = pathAddr;
48 addr.append('-');
49 addr.append(xitoa(id));
50 addr.append(".ipc");
51 return addr;
52 }
53
54 void Ipc::Port::noteRead(const CommIoCbParams& params)
55 {
56 debugs(54, 6, HERE << "FD " << params.fd << " flag " << params.flag <<
57 " [" << this << ']');
58 if (params.flag == COMM_OK) {
59 assert(params.buf == buf.raw());
60 receive(buf);
61 }
62 // TODO: if there was a fatal error on our socket, close the socket before
63 // trying to listen again and print a level-1 error message.
64
65 listen();
66 }