]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Don't generate OpenListenerParams unless needed.
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 21 Jan 2011 15:48:07 +0000 (04:48 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 21 Jan 2011 15:48:07 +0000 (04:48 +1300)
Removes a few minor data copies.

src/ipc/StartListening.cc

index 77fa86f778e6cdaa1b1cd8a330a2d531c12fee98..65fb6f0ac974b22e647a71e588ff8cdb033bc948 100644 (file)
@@ -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<StartListeningCb*>(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<StartListeningCb*>(callback->getDialer());
-    Must(cbd);
-    cbd->fd = sock;
-    cbd->errNo = errNo;
+    debugs(54, 3, HERE << "opened listen FD " << cbd->fd << " on " << addr);
     ScheduleCallHere(callback);
 }