------------------------------------------------------------ revno: 13445 revision-id: squid3@treenet.co.nz-20140605145758-w2o5nmwf53dnz0hc parent: squid3@treenet.co.nz-20140605144932-1fd2ix8l6jfsdcoz committer: Amos Jeffries branch nick: trunk timestamp: Thu 2014-06-05 07:57:58 -0700 message: 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. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140605145758-w2o5nmwf53dnz0hc # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 9d8467d70a03b0bb14dfc49e30a0e3cf80fbeddb # timestamp: 2014-06-05 15:53:48 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140605144932-\ # 1fd2ix8l6jfsdcoz # # Begin patch === modified file 'src/Comm.dox' --- src/Comm.dox 2008-09-25 04:53:22 +0000 +++ src/Comm.dox 2014-06-05 14:57:58 +0000 @@ -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 === modified file 'src/CommCalls.cc' --- src/CommCalls.cc 2013-06-18 23:26:17 +0000 +++ src/CommCalls.cc 2014-06-05 14:57:58 +0000 @@ -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 @@ 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 @@ { // 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 } === modified file 'src/CommCalls.h' --- src/CommCalls.h 2014-06-05 08:28:20 +0000 +++ src/CommCalls.h 2014-06-05 14:57:58 +0000 @@ -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 @@ * - 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: === modified file 'src/FwdState.cc' --- src/FwdState.cc 2014-06-02 07:19:35 +0000 +++ src/FwdState.cc 2014-06-05 14:57:58 +0000 @@ -539,7 +539,7 @@ } 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 @@ } 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); === modified file 'src/FwdState.h' --- src/FwdState.h 2014-04-30 10:50:09 +0000 +++ src/FwdState.h 2014-06-05 14:57:58 +0000 @@ -73,7 +73,7 @@ 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(); === modified file 'src/Makefile.am' --- src/Makefile.am 2014-06-04 15:30:16 +0000 +++ src/Makefile.am 2014-06-05 14:57:58 +0000 @@ -264,7 +264,6 @@ libsquid_la_SOURCES = \ comm.cc \ comm.h \ - comm_err_t.h \ CommCalls.cc \ CommCalls.h \ DescriptorSet.cc \ === modified file 'src/PeerPoolMgr.cc' --- src/PeerPoolMgr.cc 2014-05-07 14:40:05 +0000 +++ src/PeerPoolMgr.cc 2014-06-05 14:57:58 +0000 @@ -91,7 +91,7 @@ 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(); === modified file 'src/Server.cc' --- src/Server.cc 2014-04-22 02:47:09 +0000 +++ src/Server.cc 2014-06-05 14:57:58 +0000 @@ -376,7 +376,7 @@ // kids should increment their counters } - if (io.flag == COMM_ERR_CLOSING) + if (io.flag == Comm::ERR_CLOSING) return; if (!requestBodySource) { === modified file 'src/client_side.cc' --- src/client_side.cc 2014-06-05 08:28:20 +0000 +++ src/client_side.cc 2014-06-05 14:57:58 +0000 @@ -375,12 +375,12 @@ /// 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 @@ /// 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 @@ 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 @@ 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 @@ } 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 @@ * 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 @@ } 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 @@ (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 @@ 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 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 @@ { 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. === modified file 'src/client_side.h' --- src/client_side.h 2014-06-05 08:28:20 +0000 +++ src/client_side.h 2014-06-05 14:57:58 +0000 @@ -87,7 +87,7 @@ 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 @@ 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); === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2014-06-03 08:52:29 +0000 +++ src/client_side_request.cc 2014-06-05 14:57:58 +0000 @@ -1558,7 +1558,7 @@ // 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 @@ } 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) { === modified file 'src/client_side_request.h' --- src/client_side_request.h 2014-03-30 12:00:34 +0000 +++ src/client_side_request.h 2014-06-05 14:57:58 +0000 @@ -154,7 +154,7 @@ /// 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 === modified file 'src/comm.cc' --- src/comm.cc 2014-06-05 09:32:50 +0000 +++ src/comm.cc 2014-06-05 14:57:58 +0000 @@ -98,7 +98,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ */ 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 @@ */ 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 @@ 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 @@ * + 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 @@ // 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ // 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 @@ /// 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 @@ 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 @@ 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 @@ 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 @@ } 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; === modified file 'src/comm.h' --- src/comm.h 2014-06-05 08:28:20 +0000 +++ src/comm.h 2014-06-05 14:57:58 +0000 @@ -71,7 +71,6 @@ 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 *); === modified file 'src/comm/ConnOpener.cc' --- src/comm/ConnOpener.cc 2014-06-02 07:19:35 +0000 +++ src/comm/ConnOpener.cc 2014-06-05 14:57:58 +0000 @@ -62,7 +62,7 @@ { 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ { 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 === modified file 'src/comm/ConnOpener.h' --- src/comm/ConnOpener.h 2013-10-25 00:13:46 +0000 +++ src/comm/ConnOpener.h 2014-06-05 14:57:58 +0000 @@ -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 @@ 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 @@ 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. === renamed file 'src/comm/comm_err_t.h' => 'src/comm/Flag.h' --- src/comm/comm_err_t.h 2014-06-05 08:28:20 +0000 +++ src/comm/Flag.h 2014-06-05 14:57:58 +0000 @@ -1,20 +1,25 @@ -#ifndef _SQUID_COMM_COMM_ERR_T_H -#define _SQUID_COMM_COMM_ERR_T_H +#ifndef _SQUID_SRC_COMM_FLAG_H +#define _SQUID_SRC_COMM_FLAG_H + +namespace Comm +{ 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 */ + 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 */ === modified file 'src/comm/IoCallback.cc' --- src/comm/IoCallback.cc 2014-06-05 08:28:20 +0000 +++ src/comm/IoCallback.cc 2014-06-05 14:57:58 +0000 @@ -103,7 +103,7 @@ // 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()); === modified file 'src/comm/IoCallback.h' --- src/comm/IoCallback.h 2014-06-05 08:28:20 +0000 +++ src/comm/IoCallback.h 2014-06-05 14:57:58 +0000 @@ -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 @@ 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 @@ 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(); === modified file 'src/comm/Loops.h' --- src/comm/Loops.h 2012-10-08 05:21:11 +0000 +++ src/comm/Loops.h 2014-06-05 14:57:58 +0000 @@ -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 @@ /** 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); === modified file 'src/comm/Makefile.am' --- src/comm/Makefile.am 2014-06-05 08:28:20 +0000 +++ src/comm/Makefile.am 2014-06-05 14:57:58 +0000 @@ -11,6 +11,7 @@ ConnOpener.h \ Connection.cc \ Connection.h \ + Flag.h \ forward.h \ IoCallback.cc \ IoCallback.h \ === modified file 'src/comm/ModDevPoll.cc' --- src/comm/ModDevPoll.cc 2014-02-21 10:46:19 +0000 +++ src/comm/ModDevPoll.cc 2014-06-05 14:57:58 +0000 @@ -336,7 +336,7 @@ * * @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 @@ /* error during poll */ getCurrentTime(); PROF_stop(comm_check_incoming); - return COMM_ERROR; + return Comm::ERROR; } PROF_stop(comm_check_incoming); @@ -375,7 +375,7 @@ 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 @@ } PROF_stop(comm_handle_ready_fd); - return COMM_OK; + return Comm::OK; } void === modified file 'src/comm/ModEpoll.cc' --- src/comm/ModEpoll.cc 2014-06-02 07:19:35 +0000 +++ src/comm/ModEpoll.cc 2014-06-05 14:57:58 +0000 @@ -239,7 +239,7 @@ * 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 @@ PROF_stop(comm_check_incoming); - return COMM_ERROR; + return Comm::ERROR; } PROF_stop(comm_check_incoming); @@ -276,7 +276,7 @@ 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 @@ PROF_stop(comm_handle_ready_fd); - return COMM_OK; + return Comm::OK; } void === modified file 'src/comm/ModKqueue.cc' --- src/comm/ModKqueue.cc 2014-06-02 07:19:35 +0000 +++ src/comm/ModKqueue.cc 2014-06-05 14:57:58 +0000 @@ -242,7 +242,7 @@ * events. */ -comm_err_t +Comm::Flag Comm::DoSelect(int msec) { int num, i; @@ -271,7 +271,7 @@ getCurrentTime(); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -279,7 +279,7 @@ 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 @@ } } - return COMM_OK; + return Comm::OK; } void === modified file 'src/comm/ModPoll.cc' --- src/comm/ModPoll.cc 2014-06-02 07:19:35 +0000 +++ src/comm/ModPoll.cc 2014-06-05 14:57:58 +0000 @@ -348,7 +348,7 @@ } /* 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 @@ assert(errno != EINVAL); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -580,12 +580,12 @@ 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 === modified file 'src/comm/ModSelect.cc' --- src/comm/ModSelect.cc 2014-06-02 07:19:35 +0000 +++ src/comm/ModSelect.cc 2014-06-05 14:57:58 +0000 @@ -344,7 +344,7 @@ #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 @@ examine_select(&readfds, &writefds); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -628,11 +628,11 @@ 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 === modified file 'src/comm/ModSelectWin32.cc' --- src/comm/ModSelectWin32.cc 2014-06-02 07:19:35 +0000 +++ src/comm/ModSelectWin32.cc 2014-06-05 14:57:58 +0000 @@ -341,7 +341,7 @@ #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 @@ examine_select(&readfds, &writefds); - return COMM_ERROR; + return Comm::ERROR; /* NOTREACHED */ } @@ -642,11 +642,11 @@ 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 === modified file 'src/comm/Read.cc' --- src/comm/Read.cc 2014-06-05 08:28:20 +0000 +++ src/comm/Read.cc 2014-06-05 14:57:58 +0000 @@ -70,7 +70,7 @@ 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 @@ 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 @@ // without a buffer, just call back if (!ccb->buf) { - ccb->finish(COMM_OK, 0); + ccb->finish(Comm::OK, 0); return; } @@ -139,13 +139,13 @@ 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; }; === modified file 'src/comm/Read.h' --- src/comm/Read.h 2014-06-05 09:32:50 +0000 +++ src/comm/Read.h 2014-06-05 14:57:58 +0000 @@ -26,13 +26,13 @@ * * 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); === modified file 'src/comm/TcpAcceptor.cc' --- src/comm/TcpAcceptor.cc 2014-06-02 07:19:35 +0000 +++ src/comm/TcpAcceptor.cc 2014-06-05 14:57:58 +0000 @@ -261,12 +261,12 @@ /* 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 @@ } 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ // 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 @@ #endif PROF_stop(comm_accept); - return COMM_OK; + return Comm::OK; } === modified file 'src/comm/TcpAcceptor.h' --- src/comm/TcpAcceptor.h 2014-06-02 05:09:38 +0000 +++ src/comm/TcpAcceptor.h 2014-06-05 14:57:58 +0000 @@ -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 @@ 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 @@ 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); === modified file 'src/comm/Write.cc' --- src/comm/Write.cc 2014-02-21 10:46:19 +0000 +++ src/comm/Write.cc 2014-06-05 14:57:58 +0000 @@ -125,18 +125,18 @@ 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 @@ /* 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); } } === removed file 'src/comm_err_t.h' --- src/comm_err_t.h 2010-12-10 09:49:50 +0000 +++ src/comm_err_t.h 1970-01-01 00:00:00 +0000 @@ -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 */ === modified file 'src/dns_internal.cc' --- src/dns_internal.cc 2014-06-05 08:28:20 +0000 +++ src/dns_internal.cc 2014-06-05 14:57:58 +0000 @@ -796,18 +796,18 @@ } 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 @@ } 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 @@ } 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 @@ } 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; === modified file 'src/errorpage.cc' --- src/errorpage.cc 2014-05-07 14:40:05 +0000 +++ src/errorpage.cc 2014-06-05 14:57:58 +0000 @@ -682,12 +682,12 @@ * 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); === modified file 'src/ftp.cc' --- src/ftp.cc 2014-06-05 08:28:20 +0000 +++ src/ftp.cc 2014-06-05 14:57:58 +0000 @@ -1241,7 +1241,7 @@ 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 @@ 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 @@ ++ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ } } - /** 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]; === modified file 'src/gopher.cc' --- src/gopher.cc 2014-06-05 08:28:20 +0000 +++ src/gopher.cc 2014-06-05 14:57:58 +0000 @@ -739,7 +739,7 @@ * 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ * 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; === modified file 'src/helper.cc' --- src/helper.cc 2014-06-05 08:28:20 +0000 +++ src/helper.cc 2014-06-05 14:57:58 +0000 @@ -887,16 +887,16 @@ } 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ } 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! */ === modified file 'src/http.cc' --- src/http.cc 2014-04-27 07:59:17 +0000 +++ src/http.cc 2014-06-05 14:57:58 +0000 @@ -1127,7 +1127,7 @@ */ /* 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 @@ 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 @@ } // 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 @@ 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) { === modified file 'src/ident/Ident.cc' --- src/ident/Ident.cc 2014-06-05 08:28:20 +0000 +++ src/ident/Ident.cc 2014-06-05 14:57:58 +0000 @@ -119,12 +119,12 @@ } 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 @@ } 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 @@ 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; } === modified file 'src/ipc.cc' --- src/ipc.cc 2013-10-25 00:13:46 +0000 +++ src/ipc.cc 2014-06-05 14:57:58 +0000 @@ -262,7 +262,7 @@ 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 @@ 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); } === modified file 'src/ipc/Port.cc' --- src/ipc/Port.cc 2014-06-05 08:28:20 +0000 +++ src/ipc/Port.cc 2014-06-05 14:57:58 +0000 @@ -71,7 +71,7 @@ { 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); } === modified file 'src/ipc/UdsOp.cc' --- src/ipc/UdsOp.cc 2013-12-01 08:02:49 +0000 +++ src/ipc/UdsOp.cc 2014-06-05 14:57:58 +0000 @@ -123,7 +123,7 @@ { 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(); === modified file 'src/ipc_win32.cc' --- src/ipc_win32.cc 2014-06-02 07:19:35 +0000 +++ src/ipc_win32.cc 2014-06-05 14:57:58 +0000 @@ -263,7 +263,7 @@ } /* 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 @@ 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 @@ 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; } === modified file 'src/log/TcpLogger.cc' --- src/log/TcpLogger.cc 2013-10-25 00:13:46 +0000 +++ src/log/TcpLogger.cc 2014-06-05 14:57:58 +0000 @@ -254,7 +254,7 @@ 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 @@ 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(); === modified file 'src/mgr/Inquirer.cc' --- src/mgr/Inquirer.cc 2013-10-25 00:13:46 +0000 +++ src/mgr/Inquirer.cc 2014-06-05 14:57:58 +0000 @@ -104,7 +104,7 @@ { 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 === modified file 'src/mgr/StoreToCommWriter.cc' --- src/mgr/StoreToCommWriter.cc 2013-12-19 04:53:35 +0000 +++ src/mgr/StoreToCommWriter.cc 2014-06-05 14:57:58 +0000 @@ -112,7 +112,7 @@ 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; === modified file 'src/neighbors.cc' --- src/neighbors.cc 2014-05-22 10:13:57 +0000 +++ src/neighbors.cc 2014-06-05 14:57:58 +0000 @@ -1375,11 +1375,11 @@ } 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); === modified file 'src/pconn.cc' --- src/pconn.cc 2014-06-05 08:28:20 +0000 +++ src/pconn.cc 2014-06-05 14:57:58 +0000 @@ -311,13 +311,13 @@ } 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; } === modified file 'src/tests/stub_client_side.cc' --- src/tests/stub_client_side.cc 2014-06-05 08:28:20 +0000 +++ src/tests/stub_client_side.cc 2014-06-05 14:57:58 +0000 @@ -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) === modified file 'src/tests/stub_comm.cc' --- src/tests/stub_comm.cc 2013-01-21 07:15:09 +0000 +++ src/tests/stub_comm.cc 2014-06-05 14:57:58 +0000 @@ -55,7 +55,7 @@ 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() === modified file 'src/tests/stub_libcomm.cc' --- src/tests/stub_libcomm.cc 2014-06-05 08:28:20 +0000 +++ src/tests/stub_libcomm.cc 2014-06-05 14:57:58 +0000 @@ -36,7 +36,7 @@ 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::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::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 === modified file 'src/tunnel.cc' --- src/tunnel.cc 2014-06-05 08:28:20 +0000 +++ src/tunnel.cc 2014-06-05 14:57:58 +0000 @@ -88,10 +88,10 @@ 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 @@ #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 @@ /* 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 @@ } 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 @@ /// 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 @@ /* 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 @@ /* 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 @@ } 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 @@ /// 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 @@ /* 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 @@ } 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 @@ /* 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 @@ } 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 @@ // 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 @@ * 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 @@ /// 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 @@ } 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]); === modified file 'src/whois.cc' --- src/whois.cc 2014-06-05 08:28:20 +0000 +++ src/whois.cc 2014-06-05 14:57:58 +0000 @@ -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 @@ /* 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 @@ } 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 @@ } 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)) {