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