]>
Commit | Line | Data |
---|---|---|
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 | |
21d845b1 FC |
14 | #if HAVE_ERRNO_H |
15 | #include <errno.h> | |
16 | #endif | |
17 | ||
e0d28505 | 18 | Ipc::StartListeningCb::StartListeningCb(): conn(NULL), errNo(0) |
0d0bce6a AR |
19 | { |
20 | } | |
21 | ||
22 | Ipc::StartListeningCb::~StartListeningCb() | |
23 | { | |
24 | } | |
25 | ||
26 | std::ostream &Ipc::StartListeningCb::startPrint(std::ostream &os) const | |
27 | { | |
e0d28505 | 28 | return os << "(" << conn << ", err=" << errNo; |
0d0bce6a AR |
29 | } |
30 | ||
e0d28505 AJ |
31 | void |
32 | Ipc::StartListening(int sock_type, int proto, const Comm::ConnectionPointer &listenConn, | |
f5e46c0a | 33 | FdNoteId fdNote, AsyncCall::Pointer &callback) |
0d0bce6a | 34 | { |
b72fb55d CT |
35 | StartListeningCb *cbd = dynamic_cast<StartListeningCb*>(callback->getDialer()); |
36 | Must(cbd); | |
37 | cbd->conn = listenConn; | |
38 | ||
67858492 | 39 | if (UsingSmp()) { // if SMP is on, share |
e0d28505 AJ |
40 | OpenListenerParams p; |
41 | p.sock_type = sock_type; | |
42 | p.proto = proto; | |
43 | p.addr = listenConn->local; | |
44 | p.flags = listenConn->flags; | |
45 | p.fdNote = fdNote; | |
0d0bce6a AR |
46 | Ipc::JoinSharedListen(p, callback); |
47 | return; // wait for the call back | |
48 | } | |
49 | ||
50 | enter_suid(); | |
8bbb16e3 AJ |
51 | comm_open_listener(sock_type, proto, cbd->conn, FdNote(fdNote)); |
52 | cbd->errNo = Comm::IsConnOpen(cbd->conn) ? 0 : errno; | |
0d0bce6a AR |
53 | leave_suid(); |
54 | ||
e0d28505 | 55 | debugs(54, 3, HERE << "opened listen " << cbd->conn); |
0d0bce6a AR |
56 | ScheduleCallHere(callback); |
57 | } |