]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ipc/StartListening.cc
Boilerplate: update copyright blurbs on Squid helpers
[thirdparty/squid.git] / src / ipc / StartListening.cc
CommitLineData
0d0bce6a 1/*
0d0bce6a
AR
2 * DEBUG: section 54 Interprocess Communication
3 *
4 */
5
f7f3304a 6#include "squid.h"
a67d2b2e 7#include "base/TextException.h"
e0d28505 8#include "comm.h"
e0d28505 9#include "comm/Connection.h"
0d0bce6a
AR
10#include "ipc/SharedListen.h"
11#include "ipc/StartListening.h"
561076e2 12#include "tools.h"
0d0bce6a 13
1a30fdf5 14#include <cerrno>
21d845b1 15
e0d28505 16Ipc::StartListeningCb::StartListeningCb(): conn(NULL), errNo(0)
0d0bce6a
AR
17{
18}
19
20Ipc::StartListeningCb::~StartListeningCb()
21{
22}
23
24std::ostream &Ipc::StartListeningCb::startPrint(std::ostream &os) const
25{
e0d28505 26 return os << "(" << conn << ", err=" << errNo;
0d0bce6a
AR
27}
28
e0d28505
AJ
29void
30Ipc::StartListening(int sock_type, int proto, const Comm::ConnectionPointer &listenConn,
f5e46c0a 31 FdNoteId fdNote, AsyncCall::Pointer &callback)
0d0bce6a 32{
b72fb55d
CT
33 StartListeningCb *cbd = dynamic_cast<StartListeningCb*>(callback->getDialer());
34 Must(cbd);
35 cbd->conn = listenConn;
36
67858492 37 if (UsingSmp()) { // if SMP is on, share
e0d28505
AJ
38 OpenListenerParams p;
39 p.sock_type = sock_type;
40 p.proto = proto;
41 p.addr = listenConn->local;
42 p.flags = listenConn->flags;
43 p.fdNote = fdNote;
0d0bce6a
AR
44 Ipc::JoinSharedListen(p, callback);
45 return; // wait for the call back
46 }
47
48 enter_suid();
8bbb16e3
AJ
49 comm_open_listener(sock_type, proto, cbd->conn, FdNote(fdNote));
50 cbd->errNo = Comm::IsConnOpen(cbd->conn) ? 0 : errno;
0d0bce6a
AR
51 leave_suid();
52
e0d28505 53 debugs(54, 3, HERE << "opened listen " << cbd->conn);
0d0bce6a
AR
54 ScheduleCallHere(callback);
55}