]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/comm/Write.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / comm / Write.cc
index 4d5cf46a69de5d1df00f013d1f0b5b069f792e03..4a853e20888e54488cb8e71f10dbbb374b72bde8 100644 (file)
@@ -1,13 +1,27 @@
-#include "config.h"
-#if USE_DELAY_POOLS
-#include "ClientInfo.h"
-#endif
+/*
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
 #include "comm/Connection.h"
 #include "comm/IoCallback.h"
 #include "comm/Write.h"
+#include "fd.h"
 #include "fde.h"
-#include "SquidTime.h"
+#include "globals.h"
 #include "MemBuf.h"
+#include "profiler/Profiler.h"
+#include "SquidTime.h"
+#include "StatCounters.h"
+#if USE_DELAY_POOLS
+#include "ClientInfo.h"
+#endif
+
+#include <cerrno>
 
 void
 Comm::Write(const Comm::ConnectionPointer &conn, MemBuf *mb, AsyncCall::Pointer &callback)
@@ -97,7 +111,7 @@ Comm::HandleWrite(int fd, void *data)
             /* we wrote data - drain them from bucket */
             clientInfo->bucketSize -= len;
             if (clientInfo->bucketSize < 0.0) {
-                debugs(5,1, HERE << "drained too much"); // should not happen
+                debugs(5, DBG_IMPORTANT, HERE << "drained too much"); // should not happen
                 clientInfo->bucketSize = 0;
             }
         }
@@ -108,7 +122,7 @@ Comm::HandleWrite(int fd, void *data)
 #endif /* USE_DELAY_POOLS */
 
     fd_bytes(fd, len, FD_WRITE);
-    statCounter.syscalls.sock.writes++;
+    ++statCounter.syscalls.sock.writes;
     // After each successful partial write,
     // reset fde::writeStart to the current time.
     fd_table[fd].writeStart = squid_curtime;
@@ -119,18 +133,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::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::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::COMM_ERROR : Comm::OK, errno);
         }
     } else {
         /* A successful write, continue */
@@ -140,9 +154,10 @@ 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::COMM_ERROR, errno);
         }
     }
 
     PROF_stop(commHandleWrite);
 }
+