From: Alex Rousskov Date: Tue, 6 Jul 2010 18:58:38 +0000 (-0600) Subject: Applied source formatting rules in preparation for trunk merge. X-Git-Tag: SQUID_3_2_0_1~93^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5667a628128f3a5bb5e2238f9364bbbae4e0410d;p=thirdparty%2Fsquid.git Applied source formatting rules in preparation for trunk merge. --- diff --git a/src/client_side.cc b/src/client_side.cc index 33ed26e62f..228c6fb7cf 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -120,10 +120,12 @@ class ListeningStartedDialer: public CallDialer, public Ipc::StartListeningCb public: typedef void (*Handler)(int fd, int errNo, http_port_list *portCfg); ListeningStartedDialer(Handler aHandler, http_port_list *aPortCfg): - handler(aHandler), portCfg(aPortCfg) {} + handler(aHandler), portCfg(aPortCfg) {} - virtual void print(std::ostream &os) const { startPrint(os) << - ", port=" << (void*)portCfg << ')'; } + virtual void print(std::ostream &os) const { + startPrint(os) << + ", port=" << (void*)portCfg << ')'; + } virtual bool canDial(AsyncCall &) const { return true; } virtual void dial(AsyncCall &) { (handler)(fd, errNo, portCfg); } @@ -3414,13 +3416,13 @@ clientHttpConnectionsOpen(void) /* AYJ: 2009-12-27: bit bumpy. new ListenStateData(...) should be doing all the Comm:: stuff ... */ const int openFlags = COMM_NONBLOCKING | - (s->spoof_client_ip ? COMM_TRANSPARENT : 0); + (s->spoof_client_ip ? COMM_TRANSPARENT : 0); AsyncCall::Pointer callback = asyncCall(33,2, - "clientHttpConnectionOpened", - ListeningStartedDialer(&clientHttpConnectionOpened, s)); + "clientHttpConnectionOpened", + ListeningStartedDialer(&clientHttpConnectionOpened, s)); Ipc::StartListening(SOCK_STREAM, IPPROTO_TCP, s->s, openFlags, - Ipc::fdnHttpSocket, callback); + Ipc::fdnHttpSocket, callback); HttpSockets[NHttpSockets++] = -1; // set in clientHttpConnectionOpened } @@ -3442,18 +3444,18 @@ clientHttpConnectionOpened(int fd, int, http_port_list *s) Must(s); - AsyncCall::Pointer call = commCbCall(5,5, "SomeCommAcceptHandler(httpAccept)", - CommAcceptCbPtrFun(httpAccept, s)); + AsyncCall::Pointer call = commCbCall(5,5, "SomeCommAcceptHandler(httpAccept)", + CommAcceptCbPtrFun(httpAccept, s)); - s->listener = new Comm::ListenStateData(fd, call, true); + s->listener = new Comm::ListenStateData(fd, call, true); - debugs(1, 1, "Accepting " << - (s->intercepted ? " intercepted" : "") << - (s->spoof_client_ip ? " spoofing" : "") << - (s->sslBump ? " bumpy" : "") << - (s->accel ? " accelerated" : "") - << " HTTP connections at " << s->s - << ", FD " << fd << "." ); + debugs(1, 1, "Accepting " << + (s->intercepted ? " intercepted" : "") << + (s->spoof_client_ip ? " spoofing" : "") << + (s->sslBump ? " bumpy" : "") << + (s->accel ? " accelerated" : "") + << " HTTP connections at " << s->s + << ", FD " << fd << "." ); Must(AddOpenedHttpSocket(fd)); // otherwise, we have received a fd we did not ask for } @@ -3478,10 +3480,10 @@ clientHttpsConnectionsOpen(void) } AsyncCall::Pointer call = asyncCall(33, 2, "clientHttpsConnectionOpened", - ListeningStartedDialer(&clientHttpsConnectionOpened, &s->http)); + ListeningStartedDialer(&clientHttpsConnectionOpened, &s->http)); Ipc::StartListening(SOCK_STREAM, IPPROTO_TCP, s->http.s, COMM_NONBLOCKING, - Ipc::fdnHttpsSocket, call); + Ipc::fdnHttpsSocket, call); HttpSockets[NHttpSockets++] = -1; } @@ -3496,12 +3498,12 @@ clientHttpsConnectionOpened(int fd, int, http_port_list *s) Must(s); - AsyncCall::Pointer call = commCbCall(5,5, "SomeCommAcceptHandler(httpsAccept)", - CommAcceptCbPtrFun(httpsAccept, s)); + AsyncCall::Pointer call = commCbCall(5,5, "SomeCommAcceptHandler(httpsAccept)", + CommAcceptCbPtrFun(httpsAccept, s)); - s->listener = new Comm::ListenStateData(fd, call, true); + s->listener = new Comm::ListenStateData(fd, call, true); - debugs(1, 1, "Accepting HTTPS connections at " << s->s << ", FD " << fd << "."); + debugs(1, 1, "Accepting HTTPS connections at " << s->s << ", FD " << fd << "."); Must(AddOpenedHttpSocket(fd)); // otherwise, we have received a fd we did not ask for } diff --git a/src/comm.cc b/src/comm.cc index 06ba71adf8..475d167bf6 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -757,10 +757,10 @@ comm_openex(int sock_type, /// update FD tables after a local or remote (IPC) comm_openex(); void comm_init_opened(int new_socket, - IpAddress &addr, - unsigned char TOS, - const char *note, - struct addrinfo *AI) + IpAddress &addr, + unsigned char TOS, + const char *note, + struct addrinfo *AI) { assert(new_socket >= 0); assert(AI); @@ -790,9 +790,9 @@ comm_init_opened(int new_socket, /// returns new_socket or -1 on error static int comm_apply_flags(int new_socket, - IpAddress &addr, - int flags, - struct addrinfo *AI) + IpAddress &addr, + int flags, + struct addrinfo *AI) { assert(new_socket >= 0); assert(AI); @@ -851,10 +851,10 @@ comm_apply_flags(int new_socket, void comm_import_opened(int fd, - IpAddress &addr, - int flags, - const char *note, - struct addrinfo *AI) + IpAddress &addr, + int flags, + const char *note, + struct addrinfo *AI) { debugs(5, 2, HERE << " FD " << fd << " at " << addr); assert(fd >= 0); diff --git a/src/debug.cc b/src/debug.cc index edcaf70120..1e60987ca4 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -550,10 +550,10 @@ static const char * debugLogKid(void) { if (KidIdentifier != 0) { - static char buf[16]; + static char buf[16]; if (!*buf) // optimization: fill only once after KidIdentifier is set snprintf(buf, sizeof(buf), " kid%d", KidIdentifier); - return buf; + return buf; } return ""; diff --git a/src/htcp.cc b/src/htcp.cc index ab76d6678d..2e261aa295 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -50,7 +50,7 @@ /// dials htcpIncomingConnectionOpened call class HtcpListeningStartedDialer: public CallDialer, - public Ipc::StartListeningCb + public Ipc::StartListeningCb { public: typedef void (*Handler)(int fd, int errNo); @@ -1504,14 +1504,14 @@ htcpInit(void) incomingAddr.SetPort(Config.Port.htcp); AsyncCall::Pointer call = asyncCall(31, 2, - "htcpIncomingConnectionOpened", - HtcpListeningStartedDialer(&htcpIncomingConnectionOpened)); + "htcpIncomingConnectionOpened", + HtcpListeningStartedDialer(&htcpIncomingConnectionOpened)); Ipc::StartListening(SOCK_DGRAM, - IPPROTO_UDP, - incomingAddr, - COMM_NONBLOCKING, - Ipc::fdnInHtcpSocket, call); + IPPROTO_UDP, + incomingAddr, + COMM_NONBLOCKING, + Ipc::fdnInHtcpSocket, call); if (!Config.Addrs.udp_outgoing.IsNoAddr()) { IpAddress outgoingAddr = Config.Addrs.udp_outgoing; diff --git a/src/icp_v2.cc b/src/icp_v2.cc index fbd600b20e..67bd978882 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -53,15 +53,17 @@ /// dials icpIncomingConnectionOpened call class IcpListeningStartedDialer: public CallDialer, - public Ipc::StartListeningCb + public Ipc::StartListeningCb { public: typedef void (*Handler)(int fd, int errNo, IpAddress& addr); IcpListeningStartedDialer(Handler aHandler, IpAddress& anAddr): - handler(aHandler), addr(anAddr) {} + handler(aHandler), addr(anAddr) {} - virtual void print(std::ostream &os) const { startPrint(os) << - ", address=" << addr << ')'; } + virtual void print(std::ostream &os) const { + startPrint(os) << + ", address=" << addr << ')'; + } virtual bool canDial(AsyncCall &) const { return true; } virtual void dial(AsyncCall &) { (handler)(fd, errNo, addr); } @@ -687,14 +689,14 @@ icpConnectionsOpen(void) addr.SetPort(port); AsyncCall::Pointer call = asyncCall(12, 2, - "icpIncomingConnectionOpened", - IcpListeningStartedDialer(&icpIncomingConnectionOpened, addr)); + "icpIncomingConnectionOpened", + IcpListeningStartedDialer(&icpIncomingConnectionOpened, addr)); Ipc::StartListening(SOCK_DGRAM, - IPPROTO_UDP, - addr, - COMM_NONBLOCKING, - Ipc::fdnInIcpSocket, call); + IPPROTO_UDP, + addr, + COMM_NONBLOCKING, + Ipc::fdnInIcpSocket, call); addr.SetEmpty(); // clear for next use. addr = Config.Addrs.udp_outgoing; @@ -755,7 +757,7 @@ icpIncomingConnectionOpened(int fd, int errNo, IpAddress& addr) debugs(12, 1, "Accepting ICP messages at " << addr << ", FD " << theInIcpConnection << "."); - fd_note(theInIcpConnection, "Incoming ICP socket"); + fd_note(theInIcpConnection, "Incoming ICP socket"); if (Config.Addrs.udp_outgoing.IsNoAddr()) theOutIcpConnection = theInIcpConnection; diff --git a/src/ipc/Coordinator.cc b/src/ipc/Coordinator.cc index 47ecf7ccfd..a714330e31 100644 --- a/src/ipc/Coordinator.cc +++ b/src/ipc/Coordinator.cc @@ -18,7 +18,7 @@ Ipc::Coordinator* Ipc::Coordinator::TheInstance = NULL; Ipc::Coordinator::Coordinator(): - Port(coordinatorAddr) + Port(coordinatorAddr) { } @@ -78,15 +78,15 @@ void Ipc::Coordinator::handleSharedListenRequest(const SharedListenRequest& request) { debugs(54, 4, HERE << "kid" << request.requestorId << - " needs shared listen FD for " << request.params.addr); + " needs shared listen FD for " << request.params.addr); Listeners::const_iterator i = listeners.find(request.params); int errNo = 0; const int sock = (i != listeners.end()) ? - i->second : openListenSocket(request, errNo); + i->second : openListenSocket(request, errNo); debugs(54, 3, HERE << "sending shared listen FD " << sock << " for " << - request.params.addr << " to kid" << request.requestorId << - " mapId=" << request.mapId); + request.params.addr << " to kid" << request.requestorId << + " mapId=" << request.mapId); SharedListenResponse response(sock, errNo, request.mapId); TypedMsgHdr message; @@ -96,18 +96,18 @@ Ipc::Coordinator::handleSharedListenRequest(const SharedListenRequest& request) int Ipc::Coordinator::openListenSocket(const SharedListenRequest& request, - int &errNo) + int &errNo) { const OpenListenerParams &p = request.params; debugs(54, 6, HERE << "opening listen FD at " << p.addr << " for kid" << - request.requestorId); + request.requestorId); IpAddress addr = p.addr; // comm_open_listener may modify it enter_suid(); const int sock = comm_open_listener(p.sock_type, p.proto, addr, p.flags, - FdNote(p.fdNote)); + FdNote(p.fdNote)); errNo = (sock >= 0) ? 0 : errno; leave_suid(); @@ -123,7 +123,7 @@ void Ipc::Coordinator::broadcastSignal(int sig) const typedef Strands::const_iterator SCI; for (SCI iter = strands.begin(); iter != strands.end(); ++iter) { debugs(54, 5, HERE << "signal " << sig << " to kid" << iter->kidId << - ", PID=" << iter->pid); + ", PID=" << iter->pid); kill(iter->pid, sig); } } diff --git a/src/ipc/FdNotes.h b/src/ipc/FdNotes.h index 87219d09bc..91409d0e72 100644 --- a/src/ipc/FdNotes.h +++ b/src/ipc/FdNotes.h @@ -15,8 +15,9 @@ namespace Ipc /// fd_note() label ID typedef enum { fdnNone, fdnHttpSocket, fdnHttpsSocket, - fdnInSnmpSocket, fdnOutSnmpSocket, - fdnInIcpSocket, fdnInHtcpSocket, fdnEnd } FdNoteId; + fdnInSnmpSocket, fdnOutSnmpSocket, + fdnInIcpSocket, fdnInHtcpSocket, fdnEnd + } FdNoteId; extern const char *FdNote(int fdNodeId); ///< converts FdNoteId into a string diff --git a/src/ipc/Kid.cc b/src/ipc/Kid.cc index 8150fee41a..f6f5d1ccf7 100644 --- a/src/ipc/Kid.cc +++ b/src/ipc/Kid.cc @@ -9,19 +9,19 @@ #include "ipc/Kid.h" Kid::Kid(): - badFailures(0), - pid(-1), - startTime(0), - isRunning(false) + badFailures(0), + pid(-1), + startTime(0), + isRunning(false) { } Kid::Kid(const String& kid_name): - theName(kid_name), - badFailures(0), - pid(-1), - startTime(0), - isRunning(false) + theName(kid_name), + badFailures(0), + pid(-1), + startTime(0), + isRunning(false) { } diff --git a/src/ipc/Messages.h b/src/ipc/Messages.h index 7ece20418d..7d0e370ac0 100644 --- a/src/ipc/Messages.h +++ b/src/ipc/Messages.h @@ -19,10 +19,12 @@ class TypedMsgHdr; /// message class identifier typedef enum { mtNone = 0, mtRegistration, - mtSharedListenRequest, mtSharedListenResponse } MessageType; + mtSharedListenRequest, mtSharedListenResponse + } MessageType; /// Strand location details -class StrandCoord { +class StrandCoord +{ public: StrandCoord(); ///< unknown location StrandCoord(int akidId, pid_t aPid); ///< from registrant diff --git a/src/ipc/Port.cc b/src/ipc/Port.cc index b02c18ee49..328229e247 100644 --- a/src/ipc/Port.cc +++ b/src/ipc/Port.cc @@ -15,7 +15,7 @@ const char Ipc::strandAddrPfx[] = DEFAULT_PREFIX "/var/run/squid"; Ipc::Port::Port(const String& aListenAddr): - UdsOp(aListenAddr) + UdsOp(aListenAddr) { setOptions(COMM_NONBLOCKING | COMM_DOBIND); } @@ -31,7 +31,7 @@ void Ipc::Port::listen() debugs(54, 6, HERE); buf.prepForReading(); AsyncCall::Pointer readHandler = asyncCall(54, 6, "Ipc::Port::noteRead", - CommCbMemFunT(this, &Port::noteRead)); + CommCbMemFunT(this, &Port::noteRead)); comm_read(fd(), buf.raw(), buf.size(), readHandler); } @@ -53,7 +53,7 @@ String Ipc::Port::MakeAddr(const char* pathAddr, int id) void Ipc::Port::noteRead(const CommIoCbParams& params) { debugs(54, 6, HERE << "FD " << params.fd << " flag " << params.flag << - " [" << this << ']'); + " [" << this << ']'); if (params.flag == COMM_OK) { assert(params.buf == buf.raw()); receive(buf); diff --git a/src/ipc/SharedListen.cc b/src/ipc/SharedListen.cc index 9e46fcb6e5..ada9cefac4 100644 --- a/src/ipc/SharedListen.cc +++ b/src/ipc/SharedListen.cc @@ -80,12 +80,12 @@ void Ipc::SharedListenRequest::pack(TypedMsgHdr &hdrMsg) const Ipc::SharedListenResponse::SharedListenResponse(int aFd, int anErrNo, int aMapId): - fd(aFd), errNo(anErrNo), mapId(aMapId) + fd(aFd), errNo(anErrNo), mapId(aMapId) { } Ipc::SharedListenResponse::SharedListenResponse(const TypedMsgHdr &hdrMsg): - fd(-1), errNo(0), mapId(-1) + fd(-1), errNo(0), mapId(-1) { hdrMsg.getData(mtSharedListenResponse, this, sizeof(*this)); fd = hdrMsg.getFd(); @@ -99,7 +99,7 @@ void Ipc::SharedListenResponse::pack(TypedMsgHdr &hdrMsg) const void Ipc::JoinSharedListen(const OpenListenerParams ¶ms, - AsyncCall::Pointer &callback) + AsyncCall::Pointer &callback) { PendingOpenRequest por; por.params = params; @@ -111,7 +111,7 @@ void Ipc::JoinSharedListen(const OpenListenerParams ¶ms, request.mapId = AddToMap(por); debugs(54, 3, HERE << "getting listening FD for " << request.params.addr << - " mapId=" << request.mapId); + " mapId=" << request.mapId); TypedMsgHdr message; request.pack(message); @@ -123,7 +123,7 @@ void Ipc::SharedListenJoined(const SharedListenResponse &response) const int fd = response.fd; debugs(54, 3, HERE << "got listening FD " << fd << " errNo=" << - response.errNo << " mapId=" << response.mapId); + response.errNo << " mapId=" << response.mapId); Must(TheSharedListenRequestMap.find(response.mapId) != TheSharedListenRequestMap.end()); PendingOpenRequest por = TheSharedListenRequestMap[response.mapId]; diff --git a/src/ipc/StartListening.cc b/src/ipc/StartListening.cc index 9292bd753d..ff61538cc3 100644 --- a/src/ipc/StartListening.cc +++ b/src/ipc/StartListening.cc @@ -27,7 +27,7 @@ std::ostream &Ipc::StartListeningCb::startPrint(std::ostream &os) const void Ipc::StartListening(int sock_type, int proto, IpAddress &addr, - int flags, FdNoteId fdNote, AsyncCall::Pointer &callback) + int flags, FdNoteId fdNote, AsyncCall::Pointer &callback) { OpenListenerParams p; p.sock_type = sock_type; @@ -43,7 +43,7 @@ void Ipc::StartListening(int sock_type, int proto, IpAddress &addr, enter_suid(); const int sock = comm_open_listener(p.sock_type, p.proto, p.addr, p.flags, - FdNote(p.fdNote)); + FdNote(p.fdNote)); const int errNo = (sock >= 0) ? 0 : errno; leave_suid(); diff --git a/src/ipc/StartListening.h b/src/ipc/StartListening.h index 9bf8e44f11..f2180d7543 100644 --- a/src/ipc/StartListening.h +++ b/src/ipc/StartListening.h @@ -35,7 +35,7 @@ public: /// Depending on whether SMP is on, either ask Coordinator to send us /// the listening FD or call comm_open_listener() directly. extern void StartListening(int sock_type, int proto, IpAddress &addr, - int flags, FdNoteId fdNote, AsyncCall::Pointer &callback); + int flags, FdNoteId fdNote, AsyncCall::Pointer &callback); } // namespace Ipc; diff --git a/src/ipc/Strand.cc b/src/ipc/Strand.cc index cc0bd841c2..622f8c4e6b 100644 --- a/src/ipc/Strand.cc +++ b/src/ipc/Strand.cc @@ -16,8 +16,8 @@ CBDATA_NAMESPACED_CLASS_INIT(Ipc, Strand); Ipc::Strand::Strand(): - Port(MakeAddr(strandAddrPfx, KidIdentifier)), - isRegistered(false) + Port(MakeAddr(strandAddrPfx, KidIdentifier)), + isRegistered(false) { } diff --git a/src/ipc/TypedMsgHdr.cc b/src/ipc/TypedMsgHdr.cc index b596b80c1d..0b12ab4861 100644 --- a/src/ipc/TypedMsgHdr.cc +++ b/src/ipc/TypedMsgHdr.cc @@ -13,49 +13,49 @@ Ipc::TypedMsgHdr::TypedMsgHdr() { - xmemset(this, 0, sizeof(*this)); - sync(); + xmemset(this, 0, sizeof(*this)); + sync(); } Ipc::TypedMsgHdr::TypedMsgHdr(const TypedMsgHdr &tmh) { - xmemcpy(this, &tmh, sizeof(*this)); - sync(); + xmemcpy(this, &tmh, sizeof(*this)); + sync(); } Ipc::TypedMsgHdr &Ipc::TypedMsgHdr::operator =(const TypedMsgHdr &tmh) { - if (this != &tmh) { // skip assignment to self - xmemcpy(this, &tmh, sizeof(*this)); - sync(); - } - return *this; + if (this != &tmh) { // skip assignment to self + xmemcpy(this, &tmh, sizeof(*this)); + sync(); + } + return *this; } // update msghdr and ios pointers based on msghdr counters void Ipc::TypedMsgHdr::sync() { - if (msg_name) { // we have a name - msg_name = &name; - } else { - Must(!msg_namelen && !msg_name); - } - - if (msg_iov) { // we have a data component - Must(msg_iovlen == 1); - msg_iov = ios; - ios[0].iov_base = &data; - Must(ios[0].iov_len == sizeof(data)); - } else { - Must(!msg_iovlen && !msg_iov); - } - - if (msg_control) { // we have a control component - Must(msg_controllen > 0); - msg_control = &ctrl; - } else { - Must(!msg_controllen && !msg_control); - } + if (msg_name) { // we have a name + msg_name = &name; + } else { + Must(!msg_namelen && !msg_name); + } + + if (msg_iov) { // we have a data component + Must(msg_iovlen == 1); + msg_iov = ios; + ios[0].iov_base = &data; + Must(ios[0].iov_len == sizeof(data)); + } else { + Must(!msg_iovlen && !msg_iov); + } + + if (msg_control) { // we have a control component + Must(msg_controllen > 0); + msg_control = &ctrl; + } else { + Must(!msg_controllen && !msg_control); + } } @@ -63,15 +63,15 @@ void Ipc::TypedMsgHdr::sync() int Ipc::TypedMsgHdr::type() const { - Must(msg_iovlen == 1); - return data.type_; + Must(msg_iovlen == 1); + return data.type_; } void Ipc::TypedMsgHdr::address(const struct sockaddr_un& addr) { - allocName(); - name = addr; + allocName(); + name = addr; msg_name = &name; msg_namelen = SUN_LEN(&name); } @@ -79,81 +79,81 @@ Ipc::TypedMsgHdr::address(const struct sockaddr_un& addr) void Ipc::TypedMsgHdr::getData(int destType, void *raw, size_t size) const { - Must(type() == destType); - Must(size == data.size); - xmemcpy(raw, data.raw, size); + Must(type() == destType); + Must(size == data.size); + xmemcpy(raw, data.raw, size); } void Ipc::TypedMsgHdr::putData(int aType, const void *raw, size_t size) { - Must(size <= sizeof(data.raw)); - allocData(); - data.type_ = aType; - data.size = size; - xmemcpy(data.raw, raw, size); + Must(size <= sizeof(data.raw)); + allocData(); + data.type_ = aType; + data.size = size; + xmemcpy(data.raw, raw, size); } void Ipc::TypedMsgHdr::putFd(int fd) { - Must(fd >= 0); - allocControl(); + Must(fd >= 0); + allocControl(); - const int fdCount = 1; + const int fdCount = 1; - struct cmsghdr *cmsg = CMSG_FIRSTHDR(this); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fdCount); + struct cmsghdr *cmsg = CMSG_FIRSTHDR(this); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fdCount); int *fdStore = reinterpret_cast(CMSG_DATA(cmsg)); - xmemcpy(fdStore, &fd, fdCount * sizeof(int)); + xmemcpy(fdStore, &fd, fdCount * sizeof(int)); msg_controllen = cmsg->cmsg_len; } int Ipc::TypedMsgHdr::getFd() const { - Must(msg_control && msg_controllen); + Must(msg_control && msg_controllen); - struct cmsghdr *cmsg = CMSG_FIRSTHDR(this); - Must(cmsg->cmsg_level == SOL_SOCKET); - Must(cmsg->cmsg_type == SCM_RIGHTS); + struct cmsghdr *cmsg = CMSG_FIRSTHDR(this); + Must(cmsg->cmsg_level == SOL_SOCKET); + Must(cmsg->cmsg_type == SCM_RIGHTS); - const int fdCount = 1; + const int fdCount = 1; const int *fdStore = reinterpret_cast(CMSG_DATA(cmsg)); - int fd = -1; - xmemcpy(&fd, fdStore, fdCount * sizeof(int)); - return fd; + int fd = -1; + xmemcpy(&fd, fdStore, fdCount * sizeof(int)); + return fd; } void Ipc::TypedMsgHdr::prepForReading() { - xmemset(this, 0, sizeof(*this)); - allocName(); - allocData(); - allocControl(); + xmemset(this, 0, sizeof(*this)); + allocName(); + allocData(); + allocControl(); } /// initialize io vector with one io record void Ipc::TypedMsgHdr::allocData() { - Must(!msg_iovlen && !msg_iov); - msg_iovlen = 1; - msg_iov = ios; - ios[0].iov_base = &data; - ios[0].iov_len = sizeof(data); - data.type_ = 0; - data.size = 0; + Must(!msg_iovlen && !msg_iov); + msg_iovlen = 1; + msg_iov = ios; + ios[0].iov_base = &data; + ios[0].iov_len = sizeof(data); + data.type_ = 0; + data.size = 0; } void Ipc::TypedMsgHdr::allocName() { - Must(!msg_name && !msg_namelen); + Must(!msg_name && !msg_namelen); msg_name = &name; msg_namelen = sizeof(name); // is that the right size? } @@ -161,7 +161,7 @@ Ipc::TypedMsgHdr::allocName() void Ipc::TypedMsgHdr::allocControl() { - Must(!msg_control && !msg_controllen); - msg_control = &ctrl; - msg_controllen = sizeof(ctrl); + Must(!msg_control && !msg_controllen); + msg_control = &ctrl; + msg_controllen = sizeof(ctrl); } diff --git a/src/ipc/TypedMsgHdr.h b/src/ipc/TypedMsgHdr.h index fafa048f5d..513cd89127 100644 --- a/src/ipc/TypedMsgHdr.h +++ b/src/ipc/TypedMsgHdr.h @@ -31,35 +31,35 @@ public: void address(const struct sockaddr_un& addr); ///< sets [dest.] address void getData(int ofType, void *raw, size_t size) const; ///< checks type void putData(int aType, const void *raw, size_t size); ///< stores type - void putFd(int aFd); ///< stores descriptor - int getFd() const; ///< returns descriptor + void putFd(int aFd); ///< stores descriptor + int getFd() const; ///< returns descriptor /// raw, type-independent access for I/O - void prepForReading(); ///< reset and provide all buffers - char *raw() { return reinterpret_cast(this); } - const char *raw() const { return reinterpret_cast(this); } + void prepForReading(); ///< reset and provide all buffers + char *raw() { return reinterpret_cast(this); } + const char *raw() const { return reinterpret_cast(this); } size_t size() const { return sizeof(*this); } ///< not true message size private: - void sync(); - void allocData(); - void allocName(); - void allocControl(); + void sync(); + void allocData(); + void allocName(); + void allocControl(); private: - struct sockaddr_un name; ///< same as .msg_name + struct sockaddr_un name; ///< same as .msg_name - struct iovec ios[1]; ///< same as .msg_iov[] + struct iovec ios[1]; ///< same as .msg_iov[] - struct DataBuffer { - int type_; ///< Message kind, uses MessageType values - size_t size; ///< actual raw data size (for sanity checks) - char raw[250]; ///< buffer with type-specific data - } data; ///< same as .msg_iov[0].iov_base + struct DataBuffer { + int type_; ///< Message kind, uses MessageType values + size_t size; ///< actual raw data size (for sanity checks) + char raw[250]; ///< buffer with type-specific data + } data; ///< same as .msg_iov[0].iov_base - struct CtrlBuffer { - char raw[CMSG_SPACE(sizeof(int))]; ///< control buffer space for one fd - } ctrl; ///< same as .msg_control + struct CtrlBuffer { + char raw[CMSG_SPACE(sizeof(int))]; ///< control buffer space for one fd + } ctrl; ///< same as .msg_control }; } // namespace Ipc diff --git a/src/ipc/UdsOp.cc b/src/ipc/UdsOp.cc index 9f6c005678..741a33e0e4 100644 --- a/src/ipc/UdsOp.cc +++ b/src/ipc/UdsOp.cc @@ -13,10 +13,10 @@ Ipc::UdsOp::UdsOp(const String& pathAddr): - AsyncJob("Ipc::UdsOp"), - address(PathToAddress(pathAddr)), - options(COMM_NONBLOCKING), - fd_(-1) + AsyncJob("Ipc::UdsOp"), + address(PathToAddress(pathAddr)), + options(COMM_NONBLOCKING), + fd_(-1) { debugs(54, 5, HERE << '[' << this << "] pathAddr=" << pathAddr); } @@ -47,8 +47,8 @@ int Ipc::UdsOp::fd() void Ipc::UdsOp::setTimeout(int seconds, const char *handlerName) { AsyncCall::Pointer handler = asyncCall(54,5, handlerName, - CommCbMemFunT(this, - &UdsOp::noteTimeout)); + CommCbMemFunT(this, + &UdsOp::noteTimeout)); commSetTimeout(fd(), seconds, handler); } @@ -64,8 +64,7 @@ void Ipc::UdsOp::noteTimeout(const CommTimeoutCbParams &) struct sockaddr_un -Ipc::PathToAddress(const String& pathAddr) -{ +Ipc::PathToAddress(const String& pathAddr) { assert(pathAddr.size() != 0); struct sockaddr_un unixAddr; memset(&unixAddr, 0, sizeof(unixAddr)); @@ -78,11 +77,11 @@ Ipc::PathToAddress(const String& pathAddr) CBDATA_NAMESPACED_CLASS_INIT(Ipc, UdsSender); Ipc::UdsSender::UdsSender(const String& pathAddr, const TypedMsgHdr& aMessage): - UdsOp(pathAddr), - message(aMessage), - retries(10), // TODO: make configurable? - timeout(10), // TODO: make configurable? - writing(false) + UdsOp(pathAddr), + message(aMessage), + retries(10), // TODO: make configurable? + timeout(10), // TODO: make configurable? + writing(false) { message.address(address); } @@ -104,7 +103,7 @@ void Ipc::UdsSender::write() { debugs(54, 5, HERE); AsyncCall::Pointer writeHandler = asyncCall(54, 5, "Ipc::UdsSender::wrote", - CommCbMemFunT(this, &UdsSender::wrote)); + CommCbMemFunT(this, &UdsSender::wrote)); comm_write(fd(), message.raw(), message.size(), writeHandler); writing = true; } diff --git a/src/ipc/UdsOp.h b/src/ipc/UdsOp.h index b1f3ea07af..0187a4e3ee 100644 --- a/src/ipc/UdsOp.h +++ b/src/ipc/UdsOp.h @@ -39,7 +39,7 @@ protected: void setTimeout(int seconds, const char *handlerName); void clearTimeout(); ///< remove previously set timeout, if any - void setOptions(int newOptions); ///< changes socket options + void setOptions(int newOptions); ///< changes socket options private: /// Comm timeout callback; calls timedout() diff --git a/src/main.cc b/src/main.cc index 554d061060..362a5a6f46 100644 --- a/src/main.cc +++ b/src/main.cc @@ -624,37 +624,37 @@ serverConnectionsOpen(void) if (IamPrimaryProcess()) { #if USE_WCCP - wccpConnectionOpen(); + wccpConnectionOpen(); #endif #if USE_WCCPv2 - wccp2ConnectionOpen(); + wccp2ConnectionOpen(); #endif } // Coordinator does not start proxying services if (!IamCoordinatorProcess()) { - clientOpenListenSockets(); - icpConnectionsOpen(); + clientOpenListenSockets(); + icpConnectionsOpen(); #if USE_HTCP - htcpInit(); + htcpInit(); #endif #ifdef SQUID_SNMP - snmpConnectionOpen(); + snmpConnectionOpen(); #endif - clientdbInit(); - icmpEngine.Open(); - netdbInit(); - asnInit(); - ACL::Initialize(); - peerSelectInit(); - - carpInit(); - peerUserHashInit(); - peerSourceHashInit(); + clientdbInit(); + icmpEngine.Open(); + netdbInit(); + asnInit(); + ACL::Initialize(); + peerSelectInit(); + + carpInit(); + peerUserHashInit(); + peerSourceHashInit(); } } @@ -666,28 +666,28 @@ serverConnectionsClose(void) if (IamPrimaryProcess()) { #if USE_WCCP - wccpConnectionClose(); + wccpConnectionClose(); #endif #if USE_WCCPv2 - wccp2ConnectionClose(); + wccp2ConnectionClose(); #endif } if (!IamCoordinatorProcess()) { - clientHttpConnectionsClose(); - icpConnectionShutdown(); + clientHttpConnectionsClose(); + icpConnectionShutdown(); #if USE_HTCP - htcpSocketShutdown(); + htcpSocketShutdown(); #endif - icmpEngine.Close(); + icmpEngine.Close(); #ifdef SQUID_SNMP - snmpConnectionShutdown(); + snmpConnectionShutdown(); #endif - asnFreeMemory(); + asnFreeMemory(); } } @@ -752,8 +752,8 @@ mainReconfigureFinish(void *) } if (oldWorkers != Config.workers) { debugs(1, DBG_CRITICAL, "WARNING: Changing 'workers' (from " << - oldWorkers << " to " << Config.workers << - ") is not supported and ignored"); + oldWorkers << " to " << Config.workers << + ") is not supported and ignored"); Config.workers = oldWorkers; } @@ -788,11 +788,11 @@ mainReconfigureFinish(void *) if (IamPrimaryProcess()) { #if USE_WCCP - wccpInit(); + wccpInit(); #endif #if USE_WCCPv2 - wccp2Init(); + wccp2Init(); #endif } @@ -1051,12 +1051,12 @@ mainInitialize(void) if (IamPrimaryProcess()) { #if USE_WCCP - wccpInit(); + wccpInit(); #endif #if USE_WCCPv2 - wccp2Init(); + wccp2Init(); #endif } @@ -1189,7 +1189,7 @@ SquidMainSafe(int argc, char **argv) static void ConfigureCurrentKid(const char *processName) { - // kids are marked with parenthesis around their process names + // kids are marked with parenthesis around their process names if (processName && processName[0] == '(') { if (const char *idStart = strrchr(processName, '-')) { KidIdentifier = atoi(idStart + 1); @@ -1640,9 +1640,9 @@ watch_child(char *argv[]) if (Config.workers > 128) { syslog(LOG_ALERT, "Suspiciously high workers value: %d", - Config.workers); + Config.workers); // but we keep going in hope that user knows best - } + } TheKids.init(Config.workers); // keep [re]starting kids until it is time to quit @@ -1683,19 +1683,18 @@ watch_child(char *argv[]) #endif // Loop to collect all stopped kids before we go to sleep below. - do - { + do { Kid* kid = TheKids.find(pid); if (kid) { kid->stop(status); if (kid->calledExit()) { syslog(LOG_NOTICE, - "Squid Parent: child process %d exited with status %d", - kid->getPid(), kid->exitStatus()); + "Squid Parent: child process %d exited with status %d", + kid->getPid(), kid->exitStatus()); } else if (kid->signaled()) { syslog(LOG_NOTICE, - "Squid Parent: child process %d exited due to signal %d with status %d", - kid->getPid(), kid->termSignal(), kid->exitStatus()); + "Squid Parent: child process %d exited due to signal %d with status %d", + kid->getPid(), kid->termSignal(), kid->exitStatus()); } else { syslog(LOG_NOTICE, "Squid Parent: child process %d exited", kid->getPid()); } @@ -1705,7 +1704,8 @@ watch_child(char *argv[]) #ifdef _SQUID_NEXT_ } while ((pid = wait3(&status, WNOHANG, NULL)) > 0); #else - } while ((pid = waitpid(-1, &status, WNOHANG)) > 0); + } + while ((pid = waitpid(-1, &status, WNOHANG)) > 0); #endif if (TheKids.allExitedHappy()) { diff --git a/src/protos.h b/src/protos.h index 37960375bc..ce4ba9e9e1 100644 --- a/src/protos.h +++ b/src/protos.h @@ -578,7 +578,7 @@ SQUIDCEXTERN void keepCapabilities(void); SQUIDCEXTERN void BroadcastSignalIfAny(int& sig); /// whether the current process is the parent of all other Squid processes SQUIDCEXTERN bool IamMasterProcess(); -/** +/** whether the current process is dedicated to doing things that only a single process should do, such as PID file maintenance and WCCP */ diff --git a/src/snmp_core.cc b/src/snmp_core.cc index e67140d148..287fbef1b5 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -42,7 +42,7 @@ /// dials snmpConnectionOpened call class SnmpListeningStartedDialer: public CallDialer, - public Ipc::StartListeningCb + public Ipc::StartListeningCb { public: typedef void (*Handler)(int fd, int errNo); @@ -307,27 +307,27 @@ snmpConnectionOpen(void) Config.Addrs.snmp_incoming.SetPort(Config.Port.snmp); AsyncCall::Pointer call = asyncCall(49, 2, - "snmpIncomingConnectionOpened", - SnmpListeningStartedDialer(&snmpIncomingConnectionOpened)); + "snmpIncomingConnectionOpened", + SnmpListeningStartedDialer(&snmpIncomingConnectionOpened)); Ipc::StartListening(SOCK_DGRAM, - IPPROTO_UDP, - Config.Addrs.snmp_incoming, - COMM_NONBLOCKING, - Ipc::fdnInSnmpSocket, call); + IPPROTO_UDP, + Config.Addrs.snmp_incoming, + COMM_NONBLOCKING, + Ipc::fdnInSnmpSocket, call); if (!Config.Addrs.snmp_outgoing.IsNoAddr()) { Config.Addrs.snmp_outgoing.SetPort(Config.Port.snmp); AsyncCall::Pointer call = asyncCall(49, 2, - "snmpOutgoingConnectionOpened", - SnmpListeningStartedDialer(&snmpOutgoingConnectionOpened)); - - Ipc::StartListening(SOCK_DGRAM, - IPPROTO_UDP, - Config.Addrs.snmp_outgoing, - COMM_NONBLOCKING, - Ipc::fdnOutSnmpSocket, call); + "snmpOutgoingConnectionOpened", + SnmpListeningStartedDialer(&snmpOutgoingConnectionOpened)); + + Ipc::StartListening(SOCK_DGRAM, + IPPROTO_UDP, + Config.Addrs.snmp_outgoing, + COMM_NONBLOCKING, + Ipc::fdnOutSnmpSocket, call); } } } @@ -340,10 +340,10 @@ snmpIncomingConnectionOpened(int fd, int errNo) fatal("Cannot open Incoming SNMP Port"); commSetSelect(theInSnmpConnection, COMM_SELECT_READ, snmpHandleUdp, NULL, - 0); + 0); debugs(1, 1, "Accepting SNMP messages on " << Config.Addrs.snmp_incoming << - ", FD " << theInSnmpConnection << "."); + ", FD " << theInSnmpConnection << "."); if (Config.Addrs.snmp_outgoing.IsNoAddr()) theOutSnmpConnection = theInSnmpConnection; @@ -357,10 +357,10 @@ snmpOutgoingConnectionOpened(int fd, int errNo) fatal("Cannot open Outgoing SNMP Port"); commSetSelect(theOutSnmpConnection, COMM_SELECT_READ, snmpHandleUdp, NULL, - 0); + 0); debugs(1, 1, "Outgoing SNMP messages on " << Config.Addrs.snmp_outgoing << - ", FD " << theOutSnmpConnection << "."); + ", FD " << theOutSnmpConnection << "."); { struct addrinfo *xaddr = NULL;