\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
/* 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)
{
}
if (xerrno)
os << ", errno=" << xerrno;
- if (flag != COMM_OK)
+ if (flag != Comm::OK)
os << ", flag=" << flag;
if (data)
os << ", data=" << data;
{
// 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
}
#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.
class CommAcceptCbParams;
typedef void IOACB(const CommAcceptCbParams ¶ms);
-typedef void CNCB(const Comm::ConnectionPointer &conn, comm_err_t status, int xerrno, void *data);
-typedef void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, comm_err_t flag, int xerrno, void *data);
+typedef void CNCB(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data);
+typedef void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int xerrno, void *data);
class CommTimeoutCbParams;
typedef void CTCB(const CommTimeoutCbParams ¶ms);
* - 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:
}
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);
}
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);
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();
libsquid_la_SOURCES = \
comm.cc \
comm.h \
- comm_err_t.h \
CommCalls.cc \
CommCalls.h \
DescriptorSet.cc \
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();
// kids should increment their counters
}
- if (io.flag == COMM_ERR_CLOSING)
+ if (io.flag == Comm::ERR_CLOSING)
return;
if (!requestBodySource) {
/// 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;
}
/// 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);
CommIoCbPtrFun(clientWriteComplete, this));
Comm::Write(clientConnection, &mb, call);
} else
- writeComplete(clientConnection, NULL, 0, COMM_OK);
+ writeComplete(clientConnection, NULL, 0, Comm::OK);
}
/**
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;
}
}
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);
* 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);
}
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;
(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)) {
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;
}
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())
/* 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)) {
/* 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);
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;
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;
{
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.
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.
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);
// 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);
}
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) {
/// 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
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
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;
}
/**
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;
}
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;
*/
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.
*/
if (!F->local_addr.isIPv4() && address.isIPv4()) {
errno = ENETUNREACH;
- return COMM_ERR_PROTOCOL;
+ return Comm::ERR_PROTOCOL;
}
address.getAddrInfo(AI, F->sock_family);
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");
}
* + 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
// 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
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
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_
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
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;
// 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;
/// 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);
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;
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:
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;
}
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;
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 *);
{
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?
* 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) {
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;
}
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.
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;
} 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");
}
}
}
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");
}
/**
{
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
#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
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();
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.
--- /dev/null
+#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 */
// 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());
#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;
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
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();
#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"
/** 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);
ConnOpener.h \
Connection.cc \
Connection.h \
+ Flag.h \
forward.h \
IoCallback.cc \
IoCallback.h \
*
* @param msec milliseconds to poll for (limited by max_poll_time)
*/
-comm_err_t
+Comm::Flag
Comm::DoSelect(int msec)
{
int num, i;
/* error during poll */
getCurrentTime();
PROF_stop(comm_check_incoming);
- return COMM_ERROR;
+ return Comm::ERROR;
}
PROF_stop(comm_check_incoming);
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);
}
PROF_stop(comm_handle_ready_fd);
- return COMM_OK;
+ return Comm::OK;
}
void
* 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;
PROF_stop(comm_check_incoming);
- return COMM_ERROR;
+ return Comm::ERROR;
}
PROF_stop(comm_check_incoming);
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);
PROF_stop(comm_handle_ready_fd);
- return COMM_OK;
+ return Comm::OK;
}
void
* events.
*/
-comm_err_t
+Comm::Flag
Comm::DoSelect(int msec)
{
int num, i;
getCurrentTime();
- return COMM_ERROR;
+ return Comm::ERROR;
/* NOTREACHED */
}
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;
}
}
- return COMM_OK;
+ return Comm::OK;
}
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];
assert(errno != EINVAL);
- return COMM_ERROR;
+ return Comm::ERROR;
/* NOTREACHED */
}
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
#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;
examine_select(&readfds, &writefds);
- return COMM_ERROR;
+ return Comm::ERROR;
/* NOTREACHED */
}
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
#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;
examine_select(&readfds, &writefds);
- return COMM_ERROR;
+ return Comm::ERROR;
/* NOTREACHED */
}
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
Comm::SetSelect(conn->fd, COMM_SELECT_READ, Comm::HandleRead, ccb, 0);
}
-comm_err_t
+Comm::Flag
Comm::ReadNow(CommIoCbParams ¶ms, SBuf &buf)
{
/* Attempt a read */
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;
// without a buffer, just call back
if (!ccb->buf) {
- ccb->finish(COMM_OK, 0);
+ ccb->finish(Comm::OK, 0);
return;
}
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;
};
*
* The returned flag is also placed in params.flag.
*
- * \retval COMM_OK data has been read and placed in buf, amount in params.size
- * \retval COMM_ERROR an error occured, the code is placed in params.xerrno
- * \retval COMM_INPROGRESS unable to read at this time, or a minor error occured
- * \retval COMM_ERR_CLOSING 0-byte read has occured.
+ * \retval Comm::OK data has been read and placed in buf, amount in params.size
+ * \retval Comm::ERROR an error occured, the code is placed in params.xerrno
+ * \retval Comm::INPROGRESS unable to read at this time, or a minor error occured
+ * \retval Comm::ERR_CLOSING 0-byte read has occured.
* Usually indicates the remote end has disconnected.
*/
-comm_err_t ReadNow(CommIoCbParams ¶ms, SBuf &buf);
+Comm::Flag ReadNow(CommIoCbParams ¶ms, SBuf &buf);
/// Cancel the read pending on FD. No action if none pending.
void ReadCancel(int fd, AsyncCall::Pointer &callback);
/* 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);
}
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;
}
* 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);
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;
}
}
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;
}
}
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);
// 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
#endif
PROF_stop(comm_accept);
- return COMM_OK;
+ return Comm::OK;
}
#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;
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;
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);
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 */
/* 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);
}
}
+++ /dev/null
-#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 */
+++ /dev/null
-#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 */
}
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;
}
}
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);
}
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;
}
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;
* 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);
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);
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
++ 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));
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) {
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)) {
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));
}
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
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));
}
}
- /** 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];
* 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;
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;
}
/* 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
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;
req->hier.bodyBytesRead += len;
}
- if (flag != COMM_OK) {
+ if (flag != Comm::OK) {
debugs(50, DBG_IMPORTANT, "gopherReadReply: error reading: " << xstrerror());
if (ignoreErrno(xerrno)) {
* 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;
}
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;
}
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;
}
}
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;
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;
}
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;
}
}
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;
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;
}
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! */
*/
/*
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);
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;
}
}
// 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)) {
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) {
}
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;
}
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;
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;
}
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);
}
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);
}
{
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);
}
{
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();
}
/* 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);
}
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;
}
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;
}
void
Log::TcpLogger::connectDone(const CommConnectCbParams ¶ms)
{
- if (params.flag != COMM_OK) {
+ if (params.flag != Comm::OK) {
const double delay = 0.5; // seconds
if (connectFailures++ % 100 == 0) {
debugs(MY_DEBUG_SECTION, DBG_IMPORTANT, "tcp:" << remote <<
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();
{
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
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;
}
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);
}
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;
}
//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)
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()
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
void Comm::SelectLoopInit(void) STUB
void Comm::SetSelect(int, unsigned int, PF *, void *, time_t) STUB
void Comm::ResetSelect(int) STUB
-comm_err_t Comm::DoSelect(int) STUB_RETVAL(COMM_ERROR)
+Comm::Flag Comm::DoSelect(int) STUB_RETVAL(Comm::ERROR)
void Comm::QuickPollRequired(void) STUB
#include "comm/Read.h"
void Comm::Read(const Comm::ConnectionPointer &conn, AsyncCall::Pointer &callback) STUB
bool Comm::MonitorsRead(int fd) STUB_RETVAL(false)
-comm_err_t Comm::ReadNow(CommIoCbParams ¶ms, SBuf &buf) STUB_RETVAL(COMM_ERROR)
+Comm::Flag Comm::ReadNow(CommIoCbParams ¶ms, SBuf &buf) STUB_RETVAL(Comm::ERROR)
void Comm::ReadCancel(int fd, AsyncCall::Pointer &callback) STUB
//void Comm::HandleRead(int, void*) STUB
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
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();
#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";
/* 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));
}
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) {
/// 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) {
/* 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));
/* 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));
}
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) {
/// 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 << "}");
/* 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));
}
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
}
/* 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));
}
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
}
// 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);
* 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;
/// 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;
}
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]);
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;
/* 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);
}
}
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);
}
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)) {