]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ipc/StartListening.cc
Applied source formatting rules in preparation for trunk merge.
[thirdparty/squid.git] / src / ipc / StartListening.cc
CommitLineData
0d0bce6a
AR
1/*
2 * $Id$
3 *
4 * DEBUG: section 54 Interprocess Communication
5 *
6 */
7
8#include "config.h"
9#include "comm.h"
10#include "TextException.h"
11#include "ipc/SharedListen.h"
12#include "ipc/StartListening.h"
13
14
15Ipc::StartListeningCb::StartListeningCb(): fd(-1), errNo(0)
16{
17}
18
19Ipc::StartListeningCb::~StartListeningCb()
20{
21}
22
23std::ostream &Ipc::StartListeningCb::startPrint(std::ostream &os) const
24{
25 return os << "(FD " << fd << ", err=" << errNo;
26}
27
28
29void Ipc::StartListening(int sock_type, int proto, IpAddress &addr,
5667a628 30 int flags, FdNoteId fdNote, AsyncCall::Pointer &callback)
0d0bce6a
AR
31{
32 OpenListenerParams p;
33 p.sock_type = sock_type;
34 p.proto = proto;
35 p.addr = addr;
36 p.flags = flags;
37 p.fdNote = fdNote;
38
67858492 39 if (UsingSmp()) { // if SMP is on, share
0d0bce6a
AR
40 Ipc::JoinSharedListen(p, callback);
41 return; // wait for the call back
42 }
43
44 enter_suid();
45 const int sock = comm_open_listener(p.sock_type, p.proto, p.addr, p.flags,
5667a628 46 FdNote(p.fdNote));
0d0bce6a
AR
47 const int errNo = (sock >= 0) ? 0 : errno;
48 leave_suid();
49
50 debugs(54, 3, HERE << "opened listen FD " << sock << " for " << p.addr);
51
52 StartListeningCb *cbd =
53 dynamic_cast<StartListeningCb*>(callback->getDialer());
54 Must(cbd);
55 cbd->fd = sock;
56 cbd->errNo = errNo;
57 ScheduleCallHere(callback);
58}