-#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)
/* 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;
}
}
#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;
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 */
/* 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);
}
+