]>
Commit | Line | Data |
---|---|---|
0d0bce6a AR |
1 | /* |
2 | * $Id$ | |
3 | * | |
4 | * DEBUG: section 54 Interprocess Communication | |
5 | * | |
6 | */ | |
7 | ||
8 | #include "config.h" | |
a67d2b2e | 9 | #include "base/TextException.h" |
e0d28505 | 10 | #include "comm.h" |
e0d28505 | 11 | #include "comm/Connection.h" |
0d0bce6a AR |
12 | #include "ipc/SharedListen.h" |
13 | #include "ipc/StartListening.h" | |
14 | ||
15 | ||
e0d28505 | 16 | Ipc::StartListeningCb::StartListeningCb(): conn(NULL), errNo(0) |
0d0bce6a AR |
17 | { |
18 | } | |
19 | ||
20 | Ipc::StartListeningCb::~StartListeningCb() | |
21 | { | |
22 | } | |
23 | ||
24 | std::ostream &Ipc::StartListeningCb::startPrint(std::ostream &os) const | |
25 | { | |
e0d28505 | 26 | return os << "(" << conn << ", err=" << errNo; |
0d0bce6a AR |
27 | } |
28 | ||
e0d28505 AJ |
29 | void |
30 | Ipc::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 | } |