]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceLayout: rename comm_err_t to Comm::Flag
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 5 Jun 2014 14:57:58 +0000 (07:57 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 5 Jun 2014 14:57:58 +0000 (07:57 -0700)
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.

55 files changed:
src/Comm.dox
src/CommCalls.cc
src/CommCalls.h
src/FwdState.cc
src/FwdState.h
src/Makefile.am
src/PeerPoolMgr.cc
src/Server.cc
src/client_side.cc
src/client_side.h
src/client_side_request.cc
src/client_side_request.h
src/comm.cc
src/comm.h
src/comm/ConnOpener.cc
src/comm/ConnOpener.h
src/comm/Flag.h [new file with mode: 0644]
src/comm/IoCallback.cc
src/comm/IoCallback.h
src/comm/Loops.h
src/comm/Makefile.am
src/comm/ModDevPoll.cc
src/comm/ModEpoll.cc
src/comm/ModKqueue.cc
src/comm/ModPoll.cc
src/comm/ModSelect.cc
src/comm/ModSelectWin32.cc
src/comm/Read.cc
src/comm/Read.h
src/comm/TcpAcceptor.cc
src/comm/TcpAcceptor.h
src/comm/Write.cc
src/comm/comm_err_t.h [deleted file]
src/comm_err_t.h [deleted file]
src/dns_internal.cc
src/errorpage.cc
src/ftp.cc
src/gopher.cc
src/helper.cc
src/http.cc
src/ident/Ident.cc
src/ipc.cc
src/ipc/Port.cc
src/ipc/UdsOp.cc
src/ipc_win32.cc
src/log/TcpLogger.cc
src/mgr/Inquirer.cc
src/mgr/StoreToCommWriter.cc
src/neighbors.cc
src/pconn.cc
src/tests/stub_client_side.cc
src/tests/stub_comm.cc
src/tests/stub_libcomm.cc
src/tunnel.cc
src/whois.cc

index 55eb1ec92bc937cbfd249a82825da6990eb4e42c..4bf256a9457f443eb701dc783f8d766ed688fcbb 100644 (file)
 
   \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
   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.
 
   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
index e0f622cdbd3a94501dd76724392c1cac06e9d612..36d91b196ebb22b11b32a7f4ccdb6d0106eac8b8 100644 (file)
@@ -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
 }
index 084171b9281f0610b66a1695a25a7f4de9e2dcc3..d430cb6cb3eb594501ab666a2f5019569e1ee9c2 100644 (file)
@@ -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 &params);
 
-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 &params);
@@ -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:
index ccdd03c9e4d18cbb1b840030b57177e887e89173..8b5b2d1863417ec01d640d37fd1306b8fb4dc4fd 100644 (file)
@@ -539,7 +539,7 @@ fwdServerClosedWrapper(const CommCloseCbParams &params)
 }
 
 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);
index 36680b9ba554eb3d01b98b601c7983a67d06f1cf..e78aa905ade88f3452ba095341e222a7c72f870c 100644 (file)
@@ -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();
index d2ebb1f65ecf460a90ee45ef6d2a2521310cc516..6f8fcd0709dff78d1113414406c085a34ebb4716 100644 (file)
@@ -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 \
index 04124000ea3a07b3fc872b7c24e4683001ec8bab..2a6de4262c0f39d327dab5ef37af9d8cc0cb4176 100644 (file)
@@ -91,7 +91,7 @@ PeerPoolMgr::handleOpenedConnection(const CommConnectCbParams &params)
         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();
index 324b23315b49735834ab560ac99d9157b67089ae..7e2e26dbbf41c110943962ee10a68dfcf3a0c84e 100644 (file)
@@ -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) {
index baade6c0e03d50190118585d9682795e752be219..cd7b74df6110fec8e369a8917700855165ff58a4 100644 (file)
@@ -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<ClientSocketContext*>(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 &params)
         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 &params)
         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.
index 792dfc3c4ba5bb5777b0615297d71294996f3265..a86c66c0e0c5707609e72c71d48a605654b812f6 100644 (file)
@@ -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);
index d5a1cbd1ae851548c475450010532e3b73e169bc..2b85580edc1494503fb3fa0e68deca7ff8068efe 100644 (file)
@@ -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<ClientHttpRequest*>(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) {
index 3d6e2b1cd26afa04419f9b124c28eae975c04694..0ea82869b041f957db34f9c0bdf9c79f15f9a8b9 100644 (file)
@@ -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
index 712d6e24d71f0c32fcf3da11291d0f516cbabc04..271167f1b15d15f1a585d9dea7380d511b420055 100644 (file)
@@ -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 &params)
  * + 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;
index 46d377ca4f21bf42013f47bd03b18ac6226267f9..3046604959e5bca6847b09c95a71ae59192d87af 100644 (file)
@@ -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 *);
index fd26497ff4581dbbf08166f10af726d5e0ddbd7d..383f616593cfbca0ee2a021494fe61ee96b47458 100644 (file)
@@ -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
index 003b474908b9836e68fcbfcb2326d4c0a7dbd640..739443ba89bf93c7018e7415efdac3f915b2adde 100644 (file)
@@ -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 (file)
index 0000000..a6b9532
--- /dev/null
@@ -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 */
index a018953668c41db40c7a21767501b840fd4b0e3a..b43873478b532447b1a2c2d442fd7144dca9262c 100644 (file)
@@ -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());
index 705ebf845c0314b2ea6a995b29c8bc3a7e56b7e1..ac998bc8393cd2e654f8434bea492c46cfc718dc 100644 (file)
@@ -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();
index 56f064037b001736d90ede0f4642176c28341bdd..7f748242082dc7f718781482b97de325d640f3b6 100644 (file)
@@ -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);
 
index 45cfc77c9d17d714e255b066d2a2ac5137b0b62b..e9f8bc3f5db179c5d835d9f43302b4b84f5ede49 100644 (file)
@@ -11,6 +11,7 @@ libcomm_la_SOURCES= \
        ConnOpener.h \
        Connection.cc \
        Connection.h \
+       Flag.h \
        forward.h \
        IoCallback.cc \
        IoCallback.h \
index 72fc17382250b9cd04c89601094726f6612dc682..944ad53c7fec163898061f261399b1bb6dca1128 100644 (file)
@@ -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
index d7cb229a646b2fd4a394e2fa5415add02b54d83c..aac515899035de495b854299f97a89a77f878be2 100644 (file)
@@ -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
index b87f5d60ad819e45c5e26f70c6b560af4c0bd32b..0fecd72693cda0f19dffe4668b72089fb440c881 100644 (file)
@@ -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
index dd3bd3349fee5ba6adb05baf97bb718d36915105..82e8495288afeab9790fc807ff8ed51b23c246b4 100644 (file)
@@ -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
index 03e04884b04b46fc489196bcc27736661c087254..d02df7ed03218e7a98ec11a80b01264c3f19441c 100644 (file)
@@ -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
index 1b52dcd39e671f8ba6ca50676cb1fb247173e23a..5b788923a3a621a0da68717b5699ae702b6dcf1a 100644 (file)
@@ -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
index 558f3be9ce3980658c90462f88add771ca016ec6..7e5318813d1e4054856912042e380c3a0b946107 100644 (file)
@@ -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 &params, SBuf &buf)
 {
     /* Attempt a read */
@@ -86,19 +86,19 @@ Comm::ReadNow(CommIoCbParams &params, 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;
     };
 
index 69de56cc29454ba53b0559eb8d710c31e733b0f1..99d78c43c61c234570fb7548e86fbd152f115336 100644 (file)
@@ -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 &params, SBuf &buf);
+Comm::Flag ReadNow(CommIoCbParams &params, SBuf &buf);
 
 /// Cancel the read pending on FD. No action if none pending.
 void ReadCancel(int fd, AsyncCall::Pointer &callback);
index 85e3d0ec8bf69544d2336585e67dd54eb02f9a00..a5bc13690c955d2f97b73282fa6e51b73289b501 100644 (file)
@@ -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;
 }
index 4ab9e9e3090240affd4ef67e7fda027046cf2f2f..abffacb7f0f724ba6b145341b663414cfa8773e6 100644 (file)
@@ -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);
 
index 04bed7cd91528512e5e243604c3f0ce440c69023..436302aa11c4f4577d420527ce6607f81dab8a85 100644 (file)
@@ -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 (file)
index 8814856..0000000
+++ /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 (file)
index 1b22d3b..0000000
+++ /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 */
index 3cca7759494e297535a574526bbc5482e43040d4..1088ec02ac1d2c40e13b2d963e785f2e676433e3 100644 (file)
@@ -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;
index c355e90efb1d0d2a87dc0f987bfe74c4f89726b4..da889df24580f48e079b12b3ccd8f86ec4955f96 100644 (file)
@@ -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<ErrorState *>(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);
index 172d371d9c808d97e38bad1961bed0eb221f8fb5..d7006ffd602b9a74c59e06ebe3c14fb47cf22221 100644 (file)
@@ -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];
index c72039ec5c84d93ab3aff844696d9ea9ba921f18..13637dbd9d5ab8f2d28f49674c22baf34c4c7ecb 100644 (file)
@@ -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;
index 04bc003bc68b2e80ec8c70899ecc8d61fae76616..298090ab984bb5530ab5993dc7585dbb47091cdb 100644 (file)
@@ -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! */
index 90e5229a0af29d5463f7ff2b522ed67169f0b701..04bb1ef385a294e4c709cb1d77a6f7ebc4c859c5 100644 (file)
@@ -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<HttpStateData *>(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) {
index 064d52ac220ba4162a91dfc4bc11e3e5dabf4268..3217fe0659d46fd905829d80271110a39e27dae1 100644 (file)
@@ -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;
     }
index 94e611ec8606d2c6a454bd6de872b78f17ad24fe..93874697b5b2a2a96efd8bcb5dffddb11800a7f6 100644 (file)
@@ -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);
     }
 
index 79d8820b6d41ddd18531749100ec8a4581f740da..1d8029cc2fc0273cd011a3b8978f3af29b56b4fb 100644 (file)
@@ -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);
     }
index 7448ebc4b139a627db141e16c3093b067ec0b234..5393dd2ce79aea913cbd32bfbf0093792d0f6559 100644 (file)
@@ -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();
index c84e51724deed22ee8862e8d10fb34237cb8ad16..f76d57bafa1fcb1b0f25ffb7a4b985097e47b450 100644 (file)
@@ -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;
         }
index 52593f3ed45634ca9fdd29509157d2cb2d89987d..cd539b4d9613e3617e861b34b72e2de495ee5f83 100644 (file)
@@ -254,7 +254,7 @@ Log::TcpLogger::connect()
 void
 Log::TcpLogger::connectDone(const CommConnectCbParams &params)
 {
-    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();
index 9eb412dea68a646828d329b3ef1381c825f9d528..57c7e9dbe5fbae8381e7c17cb958b5a3045bc8d5 100644 (file)
@@ -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
index 00f9226c3c5d8176347043ff215ea2b17c04aacc..cb7f5e7f867dffd25acb4b6c20fbed8a16ff987a 100644 (file)
@@ -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;
index c8ee2cba8d87a8a388b354effff37823faaf0dd5..e7c5f98d5a2b9d7d3862e67fd249df9e4760cdef 100644 (file)
@@ -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);
index 4d115612b24054feb2b19ac7a30f64835f9ff7d7..7ca63fa3ffe0af804880033e3862227308168456 100644 (file)
@@ -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;
     }
 
index 662be12ea648131b3b90c75800c32a3bb13f26a8..5aff3910f4a5f417a2c13d99ac7eb952e7330850 100644 (file)
@@ -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)
index c1760c22098128b20a2c8ce981af109d93adf458..57216f1c8bf5b4aa47ec218261d62d3ff540e6b8 100644 (file)
@@ -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()
index f31768877d83e53fb940e25876ff0866447da75b..d86ea86bd003b521dc65091100eb9d88e0225a58 100644 (file)
@@ -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 &params, SBuf &buf) STUB_RETVAL(COMM_ERROR)
+Comm::Flag Comm::ReadNow(CommIoCbParams &params, 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
index 08228155ee0b89fbd748671bafb0027cce8933c3..e712a6ba553bd4fec9c3cfdf5cd89602943d36ed 100644 (file)
@@ -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]);
index 00a9f792c6ad651a21c1c40c483ba0e7089b7519..75993def8203abc363003bdaad217b8e1e78e1aa 100644 (file)
@@ -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)) {