From: Amos Jeffries Date: Fri, 21 Jan 2011 15:48:07 +0000 (+1300) Subject: Don't generate OpenListenerParams unless needed. X-Git-Tag: take03^2~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5e46c0afb442c27642627b17eb6239c8cea88b8;p=thirdparty%2Fsquid.git Don't generate OpenListenerParams unless needed. Removes a few minor data copies. --- diff --git a/src/ipc/StartListening.cc b/src/ipc/StartListening.cc index 77fa86f778..65fb6f0ac9 100644 --- a/src/ipc/StartListening.cc +++ b/src/ipc/StartListening.cc @@ -6,8 +6,8 @@ */ #include "config.h" -#include "comm.h" #include "base/TextException.h" +#include "comm.h" #include "ipc/SharedListen.h" #include "ipc/StartListening.h" @@ -25,34 +25,29 @@ std::ostream &Ipc::StartListeningCb::startPrint(std::ostream &os) const return os << "(FD " << fd << ", err=" << errNo; } - -void Ipc::StartListening(int sock_type, int proto, Ip::Address &addr, - int flags, FdNoteId fdNote, AsyncCall::Pointer &callback) +void +Ipc::StartListening(int sock_type, int proto, Ip::Address &addr, int flags, + FdNoteId fdNote, AsyncCall::Pointer &callback) { - OpenListenerParams p; - p.sock_type = sock_type; - p.proto = proto; - p.addr = addr; - p.flags = flags; - p.fdNote = fdNote; - - if (UsingSmp()) { // if SMP is on, share + if (UsingSmp()) { // if SMP is on, share + OpenListenerParams p; + p.sock_type = sock_type; + p.proto = proto; + p.addr = addr; + p.flags = flags; + p.fdNote = fdNote; Ipc::JoinSharedListen(p, callback); return; // wait for the call back } + StartListeningCb *cbd = dynamic_cast(callback->getDialer()); + Must(cbd); + enter_suid(); - const int sock = comm_open_listener(p.sock_type, p.proto, p.addr, p.flags, - FdNote(p.fdNote)); - const int errNo = (sock >= 0) ? 0 : errno; + cbd->fd = comm_open_listener(sock_type, proto, addr, flags, FdNote(fdNote)); + cbd->errNo = cbd->fd >= 0 ? 0 : errno; leave_suid(); - debugs(54, 3, HERE << "opened listen FD " << sock << " for " << p.addr); - - StartListeningCb *cbd = - dynamic_cast(callback->getDialer()); - Must(cbd); - cbd->fd = sock; - cbd->errNo = errNo; + debugs(54, 3, HERE << "opened listen FD " << cbd->fd << " on " << addr); ScheduleCallHere(callback); }