]>
Commit | Line | Data |
---|---|---|
0d0bce6a | 1 | /* |
bf95c10a | 2 | * Copyright (C) 1996-2022 The Squid Software Foundation and contributors |
0d0bce6a | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
0d0bce6a AR |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 54 Interprocess Communication */ |
10 | ||
f7f3304a | 11 | #include "squid.h" |
a67d2b2e | 12 | #include "base/TextException.h" |
e0d28505 | 13 | #include "comm.h" |
e0d28505 | 14 | #include "comm/Connection.h" |
0d0bce6a AR |
15 | #include "ipc/SharedListen.h" |
16 | #include "ipc/StartListening.h" | |
561076e2 | 17 | #include "tools.h" |
0d0bce6a | 18 | |
1a30fdf5 | 19 | #include <cerrno> |
21d845b1 | 20 | |
aee3523a | 21 | Ipc::StartListeningCb::StartListeningCb(): conn(nullptr), errNo(0) |
0d0bce6a AR |
22 | { |
23 | } | |
24 | ||
25 | Ipc::StartListeningCb::~StartListeningCb() | |
26 | { | |
27 | } | |
28 | ||
29 | std::ostream &Ipc::StartListeningCb::startPrint(std::ostream &os) const | |
30 | { | |
e0d28505 | 31 | return os << "(" << conn << ", err=" << errNo; |
0d0bce6a AR |
32 | } |
33 | ||
e0d28505 AJ |
34 | void |
35 | Ipc::StartListening(int sock_type, int proto, const Comm::ConnectionPointer &listenConn, | |
f5e46c0a | 36 | FdNoteId fdNote, AsyncCall::Pointer &callback) |
0d0bce6a | 37 | { |
b72fb55d CT |
38 | StartListeningCb *cbd = dynamic_cast<StartListeningCb*>(callback->getDialer()); |
39 | Must(cbd); | |
40 | cbd->conn = listenConn; | |
41 | ||
7d17a6a6 EB |
42 | const auto giveEachWorkerItsOwnQueue = listenConn->flags & COMM_REUSEPORT; |
43 | if (!giveEachWorkerItsOwnQueue && UsingSmp()) { | |
44 | // Ask Coordinator for a listening socket. | |
45 | // All askers share one listening queue. | |
e0d28505 AJ |
46 | OpenListenerParams p; |
47 | p.sock_type = sock_type; | |
48 | p.proto = proto; | |
49 | p.addr = listenConn->local; | |
50 | p.flags = listenConn->flags; | |
51 | p.fdNote = fdNote; | |
0d0bce6a AR |
52 | Ipc::JoinSharedListen(p, callback); |
53 | return; // wait for the call back | |
54 | } | |
55 | ||
56 | enter_suid(); | |
8bbb16e3 AJ |
57 | comm_open_listener(sock_type, proto, cbd->conn, FdNote(fdNote)); |
58 | cbd->errNo = Comm::IsConnOpen(cbd->conn) ? 0 : errno; | |
0d0bce6a AR |
59 | leave_suid(); |
60 | ||
bf95c10a | 61 | debugs(54, 3, "opened listen " << cbd->conn); |
0d0bce6a AR |
62 | ScheduleCallHere(callback); |
63 | } | |
f53969cc | 64 |