From: Amos Jeffries Date: Thu, 5 Jun 2014 14:57:58 +0000 (-0700) Subject: SourceLayout: rename comm_err_t to Comm::Flag X-Git-Tag: SQUID_3_5_0_1~200 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c84072955413d01892a9ef72f44c676609850825;p=thirdparty%2Fsquid.git SourceLayout: rename comm_err_t to Comm::Flag Integration testing of rev.13443 revealed that there were two copies of comm_err_t.h in the source code. * Remove the unnecessary duplicate file. * Shuffle the enum into Comm:: scope as 'Flag'. * Reduce the enum value labels to drop the redundant prefix. * Rename COMM_EOF to Comm::ENDFILE to avoid colliston with #define EOF in system headers. --- diff --git a/src/Comm.dox b/src/Comm.dox index 55eb1ec92b..4bf256a945 100644 --- a/src/Comm.dox +++ b/src/Comm.dox @@ -102,8 +102,8 @@ \par The read, write, and accept notifications (scheduled in step #2 - above) carry the COMM_ERR_CLOSING error flag. When handling - COMM_ERR_CLOSING event, the user code should limit + above) carry the Comm::ERR_CLOSING error flag. When handling + Comm::ERR_CLOSING event, the user code should limit descriptor-related processing, especially Comm calls, because supported Comm functionality is very limited when the descriptor is closing. New code should use the close handlers instead (scheduled @@ -121,7 +121,7 @@ Since all notifications are asynchronous, it is possible for a read or write notification that was scheduled before comm_close() was called to arrive at its destination after comm_close() was called. - Such notification will arrive with COMM_ERR_CLOSING flag even though + Such notification will arrive with Comm::ERR_CLOSING flag even though that flag was not set at the time of the I/O (and the I/O may have been successful). This behavior may change. @@ -140,12 +140,12 @@ instead. \par - COMM_ERR_CLOSING interface will be removed. The read, write, and + Comm::ERR_CLOSING interface will be removed. The read, write, and accept notifications will not be scheduled after comm_close() is called. New user code should register close handlers instead. \par - When COMM_ERR_CLOSING interface is removed, pending notifications + When Comm::ERR_CLOSING interface is removed, pending notifications (if any) will be canceled after comm_close() is called. However, the cancellation may be removed later if Comm is modified to provide safe access to closing descriptors and their fragile state. New user code diff --git a/src/CommCalls.cc b/src/CommCalls.cc index e0f622cdbd..36d91b196e 100644 --- a/src/CommCalls.cc +++ b/src/CommCalls.cc @@ -7,7 +7,7 @@ /* CommCommonCbParams */ CommCommonCbParams::CommCommonCbParams(void *aData): - data(cbdataReference(aData)), conn(), flag(COMM_OK), xerrno(0), fd(-1) + data(cbdataReference(aData)), conn(), flag(Comm::OK), xerrno(0), fd(-1) { } @@ -31,7 +31,7 @@ CommCommonCbParams::print(std::ostream &os) const if (xerrno) os << ", errno=" << xerrno; - if (flag != COMM_OK) + if (flag != Comm::OK) os << ", flag=" << flag; if (data) os << ", data=" << data; @@ -84,9 +84,9 @@ CommIoCbParams::syncWithComm() { // change parameters if the call was scheduled before comm_close but // is being fired after comm_close - if ((conn->fd < 0 || fd_table[conn->fd].closing()) && flag != COMM_ERR_CLOSING) { - debugs(5, 3, HERE << "converting late call to COMM_ERR_CLOSING: " << conn); - flag = COMM_ERR_CLOSING; + if ((conn->fd < 0 || fd_table[conn->fd].closing()) && flag != Comm::ERR_CLOSING) { + debugs(5, 3, HERE << "converting late call to Comm::ERR_CLOSING: " << conn); + flag = Comm::ERR_CLOSING; } return true; // now we are in sync and can handle the call } diff --git a/src/CommCalls.h b/src/CommCalls.h index 084171b928..d430cb6cb3 100644 --- a/src/CommCalls.h +++ b/src/CommCalls.h @@ -3,8 +3,8 @@ #include "base/AsyncCall.h" #include "base/AsyncJobCalls.h" +#include "comm/Flag.h" #include "comm/forward.h" -#include "comm_err_t.h" #include "MasterXaction.h" /* CommCalls implement AsyncCall interface for comm_* callbacks. @@ -24,8 +24,8 @@ class CommAcceptCbParams; typedef void IOACB(const CommAcceptCbParams ¶ms); -typedef void CNCB(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data); -typedef void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, comm_err_t flag, int xerrno, void *data); +typedef void CNCB(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data); +typedef void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int xerrno, void *data); class CommTimeoutCbParams; typedef void CTCB(const CommTimeoutCbParams ¶ms); @@ -72,12 +72,12 @@ public: * - On read calls this is the connection just read from. * - On close calls this describes the connection which is now closed. * - On timeouts this is the connection whose operation timed out. - * + NP: timeouts might also return to the connect/read/write handler with COMM_ERR_TIMEOUT. + * + NP: timeouts might also return to the connect/read/write handler with Comm::TIMEOUT. */ Comm::ConnectionPointer conn; - comm_err_t flag; ///< comm layer result status. - int xerrno; ///< The last errno to occur. non-zero if flag is COMM_ERR. + Comm::Flag flag; ///< comm layer result status. + int xerrno; ///< The last errno to occur. non-zero if flag is Comm::ERROR. int fd; ///< FD which the call was about. Set by the async call creator. private: diff --git a/src/FwdState.cc b/src/FwdState.cc index ccdd03c9e4..8b5b2d1863 100644 --- a/src/FwdState.cc +++ b/src/FwdState.cc @@ -539,7 +539,7 @@ fwdServerClosedWrapper(const CommCloseCbParams ¶ms) } void -fwdConnectDoneWrapper(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data) +fwdConnectDoneWrapper(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data) { FwdState *fwd = (FwdState *) data; fwd->connectDone(conn, status, xerrno); @@ -671,9 +671,9 @@ FwdState::handleUnregisteredServerEnd() } void -FwdState::connectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno) +FwdState::connectDone(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno) { - if (status != COMM_OK) { + if (status != Comm::OK) { ErrorState *const anErr = makeConnectingError(ERR_CONNECT_FAIL); anErr->xerrno = xerrno; fail(anErr); diff --git a/src/FwdState.h b/src/FwdState.h index 36680b9ba5..e78aa905ad 100644 --- a/src/FwdState.h +++ b/src/FwdState.h @@ -73,7 +73,7 @@ public: bool reforwardableStatus(const Http::StatusCode s) const; void serverClosed(int fd); void connectStart(); - void connectDone(const Comm::ConnectionPointer & conn, comm_err_t status, int xerrno); + void connectDone(const Comm::ConnectionPointer & conn, Comm::Flag status, int xerrno); void connectTimeout(int fd); bool checkRetry(); bool checkRetriable(); diff --git a/src/Makefile.am b/src/Makefile.am index d2ebb1f65e..6f8fcd0709 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -264,7 +264,6 @@ DiskIO/DiskIOModules_gen.cc: Makefile libsquid_la_SOURCES = \ comm.cc \ comm.h \ - comm_err_t.h \ CommCalls.cc \ CommCalls.h \ DescriptorSet.cc \ diff --git a/src/PeerPoolMgr.cc b/src/PeerPoolMgr.cc index 04124000ea..2a6de4262c 100644 --- a/src/PeerPoolMgr.cc +++ b/src/PeerPoolMgr.cc @@ -91,7 +91,7 @@ PeerPoolMgr::handleOpenedConnection(const CommConnectCbParams ¶ms) return; } - if (params.flag != COMM_OK) { + if (params.flag != Comm::OK) { /* it might have been a timeout with a partially open link */ if (params.conn != NULL) params.conn->close(); diff --git a/src/Server.cc b/src/Server.cc index 324b23315b..7e2e26dbbf 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -376,7 +376,7 @@ ServerStateData::sentRequestBody(const CommIoCbParams &io) // kids should increment their counters } - if (io.flag == COMM_ERR_CLOSING) + if (io.flag == Comm::ERR_CLOSING) return; if (!requestBodySource) { diff --git a/src/client_side.cc b/src/client_side.cc index baade6c0e0..cd7b74df61 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -375,12 +375,12 @@ ClientSocketContext::writeControlMsg(HttpControlMsg &msg) /// called when we wrote the 1xx response void -ClientSocketContext::wroteControlMsg(const Comm::ConnectionPointer &conn, char *, size_t, comm_err_t errflag, int xerrno) +ClientSocketContext::wroteControlMsg(const Comm::ConnectionPointer &conn, char *, size_t, Comm::Flag errflag, int xerrno) { - if (errflag == COMM_ERR_CLOSING) + if (errflag == Comm::ERR_CLOSING) return; - if (errflag == COMM_OK) { + if (errflag == Comm::OK) { ScheduleCallHere(cbControlMsgSent); return; } @@ -396,7 +396,7 @@ ClientSocketContext::wroteControlMsg(const Comm::ConnectionPointer &conn, char * /// wroteControlMsg() wrapper: ClientSocketContext is not an AsyncJob void -ClientSocketContext::WroteControlMsg(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag, int xerrno, void *data) +ClientSocketContext::WroteControlMsg(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, Comm::Flag errflag, int xerrno, void *data) { ClientSocketContext *context = static_cast(data); context->wroteControlMsg(conn, bufnotused, size, errflag, xerrno); @@ -1061,7 +1061,7 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData) CommIoCbPtrFun(clientWriteComplete, this)); Comm::Write(clientConnection, &mb, call); } else - writeComplete(clientConnection, NULL, 0, COMM_OK); + writeComplete(clientConnection, NULL, 0, Comm::OK); } /** @@ -1503,7 +1503,7 @@ clientSocketRecipient(clientStreamNode * node, ClientHttpRequest * http, const bool mustSendLastChunk = http->request->flags.chunkedReply && !http->request->flags.streamError && !context->startOfOutput(); if (responseFinishedOrFailed(rep, receivedData) && !mustSendLastChunk) { - context->writeComplete(context->clientConnection, NULL, 0, COMM_OK); + context->writeComplete(context->clientConnection, NULL, 0, Comm::OK); PROF_stop(clientSocketRecipient); return; } @@ -1547,7 +1547,7 @@ clientSocketDetach(clientStreamNode * node, ClientHttpRequest * http) } static void -clientWriteBodyComplete(const Comm::ConnectionPointer &conn, char *buf, size_t size, comm_err_t errflag, int xerrno, void *data) +clientWriteBodyComplete(const Comm::ConnectionPointer &conn, char *buf, size_t size, Comm::Flag errflag, int xerrno, void *data) { debugs(33,7, HERE << "clientWriteBodyComplete schedules clientWriteComplete"); clientWriteComplete(conn, NULL, size, errflag, xerrno, data); @@ -1841,7 +1841,7 @@ ClientSocketContext::socketState() * no more data to send. */ void -clientWriteComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag, int xerrno, void *data) +clientWriteComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, Comm::Flag errflag, int xerrno, void *data) { ClientSocketContext *context = (ClientSocketContext *)data; context->writeComplete(conn, bufnotused, size, errflag); @@ -1897,7 +1897,7 @@ ConnStateData::stopSending(const char *error) } void -ClientSocketContext::writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag) +ClientSocketContext::writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, Comm::Flag errflag) { const StoreEntry *entry = http->storeEntry(); http->out.size += size; @@ -1906,9 +1906,9 @@ ClientSocketContext::writeComplete(const Comm::ConnectionPointer &conn, char *bu (entry ? entry->objectLen() : 0)); clientUpdateSocketStats(http->logType, size); - /* Bail out quickly on COMM_ERR_CLOSING - close handlers will tidy up */ + /* Bail out quickly on Comm::ERR_CLOSING - close handlers will tidy up */ - if (errflag == COMM_ERR_CLOSING || !Comm::IsConnOpen(conn)) + if (errflag == Comm::ERR_CLOSING || !Comm::IsConnOpen(conn)) return; if (errflag || clientHttpRequestStatus(conn->fd, http)) { @@ -2969,8 +2969,8 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) Must(reading()); reader = NULL; - /* Bail out quickly on COMM_ERR_CLOSING - close handlers will tidy up */ - if (io.flag == COMM_ERR_CLOSING) { + /* Bail out quickly on Comm::ERR_CLOSING - close handlers will tidy up */ + if (io.flag == Comm::ERR_CLOSING) { debugs(33,5, io.conn << " closing Bailout."); return; } @@ -2989,13 +2989,13 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) rd.conn = io.conn; switch (Comm::ReadNow(rd, in.buf)) { - case COMM_INPROGRESS: + case Comm::INPROGRESS: if (in.buf.isEmpty()) debugs(33, 2, io.conn << ": no data to process, " << xstrerr(rd.xerrno)); readSomeData(); return; - case COMM_OK: + case Comm::OK: kb_incr(&(statCounter.client_http.kbytes_in), rd.size); // may comm_close or setReplyToError if (!handleReadData()) @@ -3004,7 +3004,7 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) /* Continue to process previously read data */ break; - case COMM_EOF: // close detected by 0-byte read + case Comm::ENDFILE: // close detected by 0-byte read debugs(33, 5, io.conn << " closed?"); if (connFinishedWithConn(rd.size)) { @@ -3025,7 +3025,7 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) /* Continue to process previously read data */ break; - // case COMM_ERROR: + // case Comm::ERROR: default: // no other flags should ever occur debugs(33, 2, io.conn << ": got flag " << rd.flag << "; " << xstrerr(rd.xerrno)); notifyAllContexts(rd.xerrno); @@ -3330,7 +3330,7 @@ httpAccept(const CommAcceptCbParams ¶ms) return; } - if (params.flag != COMM_OK) { + if (params.flag != Comm::OK) { // Its possible the call was still queued when the client disconnected debugs(33, 2, "httpAccept: " << s->listenConn << ": accept failure: " << xstrerr(params.xerrno)); return; @@ -3646,7 +3646,7 @@ httpsAccept(const CommAcceptCbParams ¶ms) return; } - if (params.flag != COMM_OK) { + if (params.flag != Comm::OK) { // Its possible the call was still queued when the client disconnected debugs(33, 2, "httpsAccept: " << s->listenConn << ": accept failure: " << xstrerr(params.xerrno)); return; @@ -4507,7 +4507,7 @@ ConnStateData::clientPinnedConnectionRead(const CommIoCbParams &io) { pinning.readHandler = NULL; // Comm unregisters handlers before calling - if (io.flag == COMM_ERR_CLOSING) + if (io.flag == Comm::ERR_CLOSING) return; // close handler will clean up // We could use getConcurrentRequestCount(), but this may be faster. diff --git a/src/client_side.h b/src/client_side.h index 792dfc3c4b..a86c66c0e0 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -87,7 +87,7 @@ public: ClientSocketContext(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aReq); ~ClientSocketContext(); bool startOfOutput() const; - void writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag); + void writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, Comm::Flag errflag); void keepaliveNextRequest(); Comm::ConnectionPointer clientConnection; /// details about the client connection socket. @@ -143,7 +143,7 @@ public: protected: static IOCB WroteControlMsg; - void wroteControlMsg(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag, int xerrno); + void wroteControlMsg(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, Comm::Flag errflag, int xerrno); private: void prepareReply(HttpReply * rep); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index d5a1cbd1ae..2b85580edc 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1558,7 +1558,7 @@ ClientHttpRequest::sslBumpNeed(Ssl::BumpMode mode) // called when comm_write has completed static void -SslBumpEstablish(const Comm::ConnectionPointer &, char *, size_t, comm_err_t errflag, int, void *data) +SslBumpEstablish(const Comm::ConnectionPointer &, char *, size_t, Comm::Flag errflag, int, void *data) { ClientHttpRequest *r = static_cast(data); debugs(85, 5, HERE << "responded to CONNECT: " << r << " ? " << errflag); @@ -1568,10 +1568,10 @@ SslBumpEstablish(const Comm::ConnectionPointer &, char *, size_t, comm_err_t err } void -ClientHttpRequest::sslBumpEstablish(comm_err_t errflag) +ClientHttpRequest::sslBumpEstablish(Comm::Flag errflag) { - // Bail out quickly on COMM_ERR_CLOSING - close handlers will tidy up - if (errflag == COMM_ERR_CLOSING) + // Bail out quickly on Comm::ERR_CLOSING - close handlers will tidy up + if (errflag == Comm::ERR_CLOSING) return; if (errflag) { diff --git a/src/client_side_request.h b/src/client_side_request.h index 3d6e2b1cd2..0ea82869b0 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -154,7 +154,7 @@ public: /// set the sslBumpNeeded state void sslBumpNeed(Ssl::BumpMode mode); void sslBumpStart(); - void sslBumpEstablish(comm_err_t errflag); + void sslBumpEstablish(Comm::Flag errflag); #endif #if USE_ADAPTATION diff --git a/src/comm.cc b/src/comm.cc index 712d6e24d7..271167f1b1 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -98,7 +98,7 @@ static bool WillCheckHalfClosed = false; /// true if check is scheduled static EVH commHalfClosedCheck; static void commPlanHalfClosedCheck(); -static comm_err_t commBind(int s, struct addrinfo &); +static Comm::Flag commBind(int s, struct addrinfo &); static void commSetReuseAddr(int); static void commSetNoLinger(int); #ifdef TCP_NODELAY @@ -219,19 +219,19 @@ comm_local_port(int fd) return F->local_addr.port(); } -static comm_err_t +static Comm::Flag commBind(int s, struct addrinfo &inaddr) { ++ statCounter.syscalls.sock.binds; if (bind(s, inaddr.ai_addr, inaddr.ai_addrlen) == 0) { debugs(50, 6, "commBind: bind socket FD " << s << " to " << fd_table[s].local_addr); - return COMM_OK; + return Comm::OK; } debugs(50, 0, "commBind: Cannot bind socket FD " << s << " to " << fd_table[s].local_addr << ": " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } /** @@ -504,14 +504,14 @@ comm_apply_flags(int new_socket, if ( addr.isNoAddr() ) debugs(5,0,"CRITICAL: Squid is attempting to bind() port " << addr << "!!"); - if (commBind(new_socket, *AI) != COMM_OK) { + if (commBind(new_socket, *AI) != Comm::OK) { comm_close(new_socket); return -1; } } if (flags & COMM_NONBLOCKING) - if (commSetNonBlocking(new_socket) == COMM_ERROR) { + if (commSetNonBlocking(new_socket) == Comm::ERROR) { comm_close(new_socket); return -1; } @@ -618,7 +618,7 @@ commUnsetConnTimeout(const Comm::ConnectionPointer &conn) int comm_connect_addr(int sock, const Ip::Address &address) { - comm_err_t status = COMM_OK; + Comm::Flag status = Comm::OK; fde *F = &fd_table[sock]; int x = 0; int err = 0; @@ -637,7 +637,7 @@ comm_connect_addr(int sock, const Ip::Address &address) */ if (F->sock_family == AF_INET && !address.isIPv4()) { errno = ENETUNREACH; - return COMM_ERR_PROTOCOL; + return Comm::ERR_PROTOCOL; } /* Handle IPv4 over IPv6-only socket case. @@ -649,7 +649,7 @@ comm_connect_addr(int sock, const Ip::Address &address) */ if (!F->local_addr.isIPv4() && address.isIPv4()) { errno = ENETUNREACH; - return COMM_ERR_PROTOCOL; + return Comm::ERR_PROTOCOL; } address.getAddrInfo(AI, F->sock_family); @@ -724,21 +724,21 @@ comm_connect_addr(int sock, const Ip::Address &address) PROF_stop(comm_connect_addr); if (errno == 0 || errno == EISCONN) - status = COMM_OK; + status = Comm::OK; else if (ignoreErrno(errno)) - status = COMM_INPROGRESS; + status = Comm::INPROGRESS; else if (errno == EAFNOSUPPORT || errno == EINVAL) - return COMM_ERR_PROTOCOL; + return Comm::ERR_PROTOCOL; else - return COMM_ERROR; + return Comm::ERROR; address.toStr(F->ipaddr, MAX_IPSTRLEN); F->remote_port = address.port(); /* remote_port is HS */ - if (status == COMM_OK) { + if (status == Comm::OK) { debugs(5, DBG_DATA, "comm_connect_addr: FD " << sock << " connected to " << address); - } else if (status == COMM_INPROGRESS) { + } else if (status == Comm::INPROGRESS) { debugs(5, DBG_DATA, "comm_connect_addr: FD " << sock << " connection pending"); } @@ -890,7 +890,7 @@ comm_close_complete(const FdeCbParams ¶ms) * + call read handlers with ERR_CLOSING * + call closing handlers * - * NOTE: COMM_ERR_CLOSING will NOT be called for CommReads' sitting in a + * NOTE: Comm::ERR_CLOSING will NOT be called for CommReads' sitting in a * DeferredReadManager. */ void @@ -942,11 +942,11 @@ _comm_close(int fd, char const *file, int line) // notify read/write handlers after canceling select reservations, if any if (COMMIO_FD_WRITECB(fd)->active()) { Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0); - COMMIO_FD_WRITECB(fd)->finish(COMM_ERR_CLOSING, errno); + COMMIO_FD_WRITECB(fd)->finish(Comm::ERR_CLOSING, errno); } if (COMMIO_FD_READCB(fd)->active()) { Comm::SetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); - COMMIO_FD_READCB(fd)->finish(COMM_ERR_CLOSING, errno); + COMMIO_FD_READCB(fd)->finish(Comm::ERR_CLOSING, errno); } #if USE_DELAY_POOLS @@ -1004,7 +1004,7 @@ comm_udp_sendto(int fd, debugs(50, DBG_IMPORTANT, "comm_udp_sendto: FD " << fd << ", (family=" << fd_table[fd].sock_family << ") " << to_addr << ": " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } void @@ -1129,7 +1129,7 @@ commSetNonBlocking(int fd) if (ioctl(fd, FIONBIO, &nonblocking) < 0) { debugs(50, 0, "commSetNonBlocking: FD " << fd << ": " << xstrerror() << " " << fd_table[fd].type); - return COMM_ERROR; + return Comm::ERROR; } #if _SQUID_CYGWIN_ @@ -1140,12 +1140,12 @@ commSetNonBlocking(int fd) if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { debugs(50, 0, "FD " << fd << ": fcntl F_GETFL: " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } if (fcntl(fd, F_SETFL, flags | SQUID_NONBLOCK) < 0) { debugs(50, 0, "commSetNonBlocking: FD " << fd << ": " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } #endif @@ -1170,13 +1170,13 @@ commUnsetNonBlocking(int fd) if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { debugs(50, 0, "FD " << fd << ": fcntl F_GETFL: " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } if (fcntl(fd, F_SETFL, flags & (~SQUID_NONBLOCK)) < 0) { #endif debugs(50, 0, "commUnsetNonBlocking: FD " << fd << ": " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } fd_table[fd].flags.nonblocking = false; @@ -1611,7 +1611,7 @@ checkTimeouts(void) // We have an active write callback and we are timed out debugs(5, 5, "checkTimeouts: FD " << fd << " auto write timeout"); Comm::SetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0); - COMMIO_FD_WRITECB(fd)->finish(COMM_ERROR, ETIMEDOUT); + COMMIO_FD_WRITECB(fd)->finish(Comm::ERROR, ETIMEDOUT); } else if (AlreadyTimedOut(F)) continue; @@ -1702,7 +1702,7 @@ commStopHalfClosedMonitor(int const fd) /// I/O handler for the possibly half-closed connection monitoring code static void -commHalfClosedReader(const Comm::ConnectionPointer &conn, char *, size_t size, comm_err_t flag, int, void *) +commHalfClosedReader(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int, void *) { // there cannot be more data coming in on half-closed connections assert(size == 0); @@ -1712,11 +1712,11 @@ commHalfClosedReader(const Comm::ConnectionPointer &conn, char *, size_t size, c fd_table[conn->fd].halfClosedReader = NULL; // done reading, for now // nothing to do if fd is being closed - if (flag == COMM_ERR_CLOSING) + if (flag == Comm::ERR_CLOSING) return; // if read failed, close the connection - if (flag != COMM_OK) { + if (flag != Comm::OK) { debugs(5, 3, HERE << "closing " << conn); conn->close(); return; @@ -1873,17 +1873,17 @@ CommSelectEngine::checkEvents(int timeout) switch (Comm::DoSelect(timeout)) { - case COMM_OK: + case Comm::OK: - case COMM_TIMEOUT: + case Comm::TIMEOUT: return 0; - case COMM_IDLE: + case Comm::IDLE: - case COMM_SHUTDOWN: + case Comm::SHUTDOWN: return EVENT_IDLE; - case COMM_ERROR: + case Comm::ERROR: return EVENT_ERROR; default: @@ -1957,7 +1957,7 @@ comm_open_uds(int sock_type, commSetReuseAddr(new_socket); if (flags & COMM_NONBLOCKING) { - if (commSetNonBlocking(new_socket) != COMM_OK) { + if (commSetNonBlocking(new_socket) != Comm::OK) { comm_close(new_socket); PROF_stop(comm_open); return -1; @@ -1965,7 +1965,7 @@ comm_open_uds(int sock_type, } if (flags & COMM_DOBIND) { - if (commBind(new_socket, AI) != COMM_OK) { + if (commBind(new_socket, AI) != Comm::OK) { comm_close(new_socket); PROF_stop(comm_open); return -1; diff --git a/src/comm.h b/src/comm.h index 46d377ca4f..3046604959 100644 --- a/src/comm.h +++ b/src/comm.h @@ -71,7 +71,6 @@ int ignoreErrno(int); void commCloseAllSockets(void); void checkTimeouts(void); -//typedef void IOACB(int fd, int nfd, Comm::ConnectionPointer details, comm_err_t flag, int xerrno, void *data); void comm_add_close_handler(int fd, CLCB *, void *); void comm_add_close_handler(int fd, AsyncCall::Pointer &); void comm_remove_close_handler(int fd, CLCB *, void *); diff --git a/src/comm/ConnOpener.cc b/src/comm/ConnOpener.cc index fd26497ff4..383f616593 100644 --- a/src/comm/ConnOpener.cc +++ b/src/comm/ConnOpener.cc @@ -62,7 +62,7 @@ Comm::ConnOpener::swanSong() { if (callback_ != NULL) { // inform the still-waiting caller we are dying - sendAnswer(COMM_ERR_CONNECT, 0, "Comm::ConnOpener::swanSong"); + sendAnswer(Comm::ERR_CONNECT, 0, "Comm::ConnOpener::swanSong"); } // did we abort with a temporary FD assigned? @@ -99,7 +99,7 @@ Comm::ConnOpener::getHost() const * Pass the results back to the external handler. */ void -Comm::ConnOpener::sendAnswer(comm_err_t errFlag, int xerrno, const char *why) +Comm::ConnOpener::sendAnswer(Comm::Flag errFlag, int xerrno, const char *why) { // only mark the address good/bad AFTER connect is finished. if (host_ != NULL) { @@ -255,7 +255,7 @@ Comm::ConnOpener::createFd() temporaryFd_ = comm_openex(SOCK_STREAM, IPPROTO_TCP, conn_->local, conn_->flags, conn_->tos, conn_->nfmark, host_); if (temporaryFd_ < 0) { - sendAnswer(COMM_ERR_CONNECT, 0, "Comm::ConnOpener::createFd"); + sendAnswer(Comm::ERR_CONNECT, 0, "Comm::ConnOpener::createFd"); return false; } @@ -304,7 +304,7 @@ Comm::ConnOpener::connected() Must(fd_table[conn_->fd].flags.open); fd_table[conn_->fd].local_addr = conn_->local; - sendAnswer(COMM_OK, 0, "Comm::ConnOpener::connected"); + sendAnswer(Comm::OK, 0, "Comm::ConnOpener::connected"); } /// Make an FD connection attempt. @@ -318,13 +318,13 @@ Comm::ConnOpener::connect() switch (comm_connect_addr(temporaryFd_, conn_->remote) ) { - case COMM_INPROGRESS: - debugs(5, 5, HERE << conn_ << ": COMM_INPROGRESS"); + case Comm::INPROGRESS: + debugs(5, 5, HERE << conn_ << ": Comm::INPROGRESS"); Comm::SetSelect(temporaryFd_, COMM_SELECT_WRITE, Comm::ConnOpener::InProgressConnectRetry, new Pointer(this), 0); break; - case COMM_OK: - debugs(5, 5, HERE << conn_ << ": COMM_OK - connected"); + case Comm::OK: + debugs(5, 5, HERE << conn_ << ": Comm::OK - connected"); connected(); break; @@ -342,7 +342,7 @@ Comm::ConnOpener::connect() } else { // send ERROR back to the upper layer. debugs(5, 5, HERE << conn_ << ": * - ERR tried too many times already."); - sendAnswer(COMM_ERR_CONNECT, xerrno, "Comm::ConnOpener::connect"); + sendAnswer(Comm::ERR_CONNECT, xerrno, "Comm::ConnOpener::connect"); } } } @@ -408,7 +408,7 @@ Comm::ConnOpener::earlyAbort(const CommCloseCbParams &io) debugs(5, 3, HERE << io.conn); calls_.earlyAbort_ = NULL; // NP: is closing or shutdown better? - sendAnswer(COMM_ERR_CLOSING, io.xerrno, "Comm::ConnOpener::earlyAbort"); + sendAnswer(Comm::ERR_CLOSING, io.xerrno, "Comm::ConnOpener::earlyAbort"); } /** @@ -420,10 +420,10 @@ Comm::ConnOpener::timeout(const CommTimeoutCbParams &) { debugs(5, 5, HERE << conn_ << ": * - ERR took too long to receive response."); calls_.timeout_ = NULL; - sendAnswer(COMM_TIMEOUT, ETIMEDOUT, "Comm::ConnOpener::timeout"); + sendAnswer(Comm::TIMEOUT, ETIMEDOUT, "Comm::ConnOpener::timeout"); } -/* Legacy Wrapper for the retry event after COMM_INPROGRESS +/* Legacy Wrapper for the retry event after Comm::INPROGRESS * XXX: As soon as Comm::SetSelect() accepts Async calls we can use a ConnOpener::connect call */ void diff --git a/src/comm/ConnOpener.h b/src/comm/ConnOpener.h index 003b474908..739443ba89 100644 --- a/src/comm/ConnOpener.h +++ b/src/comm/ConnOpener.h @@ -4,8 +4,8 @@ #include "base/AsyncCall.h" #include "base/AsyncJob.h" #include "cbdata.h" +#include "comm/Flag.h" #include "comm/forward.h" -#include "comm_err_t.h" #include "CommCalls.h" namespace Comm @@ -40,7 +40,7 @@ private: void earlyAbort(const CommCloseCbParams &); void timeout(const CommTimeoutCbParams &); - void sendAnswer(comm_err_t errFlag, int xerrno, const char *why); + void sendAnswer(Comm::Flag errFlag, int xerrno, const char *why); static void InProgressConnectRetry(int fd, void *data); static void DelayedConnectRetry(void *data); void connect(); @@ -66,7 +66,7 @@ private: int totalTries_; ///< total number of connection attempts over all destinations so far. int failRetries_; ///< number of retries current destination has been tried. - /// if we are not done by then, we will call back with COMM_TIMEOUT + /// if we are not done by then, we will call back with Comm::TIMEOUT time_t deadline_; /// handles to calls which we may need to cancel. diff --git a/src/comm/Flag.h b/src/comm/Flag.h new file mode 100644 index 0000000000..a6b9532530 --- /dev/null +++ b/src/comm/Flag.h @@ -0,0 +1,25 @@ +#ifndef _SQUID_SRC_COMM_FLAG_H +#define _SQUID_SRC_COMM_FLAG_H + +namespace Comm +{ + +typedef enum { + OK = 0, + ERROR = -1, + NOMESSAGE = -3, + TIMEOUT = -4, + SHUTDOWN = -5, + IDLE = -6, /* there are no active fds and no pending callbacks. */ + INPROGRESS = -7, + ERR_CONNECT = -8, + ERR_DNS = -9, + ERR_CLOSING = -10, + ERR_PROTOCOL = -11, /* IPv4 or IPv6 cannot be used on the fd socket */ + ENDFILE = -12, /**< read(2) returned success, but with 0 bytes */ + ERR__END__ = -999999 /* Dummy entry to make syntax valid (comma on line above), do not use. New entries added above */ +} Flag; + +} // namespace Comm + +#endif /* _SQUID_SRC_COMM_FLAG_H */ diff --git a/src/comm/IoCallback.cc b/src/comm/IoCallback.cc index a018953668..b43873478b 100644 --- a/src/comm/IoCallback.cc +++ b/src/comm/IoCallback.cc @@ -103,7 +103,7 @@ Comm::IoCallback::reset() // Schedule the callback call and clear the callback void -Comm::IoCallback::finish(comm_err_t code, int xerrn) +Comm::IoCallback::finish(Comm::Flag code, int xerrn) { debugs(5, 3, HERE << "called for " << conn << " (" << code << ", " << xerrno << ")"); assert(active()); diff --git a/src/comm/IoCallback.h b/src/comm/IoCallback.h index 705ebf845c..ac998bc839 100644 --- a/src/comm/IoCallback.h +++ b/src/comm/IoCallback.h @@ -2,8 +2,8 @@ #define _SQUID_COMM_IOCALLBACK_H #include "base/AsyncCall.h" +#include "comm/Flag.h" #include "comm/forward.h" -#include "comm_err_t.h" #include "typedefs.h" class SBuf; @@ -29,7 +29,7 @@ public: FREE *freefunc; int size; int offset; - comm_err_t errcode; + Comm::Flag errcode; int xerrno; #if USE_DELAY_POOLS unsigned int quotaQueueReserv; ///< reservation ID from CommQuotaQueue @@ -45,7 +45,7 @@ public: void cancel(const char *reason); /// finish the IO operation imediately and schedule the callback with the current state. - void finish(comm_err_t code, int xerrn); + void finish(Comm::Flag code, int xerrn); private: void reset(); diff --git a/src/comm/Loops.h b/src/comm/Loops.h index 56f064037b..7f74824208 100644 --- a/src/comm/Loops.h +++ b/src/comm/Loops.h @@ -1,7 +1,7 @@ #ifndef _SQUID_SRC_COMM_LOOPS_H #define _SQUID_SRC_COMM_LOOPS_H -#include "comm_err_t.h" +#include "comm/Flag.h" // for PF #include "typedefs.h" @@ -27,7 +27,7 @@ void ResetSelect(int); /** Perform a select() or equivalent call. * This is used by the main select loop engine to check for FD with IO available. */ -comm_err_t DoSelect(int); +Comm::Flag DoSelect(int); void QuickPollRequired(void); diff --git a/src/comm/Makefile.am b/src/comm/Makefile.am index 45cfc77c9d..e9f8bc3f5d 100644 --- a/src/comm/Makefile.am +++ b/src/comm/Makefile.am @@ -11,6 +11,7 @@ libcomm_la_SOURCES= \ ConnOpener.h \ Connection.cc \ Connection.h \ + Flag.h \ forward.h \ IoCallback.cc \ IoCallback.h \ diff --git a/src/comm/ModDevPoll.cc b/src/comm/ModDevPoll.cc index 72fc173822..944ad53c7f 100644 --- a/src/comm/ModDevPoll.cc +++ b/src/comm/ModDevPoll.cc @@ -336,7 +336,7 @@ Comm::ResetSelect(int fd) * * @param msec milliseconds to poll for (limited by max_poll_time) */ -comm_err_t +Comm::Flag Comm::DoSelect(int msec) { int num, i; @@ -366,7 +366,7 @@ Comm::DoSelect(int msec) /* error during poll */ getCurrentTime(); PROF_stop(comm_check_incoming); - return COMM_ERROR; + return Comm::ERROR; } PROF_stop(comm_check_incoming); @@ -375,7 +375,7 @@ Comm::DoSelect(int msec) statCounter.select_fds_hist.count(num); if (num == 0) - return COMM_TIMEOUT; /* no error */ + return Comm::TIMEOUT; /* no error */ PROF_start(comm_handle_ready_fd); @@ -453,7 +453,7 @@ Comm::DoSelect(int msec) } PROF_stop(comm_handle_ready_fd); - return COMM_OK; + return Comm::OK; } void diff --git a/src/comm/ModEpoll.cc b/src/comm/ModEpoll.cc index d7cb229a64..aac5158990 100644 --- a/src/comm/ModEpoll.cc +++ b/src/comm/ModEpoll.cc @@ -239,7 +239,7 @@ commIncomingStats(StoreEntry * sentry) * comm_setselect and fd_table[] and calls callbacks for IO ready * events. */ -comm_err_t +Comm::Flag Comm::DoSelect(int msec) { int num, i,fd; @@ -267,7 +267,7 @@ Comm::DoSelect(int msec) PROF_stop(comm_check_incoming); - return COMM_ERROR; + return Comm::ERROR; } PROF_stop(comm_check_incoming); @@ -276,7 +276,7 @@ Comm::DoSelect(int msec) statCounter.select_fds_hist.count(num); if (num == 0) - return COMM_TIMEOUT; /* No error.. */ + return Comm::TIMEOUT; /* No error.. */ PROF_start(comm_handle_ready_fd); @@ -323,7 +323,7 @@ Comm::DoSelect(int msec) PROF_stop(comm_handle_ready_fd); - return COMM_OK; + return Comm::OK; } void diff --git a/src/comm/ModKqueue.cc b/src/comm/ModKqueue.cc index b87f5d60ad..0fecd72693 100644 --- a/src/comm/ModKqueue.cc +++ b/src/comm/ModKqueue.cc @@ -242,7 +242,7 @@ Comm::ResetSelect(int fd) * events. */ -comm_err_t +Comm::Flag Comm::DoSelect(int msec) { int num, i; @@ -271,7 +271,7 @@ Comm::DoSelect(int msec) getCurrentTime(); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -279,7 +279,7 @@ Comm::DoSelect(int msec) getCurrentTime(); if (num == 0) - return COMM_OK; /* No error.. */ + return Comm::OK; /* No error.. */ for (i = 0; i < num; ++i) { int fd = (int) ke[i].ident; @@ -313,7 +313,7 @@ Comm::DoSelect(int msec) } } - return COMM_OK; + return Comm::OK; } void diff --git a/src/comm/ModPoll.cc b/src/comm/ModPoll.cc index dd3bd3349f..82e8495288 100644 --- a/src/comm/ModPoll.cc +++ b/src/comm/ModPoll.cc @@ -348,7 +348,7 @@ comm_poll_tcp_incoming(void) } /* poll all sockets; call handlers for those that are ready. */ -comm_err_t +Comm::Flag Comm::DoSelect(int msec) { struct pollfd pfds[SQUID_MAXFD]; @@ -445,7 +445,7 @@ Comm::DoSelect(int msec) assert(errno != EINVAL); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -580,12 +580,12 @@ Comm::DoSelect(int msec) statCounter.select_time += (current_dtime - start); - return COMM_OK; + return Comm::OK; } while (timeout > current_dtime); debugs(5, 8, "comm_poll: time out: " << squid_curtime << "."); - return COMM_TIMEOUT; + return Comm::TIMEOUT; } static void diff --git a/src/comm/ModSelect.cc b/src/comm/ModSelect.cc index 03e04884b0..d02df7ed03 100644 --- a/src/comm/ModSelect.cc +++ b/src/comm/ModSelect.cc @@ -344,7 +344,7 @@ comm_select_tcp_incoming(void) #define DEBUG_FDBITS 0 /* Select on all sockets; call handlers for those that are ready. */ -comm_err_t +Comm::Flag Comm::DoSelect(int msec) { fd_set readfds; @@ -466,7 +466,7 @@ Comm::DoSelect(int msec) examine_select(&readfds, &writefds); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -628,11 +628,11 @@ Comm::DoSelect(int msec) statCounter.select_time += (current_dtime - start); - return COMM_OK; + return Comm::OK; } while (timeout > current_dtime); debugs(5, 8, "comm_select: time out: " << squid_curtime); - return COMM_TIMEOUT; + return Comm::TIMEOUT; } static void diff --git a/src/comm/ModSelectWin32.cc b/src/comm/ModSelectWin32.cc index 1b52dcd39e..5b788923a3 100644 --- a/src/comm/ModSelectWin32.cc +++ b/src/comm/ModSelectWin32.cc @@ -341,7 +341,7 @@ comm_select_tcp_incoming(void) #define DEBUG_FDBITS 0 /* Select on all sockets; call handlers for those that are ready. */ -comm_err_t +Comm::Flag Comm::DoSelect(int msec) { fd_set readfds; @@ -460,7 +460,7 @@ Comm::DoSelect(int msec) examine_select(&readfds, &writefds); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -642,11 +642,11 @@ Comm::DoSelect(int msec) statCounter.select_time += (current_dtime - start); - return COMM_OK; + return Comm::OK; } while (timeout > current_dtime); debugs(5, 8, "comm_select: time out: " << squid_curtime); - return COMM_TIMEOUT; + return Comm::TIMEOUT; } static void diff --git a/src/comm/Read.cc b/src/comm/Read.cc index 558f3be9ce..7e5318813d 100644 --- a/src/comm/Read.cc +++ b/src/comm/Read.cc @@ -70,7 +70,7 @@ comm_read_base(const Comm::ConnectionPointer &conn, char *buf, int size, AsyncCa Comm::SetSelect(conn->fd, COMM_SELECT_READ, Comm::HandleRead, ccb, 0); } -comm_err_t +Comm::Flag Comm::ReadNow(CommIoCbParams ¶ms, SBuf &buf) { /* Attempt a read */ @@ -86,19 +86,19 @@ Comm::ReadNow(CommIoCbParams ¶ms, SBuf &buf) if (retval > 0) { // data read most common case buf.append(theBuf, retval); fd_bytes(params.conn->fd, retval, FD_READ); - params.flag = COMM_OK; + params.flag = Comm::OK; params.size = retval; } else if (retval == 0) { // remote closure (somewhat less) common // Note - read 0 == socket EOF, which is a valid read. - params.flag = COMM_EOF; + params.flag = Comm::ENDFILE; } else if (retval < 0) { // connection errors are worst-case - debugs(5, 3, params.conn << " COMM_ERROR: " << xstrerr(params.xerrno)); + debugs(5, 3, params.conn << " Comm::ERROR: " << xstrerr(params.xerrno)); if (ignoreErrno(params.xerrno)) - params.flag = COMM_INPROGRESS; + params.flag = Comm::INPROGRESS; else - params.flag = COMM_ERROR; + params.flag = Comm::ERROR; } return params.flag; @@ -123,7 +123,7 @@ Comm::HandleRead(int fd, void *data) // without a buffer, just call back if (!ccb->buf) { - ccb->finish(COMM_OK, 0); + ccb->finish(Comm::OK, 0); return; } @@ -139,13 +139,13 @@ Comm::HandleRead(int fd, void *data) if (retval >= 0) { fd_bytes(fd, retval, FD_READ); ccb->offset = retval; - ccb->finish(COMM_OK, errno); + ccb->finish(Comm::OK, errno); return; } else if (retval < 0 && !ignoreErrno(errno)) { - debugs(5, 3, "comm_read_try: scheduling COMM_ERROR"); + debugs(5, 3, "comm_read_try: scheduling Comm::ERROR"); ccb->offset = 0; - ccb->finish(COMM_ERROR, errno); + ccb->finish(Comm::ERROR, errno); return; }; diff --git a/src/comm/Read.h b/src/comm/Read.h index 69de56cc29..99d78c43c6 100644 --- a/src/comm/Read.h +++ b/src/comm/Read.h @@ -26,13 +26,13 @@ bool MonitorsRead(int fd); * * The returned flag is also placed in params.flag. * - * \retval COMM_OK data has been read and placed in buf, amount in params.size - * \retval COMM_ERROR an error occured, the code is placed in params.xerrno - * \retval COMM_INPROGRESS unable to read at this time, or a minor error occured - * \retval COMM_ERR_CLOSING 0-byte read has occured. + * \retval Comm::OK data has been read and placed in buf, amount in params.size + * \retval Comm::ERROR an error occured, the code is placed in params.xerrno + * \retval Comm::INPROGRESS unable to read at this time, or a minor error occured + * \retval Comm::ERR_CLOSING 0-byte read has occured. * Usually indicates the remote end has disconnected. */ -comm_err_t ReadNow(CommIoCbParams ¶ms, SBuf &buf); +Comm::Flag ReadNow(CommIoCbParams ¶ms, SBuf &buf); /// Cancel the read pending on FD. No action if none pending. void ReadCancel(int fd, AsyncCall::Pointer &callback); diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index 85e3d0ec8b..a5bc13690c 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -261,12 +261,12 @@ Comm::TcpAcceptor::acceptOne() /* Accept a new connection */ ConnectionPointer newConnDetails = new Connection(); - const comm_err_t flag = oldAccept(newConnDetails); + const Comm::Flag flag = oldAccept(newConnDetails); /* Check for errors */ if (!newConnDetails->isOpen()) { - if (flag == COMM_NOMESSAGE) { + if (flag == Comm::NOMESSAGE) { /* register interest again */ debugs(5, 5, HERE << "try later: " << conn << " handler Subscription: " << theCallSub); SetSelect(conn->fd, COMM_SELECT_READ, doAccept, this, 0); @@ -295,11 +295,11 @@ Comm::TcpAcceptor::acceptNext() } void -Comm::TcpAcceptor::notify(const comm_err_t flag, const Comm::ConnectionPointer &newConnDetails) const +Comm::TcpAcceptor::notify(const Comm::Flag flag, const Comm::ConnectionPointer &newConnDetails) const { - // listener socket handlers just abandon the port with COMM_ERR_CLOSING + // listener socket handlers just abandon the port with Comm::ERR_CLOSING // it should only happen when this object is deleted... - if (flag == COMM_ERR_CLOSING) { + if (flag == Comm::ERR_CLOSING) { return; } @@ -320,12 +320,12 @@ Comm::TcpAcceptor::notify(const comm_err_t flag, const Comm::ConnectionPointer & * accept() and process * Wait for an incoming connection on our listener socket. * - * \retval COMM_OK success. details parameter filled. - * \retval COMM_NOMESSAGE attempted accept() but nothing useful came in. - * \retval COMM_ERROR an outright failure occured. + * \retval Comm::OK success. details parameter filled. + * \retval Comm::NOMESSAGE attempted accept() but nothing useful came in. + * \retval Comm::ERROR an outright failure occured. * Or if this client has too many connections already. */ -comm_err_t +Comm::Flag Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) { PROF_start(comm_accept); @@ -344,13 +344,13 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) if (ignoreErrno(errno)) { debugs(50, 5, HERE << status() << ": " << xstrerror()); - return COMM_NOMESSAGE; + return Comm::NOMESSAGE; } else if (ENFILE == errno || EMFILE == errno) { debugs(50, 3, HERE << status() << ": " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } else { debugs(50, DBG_IMPORTANT, HERE << status() << ": " << xstrerror()); - return COMM_ERROR; + return Comm::ERROR; } } @@ -362,7 +362,7 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) if (clientdbEstablished(details->remote, 0) > Config.client_ip_max_connections) { debugs(50, DBG_IMPORTANT, "WARNING: " << details->remote << " attempting more than " << Config.client_ip_max_connections << " connections."); Ip::Address::FreeAddrInfo(gai); - return COMM_ERROR; + return Comm::ERROR; } } @@ -372,7 +372,7 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) if (getsockname(sock, gai->ai_addr, &gai->ai_addrlen) != 0) { debugs(50, DBG_IMPORTANT, "ERROR: getsockname() failed to locate local-IP on " << details << ": " << xstrerror()); Ip::Address::FreeAddrInfo(gai); - return COMM_ERROR; + return Comm::ERROR; } details->local = *gai; Ip::Address::FreeAddrInfo(gai); @@ -401,7 +401,7 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) // Perform NAT or TPROXY operations to retrieve the real client/dest IP addresses if (conn->flags&(COMM_TRANSPARENT|COMM_INTERCEPTION) && !Ip::Interceptor.Lookup(details, conn)) { // Failed. - return COMM_ERROR; + return Comm::ERROR; } #if USE_SQUID_EUI @@ -415,5 +415,5 @@ Comm::TcpAcceptor::oldAccept(Comm::ConnectionPointer &details) #endif PROF_stop(comm_accept); - return COMM_OK; + return Comm::OK; } diff --git a/src/comm/TcpAcceptor.h b/src/comm/TcpAcceptor.h index 4ab9e9e309..abffacb7f0 100644 --- a/src/comm/TcpAcceptor.h +++ b/src/comm/TcpAcceptor.h @@ -4,8 +4,8 @@ #include "base/AsyncJob.h" #include "base/CbcPointer.h" #include "base/Subscription.h" +#include "comm/Flag.h" #include "comm/forward.h" -#include "comm_err_t.h" class CommCloseCbParams; @@ -59,7 +59,7 @@ public: void acceptNext(); /// Call the subscribed callback handler with details about a new connection. - void notify(const comm_err_t flag, const Comm::ConnectionPointer &details) const; + void notify(const Comm::Flag flag, const Comm::ConnectionPointer &details) const; /// errno code of the last accept() or listen() action if one occurred. int errcode; @@ -86,7 +86,7 @@ private: static void doAccept(int fd, void *data); void acceptOne(); - comm_err_t oldAccept(Comm::ConnectionPointer &details); + Comm::Flag oldAccept(Comm::ConnectionPointer &details); void setListen(); void handleClosure(const CommCloseCbParams &io); diff --git a/src/comm/Write.cc b/src/comm/Write.cc index 04bed7cd91..436302aa11 100644 --- a/src/comm/Write.cc +++ b/src/comm/Write.cc @@ -125,18 +125,18 @@ Comm::HandleWrite(int fd, void *data) if (nleft != 0) debugs(5, DBG_IMPORTANT, "FD " << fd << " write failure: connection closed with " << nleft << " bytes remaining."); - state->finish(nleft ? COMM_ERROR : COMM_OK, errno); + state->finish(nleft ? Comm::ERROR : Comm::OK, errno); } else if (len < 0) { /* An error */ if (fd_table[fd].flags.socket_eof) { debugs(50, 2, HERE << "FD " << fd << " write failure: " << xstrerror() << "."); - state->finish(nleft ? COMM_ERROR : COMM_OK, errno); + state->finish(nleft ? Comm::ERROR : Comm::OK, errno); } else if (ignoreErrno(errno)) { debugs(50, 9, HERE << "FD " << fd << " write failure: " << xstrerror() << "."); state->selectOrQueueWrite(); } else { debugs(50, 2, HERE << "FD " << fd << " write failure: " << xstrerror() << "."); - state->finish(nleft ? COMM_ERROR : COMM_OK, errno); + state->finish(nleft ? Comm::ERROR : Comm::OK, errno); } } else { /* A successful write, continue */ @@ -146,7 +146,7 @@ Comm::HandleWrite(int fd, void *data) /* Not done, reinstall the write handler and write some more */ state->selectOrQueueWrite(); } else { - state->finish(nleft ? COMM_OK : COMM_ERROR, errno); + state->finish(nleft ? Comm::OK : Comm::ERROR, errno); } } diff --git a/src/comm/comm_err_t.h b/src/comm/comm_err_t.h deleted file mode 100644 index 88148569ac..0000000000 --- a/src/comm/comm_err_t.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _SQUID_COMM_COMM_ERR_T_H -#define _SQUID_COMM_COMM_ERR_T_H - -typedef enum { - COMM_OK = 0, - COMM_ERROR = -1, - COMM_NOMESSAGE = -3, - COMM_TIMEOUT = -4, - COMM_SHUTDOWN = -5, - COMM_IDLE = -6, /* there are no active fds and no pending callbacks. */ - COMM_INPROGRESS = -7, - COMM_ERR_CONNECT = -8, - COMM_ERR_DNS = -9, - COMM_ERR_CLOSING = -10, - COMM_ERR_PROTOCOL = -11, /* IPv4 or IPv6 cannot be used on the fd socket */ - COMM_EOF = -12, /**< read(2) returned success, but with 0 bytes */ - COMM_ERR__END__ = -999999 /* Dummy entry to make syntax valid (comma on line above), do not use. New entries added above */ -} comm_err_t; - -#endif /* _SQUID_COMM_COMM_ERR_T_H */ diff --git a/src/comm_err_t.h b/src/comm_err_t.h deleted file mode 100644 index 1b22d3bbfc..0000000000 --- a/src/comm_err_t.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _SQUID_COMM_COMM_ERR_T_H -#define _SQUID_COMM_COMM_ERR_T_H - -typedef enum { - COMM_OK = 0, - COMM_ERROR = -1, - COMM_NOMESSAGE = -3, - COMM_TIMEOUT = -4, - COMM_SHUTDOWN = -5, - COMM_IDLE = -6, /* there are no active fds and no pending callbacks. */ - COMM_INPROGRESS = -7, - COMM_ERR_CONNECT = -8, - COMM_ERR_DNS = -9, - COMM_ERR_CLOSING = -10, - COMM_ERR_PROTOCOL = -11, /* IPv4 or IPv6 cannot be used on the fd socket */ - COMM_ERR__END__ = -999999 /* Dummy entry to make syntax valid (comma on line above), do not use. New entries added above */ -} comm_err_t; - -#endif /* _SQUID_COMM_COMM_ERR_T_H */ diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 3cca775949..1088ec02ac 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -796,18 +796,18 @@ idnsTickleQueue(void) } static void -idnsSentQueryVC(const Comm::ConnectionPointer &conn, char *buf, size_t size, comm_err_t flag, int xerrno, void *data) +idnsSentQueryVC(const Comm::ConnectionPointer &conn, char *buf, size_t size, Comm::Flag flag, int xerrno, void *data) { nsvc * vc = (nsvc *)data; - if (flag == COMM_ERR_CLOSING) + if (flag == Comm::ERR_CLOSING) return; // XXX: irrelevant now that we have conn pointer? if (!Comm::IsConnOpen(conn) || fd_table[conn->fd].closing()) return; - if (flag != COMM_OK || size <= 0) { + if (flag != Comm::OK || size <= 0) { conn->close(); return; } @@ -850,11 +850,11 @@ idnsDoSendQueryVC(nsvc *vc) } static void -idnsInitVCConnected(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data) +idnsInitVCConnected(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data) { nsvc * vc = (nsvc *)data; - if (status != COMM_OK || !conn) { + if (status != Comm::OK || !conn) { char buf[MAX_IPSTRLEN] = ""; if (vc->ns < nns) nameservers[vc->ns].S.toStr(buf,MAX_IPSTRLEN); @@ -1438,14 +1438,14 @@ idnsCheckQueue(void *unused) } static void -idnsReadVC(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +idnsReadVC(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { nsvc * vc = (nsvc *)data; - if (flag == COMM_ERR_CLOSING) + if (flag == Comm::ERR_CLOSING) return; - if (flag != COMM_OK || len <= 0) { + if (flag != Comm::OK || len <= 0) { if (Comm::IsConnOpen(conn)) conn->close(); return; @@ -1471,14 +1471,14 @@ idnsReadVC(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_ } static void -idnsReadVCHeader(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +idnsReadVCHeader(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { nsvc * vc = (nsvc *)data; - if (flag == COMM_ERR_CLOSING) + if (flag == Comm::ERR_CLOSING) return; - if (flag != COMM_OK || len <= 0) { + if (flag != Comm::OK || len <= 0) { if (Comm::IsConnOpen(conn)) conn->close(); return; diff --git a/src/errorpage.cc b/src/errorpage.cc index c355e90efb..da889df245 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -682,12 +682,12 @@ errorSend(const Comm::ConnectionPointer &conn, ErrorState * err) * closing the FD, otherwise we do it ourselves. */ static void -errorSendComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag, int xerrno, void *data) +errorSendComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, Comm::Flag errflag, int xerrno, void *data) { ErrorState *err = static_cast(data); debugs(4, 3, HERE << conn << ", size=" << size); - if (errflag != COMM_ERR_CLOSING) { + if (errflag != Comm::ERR_CLOSING) { if (err->callback) { debugs(4, 3, "errorSendComplete: callback"); err->callback(conn->fd, err->callback_data, size); diff --git a/src/ftp.cc b/src/ftp.cc index 172d371d9c..d7006ffd60 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1241,7 +1241,7 @@ FtpStateData::dataRead(const CommIoCbParams &io) kb_incr(&(statCounter.server.ftp.kbytes_in), io.size); } - if (io.flag == COMM_ERR_CLOSING) + if (io.flag == Comm::ERR_CLOSING) return; assert(io.fd == data.conn->fd); @@ -1251,7 +1251,7 @@ FtpStateData::dataRead(const CommIoCbParams &io) return; } - if (io.flag == COMM_OK && io.size > 0) { + if (io.flag == Comm::OK && io.size > 0) { debugs(9,5,HERE << "appended " << io.size << " bytes to readBuf"); data.readBuf->appended(io.size); #if USE_DELAY_POOLS @@ -1266,7 +1266,7 @@ FtpStateData::dataRead(const CommIoCbParams &io) ++ IOStats.Ftp.read_hist[bin]; } - if (io.flag != COMM_OK) { + if (io.flag != Comm::OK) { debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT, "ftpDataRead: read error: " << xstrerr(io.xerrno)); @@ -1601,7 +1601,7 @@ FtpStateData::ftpWriteCommandCallback(const CommIoCbParams &io) kb_incr(&(statCounter.server.ftp.kbytes_out), io.size); } - if (io.flag == COMM_ERR_CLOSING) + if (io.flag == Comm::ERR_CLOSING) return; if (io.flag) { @@ -1742,7 +1742,7 @@ void FtpStateData::ftpReadControlReply(const CommIoCbParams &io) kb_incr(&(statCounter.server.ftp.kbytes_in), io.size); } - if (io.flag == COMM_ERR_CLOSING) + if (io.flag == Comm::ERR_CLOSING) return; if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { @@ -1752,11 +1752,11 @@ void FtpStateData::ftpReadControlReply(const CommIoCbParams &io) assert(ctrl.offset < ctrl.size); - if (io.flag == COMM_OK && io.size > 0) { + if (io.flag == Comm::OK && io.size > 0) { fd_bytes(io.fd, io.size, FD_READ); } - if (io.flag != COMM_OK) { + if (io.flag != Comm::OK) { debugs(50, ignoreErrno(io.xerrno) ? 3 : DBG_IMPORTANT, "ftpReadControlReply: read error: " << xstrerr(io.xerrno)); @@ -2733,17 +2733,17 @@ ftpReadPasv(FtpStateData * ftpState) } void -FtpStateData::ftpPasvCallback(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data) +FtpStateData::ftpPasvCallback(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data) { FtpStateData *ftpState = (FtpStateData *)data; debugs(9, 3, HERE); ftpState->data.opener = NULL; - if (status != COMM_OK) { + if (status != Comm::OK) { debugs(9, 2, HERE << "Failed to connect. Retrying via another method."); // ABORT on timeouts. server may be waiting on a broken TCP link. - if (status == COMM_TIMEOUT) + if (status == Comm::TIMEOUT) ftpState->writeCommand("ABOR"); // try another connection attempt with some other method @@ -2931,7 +2931,7 @@ FtpStateData::ftpAcceptDataConnection(const CommAcceptCbParams &io) return; } - if (io.flag != COMM_OK) { + if (io.flag != Comm::OK) { data.listenConn->close(); data.listenConn = NULL; debugs(9, DBG_IMPORTANT, "FTP AcceptDataConnection: " << io.conn << ": " << xstrerr(io.xerrno)); @@ -2974,7 +2974,7 @@ FtpStateData::ftpAcceptDataConnection(const CommAcceptCbParams &io) } } - /** On COMM_OK start using the accepted data socket and discard the temporary listen socket. */ + /** On Comm::OK start using the accepted data socket and discard the temporary listen socket. */ data.close(); data.opened(io.conn, dataCloser()); static char ntoapeer[MAX_IPSTRLEN]; diff --git a/src/gopher.cc b/src/gopher.cc index c72039ec5c..13637dbd9d 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -739,7 +739,7 @@ gopherTimeout(const CommTimeoutCbParams &io) * Read until error or connection closed. */ static void -gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { GopherStateData *gopherState = (GopherStateData *)data; StoreEntry *entry = gopherState->entry; @@ -750,9 +750,9 @@ gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm DelayId delayId = entry->mem_obj->mostBytesAllowed(); #endif - /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */ + /* Bail out early on Comm::ERR_CLOSING - close handlers will tidy up for us */ - if (flag == COMM_ERR_CLOSING) { + if (flag == Comm::ERR_CLOSING) { return; } @@ -769,7 +769,7 @@ gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm /* leave one space for \0 in gopherToHTML */ - if (flag == COMM_OK && len > 0) { + if (flag == Comm::OK && len > 0) { #if USE_DELAY_POOLS delayId.bytesIn(len); #endif @@ -780,7 +780,7 @@ gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm debugs(10, 5, HERE << conn << " read len=" << len); - if (flag == COMM_OK && len > 0) { + if (flag == Comm::OK && len > 0) { AsyncCall::Pointer nil; commSetConnTimeout(conn, Config.Timeout.read, nil); ++IOStats.Gopher.reads; @@ -797,7 +797,7 @@ gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm req->hier.bodyBytesRead += len; } - if (flag != COMM_OK) { + if (flag != Comm::OK) { debugs(50, DBG_IMPORTANT, "gopherReadReply: error reading: " << xstrerror()); if (ignoreErrno(xerrno)) { @@ -841,7 +841,7 @@ gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm * This will be called when request write is complete. Schedule read of reply. */ static void -gopherSendComplete(const Comm::ConnectionPointer &conn, char *buf, size_t size, comm_err_t errflag, int xerrno, void *data) +gopherSendComplete(const Comm::ConnectionPointer &conn, char *buf, size_t size, Comm::Flag errflag, int xerrno, void *data) { GopherStateData *gopherState = (GopherStateData *) data; StoreEntry *entry = gopherState->entry; diff --git a/src/helper.cc b/src/helper.cc index 04bc003bc6..298090ab98 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -887,16 +887,16 @@ helperReturnBuffer(int request_number, helper_server * srv, helper * hlp, char * } static void -helperHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +helperHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { char *t = NULL; helper_server *srv = (helper_server *)data; helper *hlp = srv->parent; assert(cbdataReferenceValid(data)); - /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */ + /* Bail out early on Comm::ERR_CLOSING - close handlers will tidy up for us */ - if (flag == COMM_ERR_CLOSING) { + if (flag == Comm::ERR_CLOSING) { return; } @@ -904,7 +904,7 @@ helperHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, com debugs(84, 5, "helperHandleRead: " << len << " bytes from " << hlp->id_name << " #" << srv->index); - if (flag != COMM_OK || len == 0) { + if (flag != Comm::OK || len == 0) { srv->closePipesSafely(); return; } @@ -981,7 +981,7 @@ helperHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, com } static void -helperStatefulHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +helperStatefulHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { char *t = NULL; helper_stateful_server *srv = (helper_stateful_server *)data; @@ -989,9 +989,9 @@ helperStatefulHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t statefulhelper *hlp = srv->parent; assert(cbdataReferenceValid(data)); - /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */ + /* Bail out early on Comm::ERR_CLOSING - close handlers will tidy up for us */ - if (flag == COMM_ERR_CLOSING) { + if (flag == Comm::ERR_CLOSING) { return; } @@ -1000,7 +1000,7 @@ helperStatefulHandleRead(const Comm::ConnectionPointer &conn, char *buf, size_t debugs(84, 5, "helperStatefulHandleRead: " << len << " bytes from " << hlp->id_name << " #" << srv->index); - if (flag != COMM_OK || len == 0) { + if (flag != Comm::OK || len == 0) { srv->closePipesSafely(); return; } @@ -1279,7 +1279,7 @@ StatefulGetFirstAvailable(statefulhelper * hlp) } static void -helperDispatchWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +helperDispatchWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { helper_server *srv = (helper_server *)data; @@ -1288,7 +1288,7 @@ helperDispatchWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t l srv->writebuf = NULL; srv->flags.writing = false; - if (flag != COMM_OK) { + if (flag != Comm::OK) { /* Helper server has crashed */ debugs(84, DBG_CRITICAL, "helperDispatch: Helper " << srv->parent->id_name << " #" << srv->index << " has crashed"); return; @@ -1354,7 +1354,7 @@ helperDispatch(helper_server * srv, helper_request * r) } static void -helperStatefulDispatchWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, +helperStatefulDispatchWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { /* nothing! */ diff --git a/src/http.cc b/src/http.cc index 90e5229a0a..04bb1ef385 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1127,7 +1127,7 @@ HttpStateData::persistentConnStatus() const */ /* void -HttpStateData::ReadReplyWrapper(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +HttpStateData::ReadReplyWrapper(int fd, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { HttpStateData *httpState = static_cast(data); assert (fd == httpState->serverConnection->fd); @@ -1150,8 +1150,8 @@ HttpStateData::readReply(const CommIoCbParams &io) debugs(11, 5, HERE << io.conn << ": len " << len << "."); - // Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us - if (io.flag == COMM_ERR_CLOSING) { + // Bail out early on Comm::ERR_CLOSING - close handlers will tidy up for us + if (io.flag == Comm::ERR_CLOSING) { debugs(11, 3, "http socket closing"); return; } @@ -1162,7 +1162,7 @@ HttpStateData::readReply(const CommIoCbParams &io) } // handle I/O errors - if (io.flag != COMM_OK || len < 0) { + if (io.flag != Comm::OK || len < 0) { debugs(11, 2, HERE << io.conn << ": read failure: " << xstrerror() << "."); if (ignoreErrno(io.xerrno)) { @@ -1543,7 +1543,7 @@ HttpStateData::wroteLast(const CommIoCbParams &io) kb_incr(&(statCounter.server.http.kbytes_out), io.size); } - if (io.flag == COMM_ERR_CLOSING) + if (io.flag == Comm::ERR_CLOSING) return; if (io.flag) { diff --git a/src/ident/Ident.cc b/src/ident/Ident.cc index 064d52ac22..3217fe0659 100644 --- a/src/ident/Ident.cc +++ b/src/ident/Ident.cc @@ -119,12 +119,12 @@ Ident::Timeout(const CommTimeoutCbParams &io) } void -Ident::ConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data) +Ident::ConnectDone(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data) { IdentStateData *state = (IdentStateData *)data; - if (status != COMM_OK) { - if (status == COMM_TIMEOUT) { + if (status != Comm::OK) { + if (status == Comm::TIMEOUT) { debugs(30, 3, "IDENT connection timeout to " << state->conn->remote); } return; @@ -161,19 +161,19 @@ Ident::ConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int x } void -Ident::WriteFeedback(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +Ident::WriteFeedback(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { debugs(30, 5, HERE << conn << ": Wrote IDENT request " << len << " bytes."); // TODO handle write errors better. retry or abort? - if (flag != COMM_OK) { + if (flag != Comm::OK) { debugs(30, 2, HERE << conn << " err-flags=" << flag << " IDENT write error: " << xstrerr(xerrno)); conn->close(); } } void -Ident::ReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +Ident::ReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { IdentStateData *state = (IdentStateData *)data; char *ident = NULL; @@ -182,7 +182,7 @@ Ident::ReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, com assert(buf == state->buf); assert(conn->fd == state->conn->fd); - if (flag != COMM_OK || len <= 0) { + if (flag != Comm::OK || len <= 0) { state->conn->close(); return; } diff --git a/src/ipc.cc b/src/ipc.cc index 94e611ec86..93874697b5 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -262,7 +262,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name cwfd = crfd = -1; if (type == IPC_TCP_SOCKET || type == IPC_UDP_SOCKET) { - if (comm_connect_addr(pwfd, ChS) == COMM_ERROR) + if (comm_connect_addr(pwfd, ChS) == Comm::ERROR) return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } @@ -334,7 +334,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name close(crfd); cwfd = crfd = fd; } else if (type == IPC_UDP_SOCKET) { - if (comm_connect_addr(crfd, PaS) == COMM_ERROR) + if (comm_connect_addr(crfd, PaS) == Comm::ERROR) return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } diff --git a/src/ipc/Port.cc b/src/ipc/Port.cc index 79d8820b6d..1d8029cc2f 100644 --- a/src/ipc/Port.cc +++ b/src/ipc/Port.cc @@ -71,7 +71,7 @@ void Ipc::Port::noteRead(const CommIoCbParams& params) { debugs(54, 6, HERE << params.conn << " flag " << params.flag << " [" << this << ']'); - if (params.flag == COMM_OK) { + if (params.flag == Comm::OK) { assert(params.buf == buf.raw()); receive(buf); } diff --git a/src/ipc/UdsOp.cc b/src/ipc/UdsOp.cc index 7448ebc4b1..5393dd2ce7 100644 --- a/src/ipc/UdsOp.cc +++ b/src/ipc/UdsOp.cc @@ -123,7 +123,7 @@ void Ipc::UdsSender::wrote(const CommIoCbParams& params) { debugs(54, 5, HERE << params.conn << " flag " << params.flag << " retries " << retries << " [" << this << ']'); writing = false; - if (params.flag != COMM_OK && retries-- > 0) { + if (params.flag != Comm::OK && retries-- > 0) { // perhaps a fresh connection and more time will help? conn()->close(); startSleep(); diff --git a/src/ipc_win32.cc b/src/ipc_win32.cc index c84e51724d..f76d57bafa 100644 --- a/src/ipc_win32.cc +++ b/src/ipc_win32.cc @@ -263,7 +263,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name } /* NP: tmp_addr was left with eiether empty or aiCS in Ip::Address format */ - if (comm_connect_addr(pwfd, tmp_addr) == COMM_ERROR) { + if (comm_connect_addr(pwfd, tmp_addr) == Comm::ERROR) { CloseHandle((HANDLE) thread); return ipcCloseAllFD(prfd, pwfd, -1, -1); } @@ -425,7 +425,7 @@ ipc_thread_1(void *in_params) fd_table[fd].flags.ipc = 1; cwfd = crfd = fd; } else if (type == IPC_UDP_SOCKET) { - if (comm_connect_addr(crfd, params->PS) == COMM_ERROR) + if (comm_connect_addr(crfd, params->PS) == Comm::ERROR) goto cleanup; } @@ -512,14 +512,14 @@ ipc_thread_1(void *in_params) debugs(54, 3, "ipcCreate: FD " << crfd_ipc << " sockaddr " << CS_ipc); - if (comm_connect_addr(pwfd_ipc, CS_ipc) == COMM_ERROR) { + if (comm_connect_addr(pwfd_ipc, CS_ipc) == Comm::ERROR) { ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } fd = crfd; - if (comm_connect_addr(crfd_ipc, PS_ipc) == COMM_ERROR) { + if (comm_connect_addr(crfd_ipc, PS_ipc) == Comm::ERROR) { ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } diff --git a/src/log/TcpLogger.cc b/src/log/TcpLogger.cc index 52593f3ed4..cd539b4d96 100644 --- a/src/log/TcpLogger.cc +++ b/src/log/TcpLogger.cc @@ -254,7 +254,7 @@ Log::TcpLogger::connect() void Log::TcpLogger::connectDone(const CommConnectCbParams ¶ms) { - if (params.flag != COMM_OK) { + if (params.flag != Comm::OK) { const double delay = 0.5; // seconds if (connectFailures++ % 100 == 0) { debugs(MY_DEBUG_SECTION, DBG_IMPORTANT, "tcp:" << remote << @@ -321,10 +321,10 @@ void Log::TcpLogger::writeDone(const CommIoCbParams &io) { writeScheduled = false; - if (io.flag == COMM_ERR_CLOSING) { + if (io.flag == Comm::ERR_CLOSING) { debugs(MY_DEBUG_SECTION, 7, "closing"); // do nothing here -- our comm_close_handler will be called to clean up - } else if (io.flag != COMM_OK) { + } else if (io.flag != Comm::OK) { debugs(MY_DEBUG_SECTION, 2, "write failure: " << xstrerr(io.xerrno)); // keep the first buffer (the one we failed to write) disconnect(); diff --git a/src/mgr/Inquirer.cc b/src/mgr/Inquirer.cc index 9eb412dea6..57c7e9dbe5 100644 --- a/src/mgr/Inquirer.cc +++ b/src/mgr/Inquirer.cc @@ -104,7 +104,7 @@ Mgr::Inquirer::noteWroteHeader(const CommIoCbParams& params) { debugs(16, 5, HERE); writer = NULL; - Must(params.flag == COMM_OK); + Must(params.flag == Comm::OK); Must(params.conn.getRaw() == conn.getRaw()); Must(params.size != 0); // start inquiries at the initial pos diff --git a/src/mgr/StoreToCommWriter.cc b/src/mgr/StoreToCommWriter.cc index 00f9226c3c..cb7f5e7f86 100644 --- a/src/mgr/StoreToCommWriter.cc +++ b/src/mgr/StoreToCommWriter.cc @@ -112,7 +112,7 @@ void Mgr::StoreToCommWriter::noteCommWrote(const CommIoCbParams& params) { debugs(16, 6, HERE); - Must(params.flag == COMM_OK); + Must(params.flag == Comm::OK); Must(clientConnection != NULL && params.fd == clientConnection->fd); Must(params.size != 0); writeOffset += params.size; diff --git a/src/neighbors.cc b/src/neighbors.cc index c8ee2cba8d..e7c5f98d5a 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1375,11 +1375,11 @@ peerProbeConnect(CachePeer * p) } static void -peerProbeConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data) +peerProbeConnectDone(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data) { CachePeer *p = (CachePeer*)data; - if (status == COMM_OK) { + if (status == Comm::OK) { peerConnectSucceded(p); } else { peerConnectFailedSilent(p); diff --git a/src/pconn.cc b/src/pconn.cc index 4d115612b2..7ca63fa3ff 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -311,13 +311,13 @@ IdleConnList::findAndClose(const Comm::ConnectionPointer &conn) } void -IdleConnList::Read(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +IdleConnList::Read(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { debugs(48, 3, HERE << len << " bytes from " << conn); - if (flag == COMM_ERR_CLOSING) { - debugs(48, 3, HERE << "COMM_ERR_CLOSING from " << conn); - /* Bail out on COMM_ERR_CLOSING - may happen when shutdown aborts our idle FD */ + if (flag == Comm::ERR_CLOSING) { + debugs(48, 3, HERE << "Comm::ERR_CLOSING from " << conn); + /* Bail out on Comm::ERR_CLOSING - may happen when shutdown aborts our idle FD */ return; } diff --git a/src/tests/stub_client_side.cc b/src/tests/stub_client_side.cc index 662be12ea6..5aff3910f4 100644 --- a/src/tests/stub_client_side.cc +++ b/src/tests/stub_client_side.cc @@ -7,7 +7,7 @@ //ClientSocketContext::ClientSocketContext(const ConnectionPointer&, ClientHttpRequest*) STUB //ClientSocketContext::~ClientSocketContext() STUB bool ClientSocketContext::startOfOutput() const STUB_RETVAL(false) -void ClientSocketContext::writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag) STUB +void ClientSocketContext::writeComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, Comm::Flag errflag) STUB void ClientSocketContext::keepaliveNextRequest() STUB void ClientSocketContext::pullData() STUB int64_t ClientSocketContext::getNextRangeOffset() const STUB_RETVAL(0) diff --git a/src/tests/stub_comm.cc b/src/tests/stub_comm.cc index c1760c2209..57216f1c8b 100644 --- a/src/tests/stub_comm.cc +++ b/src/tests/stub_comm.cc @@ -55,7 +55,7 @@ void commSetCloseOnExec(int fd) STUB_NOP int ignoreErrno(int ierrno) STUB_RETVAL(-1) void commUnsetFdTimeout(int fd) STUB -int commSetNonBlocking(int fd) STUB_RETVAL(COMM_ERROR) +int commSetNonBlocking(int fd) STUB_RETVAL(Comm::ERROR) int commUnsetNonBlocking(int fd) STUB_RETVAL(-1) // MinGW needs also a stub of _comm_close() diff --git a/src/tests/stub_libcomm.cc b/src/tests/stub_libcomm.cc index f31768877d..d86ea86bd0 100644 --- a/src/tests/stub_libcomm.cc +++ b/src/tests/stub_libcomm.cc @@ -36,7 +36,7 @@ Comm::ConnOpener::ConnOpener(Comm::ConnectionPointer &, AsyncCall::Pointer &, ti void Comm::IoCallback::setCallback(iocb_type, AsyncCall::Pointer &, char *, FREE *, int) STUB void Comm::IoCallback::selectOrQueueWrite() STUB void Comm::IoCallback::cancel(const char *reason) STUB - void Comm::IoCallback::finish(comm_err_t code, int xerrn) STUB + void Comm::IoCallback::finish(Comm::Flag code, int xerrn) STUB Comm::CbEntry *Comm::iocb_table = NULL; void Comm::CallbackTableInit() STUB void Comm::CallbackTableDestruct() STUB @@ -45,13 +45,13 @@ void Comm::CallbackTableDestruct() STUB void Comm::SelectLoopInit(void) STUB void Comm::SetSelect(int, unsigned int, PF *, void *, time_t) STUB void Comm::ResetSelect(int) STUB -comm_err_t Comm::DoSelect(int) STUB_RETVAL(COMM_ERROR) +Comm::Flag Comm::DoSelect(int) STUB_RETVAL(Comm::ERROR) void Comm::QuickPollRequired(void) STUB #include "comm/Read.h" void Comm::Read(const Comm::ConnectionPointer &conn, AsyncCall::Pointer &callback) STUB bool Comm::MonitorsRead(int fd) STUB_RETVAL(false) -comm_err_t Comm::ReadNow(CommIoCbParams ¶ms, SBuf &buf) STUB_RETVAL(COMM_ERROR) +Comm::Flag Comm::ReadNow(CommIoCbParams ¶ms, SBuf &buf) STUB_RETVAL(Comm::ERROR) void Comm::ReadCancel(int fd, AsyncCall::Pointer &callback) STUB //void Comm::HandleRead(int, void*) STUB @@ -63,7 +63,7 @@ void comm_read_cancel(int fd, IOCB *callback, void *data) STUB void Comm::TcpAcceptor::subscribe(const Subscription::Pointer &aSub) STUB void Comm::TcpAcceptor::unsubscribe(const char *) STUB void Comm::TcpAcceptor::acceptNext() STUB -void Comm::TcpAcceptor::notify(const comm_err_t flag, const Comm::ConnectionPointer &) const STUB +void Comm::TcpAcceptor::notify(const Comm::Flag flag, const Comm::ConnectionPointer &) const STUB #include "comm/Write.h" void Comm::Write(const Comm::ConnectionPointer &, const char *, int, AsyncCall::Pointer &, FREE *) STUB diff --git a/src/tunnel.cc b/src/tunnel.cc index 08228155ee..e712a6ba55 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -88,10 +88,10 @@ public: TunnelStateData &operator =(const TunnelStateData &); // do not implement class Connection; - static void ReadClient(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t errcode, int xerrno, void *data); - static void ReadServer(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t errcode, int xerrno, void *data); - static void WriteClientDone(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t flag, int xerrno, void *data); - static void WriteServerDone(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t flag, int xerrno, void *data); + static void ReadClient(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data); + static void ReadServer(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data); + static void WriteClientDone(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data); + static void WriteServerDone(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data); /// Starts reading peer response to our CONNECT request. void readConnectResponse(); @@ -200,16 +200,16 @@ private: #endif CBDATA_CLASS2(TunnelStateData); - bool keepGoingAfterRead(size_t len, comm_err_t errcode, int xerrno, Connection &from, Connection &to); + bool keepGoingAfterRead(size_t len, Comm::Flag errcode, int xerrno, Connection &from, Connection &to); void copy(size_t len, Connection &from, Connection &to, IOCB *); void handleConnectResponse(const size_t chunkSize); - void readServer(char *buf, size_t len, comm_err_t errcode, int xerrno); - void readClient(char *buf, size_t len, comm_err_t errcode, int xerrno); - void writeClientDone(char *buf, size_t len, comm_err_t flag, int xerrno); - void writeServerDone(char *buf, size_t len, comm_err_t flag, int xerrno); + void readServer(char *buf, size_t len, Comm::Flag errcode, int xerrno); + void readClient(char *buf, size_t len, Comm::Flag errcode, int xerrno); + void writeClientDone(char *buf, size_t len, Comm::Flag flag, int xerrno); + void writeServerDone(char *buf, size_t len, Comm::Flag flag, int xerrno); - static void ReadConnectResponseDone(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t errcode, int xerrno, void *data); - void readConnectResponseDone(char *buf, size_t len, comm_err_t errcode, int xerrno); + static void ReadConnectResponseDone(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data); + void readConnectResponseDone(char *buf, size_t len, Comm::Flag errcode, int xerrno); }; static const char *const conn_established = "HTTP/1.1 200 Connection established\r\n\r\n"; @@ -324,7 +324,7 @@ TunnelStateData::Connection::debugLevelForError(int const xerrno) const /* Read from server side and queue it for writing to the client */ void -TunnelStateData::ReadServer(const Comm::ConnectionPointer &c, char *buf, size_t len, comm_err_t errcode, int xerrno, void *data) +TunnelStateData::ReadServer(const Comm::ConnectionPointer &c, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; assert(cbdataReferenceValid(tunnelState)); @@ -334,16 +334,16 @@ TunnelStateData::ReadServer(const Comm::ConnectionPointer &c, char *buf, size_t } void -TunnelStateData::readServer(char *buf, size_t len, comm_err_t errcode, int xerrno) +TunnelStateData::readServer(char *buf, size_t len, Comm::Flag errcode, int xerrno) { debugs(26, 3, HERE << server.conn << ", read " << len << " bytes, err=" << errcode); /* - * Bail out early on COMM_ERR_CLOSING + * Bail out early on Comm::ERR_CLOSING * - close handlers will tidy up for us */ - if (errcode == COMM_ERR_CLOSING) + if (errcode == Comm::ERR_CLOSING) return; if (len > 0) { @@ -358,12 +358,12 @@ TunnelStateData::readServer(char *buf, size_t len, comm_err_t errcode, int xerrn /// Called when we read [a part of] CONNECT response from the peer void -TunnelStateData::readConnectResponseDone(char *buf, size_t len, comm_err_t errcode, int xerrno) +TunnelStateData::readConnectResponseDone(char *buf, size_t len, Comm::Flag errcode, int xerrno) { debugs(26, 3, server.conn << ", read " << len << " bytes, err=" << errcode); assert(waitingForConnectResponse()); - if (errcode == COMM_ERR_CLOSING) + if (errcode == Comm::ERR_CLOSING) return; if (len > 0) { @@ -379,7 +379,7 @@ TunnelStateData::readConnectResponseDone(char *buf, size_t len, comm_err_t errco /* Read from client side and queue it for writing to the server */ void -TunnelStateData::ReadConnectResponseDone(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t errcode, int xerrno, void *data) +TunnelStateData::ReadConnectResponseDone(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; assert (cbdataReferenceValid (tunnelState)); @@ -470,7 +470,7 @@ TunnelStateData::Connection::error(int const xerrno) /* Read from client side and queue it for writing to the server */ void -TunnelStateData::ReadClient(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t errcode, int xerrno, void *data) +TunnelStateData::ReadClient(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; assert (cbdataReferenceValid (tunnelState)); @@ -479,16 +479,16 @@ TunnelStateData::ReadClient(const Comm::ConnectionPointer &, char *buf, size_t l } void -TunnelStateData::readClient(char *buf, size_t len, comm_err_t errcode, int xerrno) +TunnelStateData::readClient(char *buf, size_t len, Comm::Flag errcode, int xerrno) { debugs(26, 3, HERE << client.conn << ", read " << len << " bytes, err=" << errcode); /* - * Bail out early on COMM_ERR_CLOSING + * Bail out early on Comm::ERR_CLOSING * - close handlers will tidy up for us */ - if (errcode == COMM_ERR_CLOSING) + if (errcode == Comm::ERR_CLOSING) return; if (len > 0) { @@ -503,7 +503,7 @@ TunnelStateData::readClient(char *buf, size_t len, comm_err_t errcode, int xerrn /// Updates state after reading from client or server. /// Returns whether the caller should use the data just read. bool -TunnelStateData::keepGoingAfterRead(size_t len, comm_err_t errcode, int xerrno, Connection &from, Connection &to) +TunnelStateData::keepGoingAfterRead(size_t len, Comm::Flag errcode, int xerrno, Connection &from, Connection &to) { debugs(26, 3, HERE << "from={" << from.conn << "}, to={" << to.conn << "}"); @@ -556,7 +556,7 @@ TunnelStateData::copy(size_t len, Connection &from, Connection &to, IOCB *comple /* Writes data from the client buffer to the server side */ void -TunnelStateData::WriteServerDone(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +TunnelStateData::WriteServerDone(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; assert (cbdataReferenceValid (tunnelState)); @@ -565,13 +565,13 @@ TunnelStateData::WriteServerDone(const Comm::ConnectionPointer &, char *buf, siz } void -TunnelStateData::writeServerDone(char *buf, size_t len, comm_err_t flag, int xerrno) +TunnelStateData::writeServerDone(char *buf, size_t len, Comm::Flag flag, int xerrno) { debugs(26, 3, HERE << server.conn << ", " << len << " bytes written, flag=" << flag); /* Error? */ - if (flag != COMM_OK) { - if (flag != COMM_ERR_CLOSING) { + if (flag != Comm::OK) { + if (flag != Comm::ERR_CLOSING) { debugs(26, 4, HERE << "calling TunnelStateData::server.error(" << xerrno <<")"); server.error(xerrno); // may call comm_close } @@ -605,7 +605,7 @@ TunnelStateData::writeServerDone(char *buf, size_t len, comm_err_t flag, int xer /* Writes data from the server buffer to the client side */ void -TunnelStateData::WriteClientDone(const Comm::ConnectionPointer &, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +TunnelStateData::WriteClientDone(const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; assert (cbdataReferenceValid (tunnelState)); @@ -626,13 +626,13 @@ TunnelStateData::Connection::dataSent(size_t amount) } void -TunnelStateData::writeClientDone(char *buf, size_t len, comm_err_t flag, int xerrno) +TunnelStateData::writeClientDone(char *buf, size_t len, Comm::Flag flag, int xerrno) { debugs(26, 3, HERE << client.conn << ", " << len << " bytes written, flag=" << flag); /* Error? */ - if (flag != COMM_OK) { - if (flag != COMM_ERR_CLOSING) { + if (flag != Comm::OK) { + if (flag != Comm::ERR_CLOSING) { debugs(26, 4, HERE << "Closing client connection due to comm flags."); client.error(xerrno); // may call comm_close } @@ -730,7 +730,7 @@ tunnelStartShoveling(TunnelStateData *tunnelState) // We just need to ensure the bytes from ConnStateData are in client.buf already to deliver memcpy(tunnelState->client.buf, in->buf.rawContent(), in->buf.length()); // NP: readClient() takes care of buffer length accounting. - tunnelState->readClient(tunnelState->client.buf, in->buf.length(), COMM_OK, 0); + tunnelState->readClient(tunnelState->client.buf, in->buf.length(), Comm::OK, 0); in->buf.consume(); // ConnStateData buffer accounting after the shuffle. } else tunnelState->copyRead(tunnelState->client, TunnelStateData::ReadClient); @@ -743,12 +743,12 @@ tunnelStartShoveling(TunnelStateData *tunnelState) * Call the tunnelStartShoveling to start the blind pump. */ static void -tunnelConnectedWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t size, comm_err_t flag, int xerrno, void *data) +tunnelConnectedWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t size, Comm::Flag flag, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; debugs(26, 3, HERE << conn << ", flag=" << flag); - if (flag != COMM_OK) { + if (flag != Comm::OK) { *tunnelState->status_ptr = Http::scInternalServerError; tunnelErrorComplete(conn->fd, data, 0); return; @@ -759,13 +759,13 @@ tunnelConnectedWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t /// Called when we are done writing CONNECT request to a peer. static void -tunnelConnectReqWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t size, comm_err_t flag, int xerrno, void *data) +tunnelConnectReqWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t size, Comm::Flag flag, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; debugs(26, 3, conn << ", flag=" << flag); assert(tunnelState->waitingForConnectRequest()); - if (flag != COMM_OK) { + if (flag != Comm::OK) { *tunnelState->status_ptr = Http::scInternalServerError; tunnelErrorComplete(conn->fd, data, 0); return; @@ -824,17 +824,17 @@ tunnelErrorComplete(int fd/*const Comm::ConnectionPointer &*/, void *data, size_ } static void -tunnelConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data) +tunnelConnectDone(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; - if (status != COMM_OK) { + if (status != Comm::OK) { debugs(26, 4, HERE << conn << ", comm failure recovery."); /* At this point only the TCP handshake has failed. no data has been passed. * we are allowed to re-try the TCP-level connection to alternate IPs for CONNECT. */ tunnelState->serverDestinations.erase(tunnelState->serverDestinations.begin()); - if (status != COMM_TIMEOUT && tunnelState->serverDestinations.size() > 0) { + if (status != Comm::TIMEOUT && tunnelState->serverDestinations.size() > 0) { /* Try another IP of this destination host */ GetMarkingsToServer(tunnelState->request.getRaw(), *tunnelState->serverDestinations[0]); debugs(26, 4, HERE << "retry with : " << tunnelState->serverDestinations[0]); diff --git a/src/whois.cc b/src/whois.cc index 00a9f792c6..75993def82 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -51,7 +51,7 @@ class WhoisState { public: - void readReply(const Comm::ConnectionPointer &, char *aBuffer, size_t aBufferLength, comm_err_t flag, int xerrno); + void readReply(const Comm::ConnectionPointer &, char *aBuffer, size_t aBufferLength, Comm::Flag flag, int xerrno); void setReplyToOK(StoreEntry *sentry); StoreEntry *entry; HttpRequest::Pointer request; @@ -72,7 +72,7 @@ static IOCB whoisReadReply; /* PUBLIC */ static void -whoisWriteComplete(const Comm::ConnectionPointer &, char *buf, size_t size, comm_err_t flag, int xerrno, void *data) +whoisWriteComplete(const Comm::ConnectionPointer &, char *buf, size_t size, Comm::Flag flag, int xerrno, void *data) { xfree(buf); } @@ -120,7 +120,7 @@ whoisTimeout(const CommTimeoutCbParams &io) } static void -whoisReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) +whoisReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data) { WhoisState *p = (WhoisState *)data; p->readReply(conn, buf, len, flag, xerrno); @@ -136,17 +136,17 @@ WhoisState::setReplyToOK(StoreEntry *sentry) } void -WhoisState::readReply(const Comm::ConnectionPointer &conn, char *aBuffer, size_t aBufferLength, comm_err_t flag, int xerrno) +WhoisState::readReply(const Comm::ConnectionPointer &conn, char *aBuffer, size_t aBufferLength, Comm::Flag flag, int xerrno) { - /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */ - if (flag == COMM_ERR_CLOSING) + /* Bail out early on Comm::ERR_CLOSING - close handlers will tidy up for us */ + if (flag == Comm::ERR_CLOSING) return; aBuffer[aBufferLength] = '\0'; debugs(75, 3, HERE << conn << " read " << aBufferLength << " bytes"); debugs(75, 5, "{" << aBuffer << "}"); - if (flag != COMM_OK) { + if (flag != Comm::OK) { debugs(50, 2, HERE << conn << ": read failure: " << xstrerror() << "."); if (ignoreErrno(errno)) {