-
/*
- * $Id$
+ * Copyright (C) 1996-2017 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.
*/
#ifndef SQUID_COMMCALLS_H
#include "base/AsyncCall.h"
#include "base/AsyncJobCalls.h"
-#include "comm_err_t.h"
+#include "comm/Flag.h"
#include "comm/forward.h"
+#include "MasterXaction.h"
/* CommCalls implement AsyncCall interface for comm_* callbacks.
* The classes cover two call dialer kinds:
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);
* known to comm and there are many kinds of parameters.
*/
-
/* Comm*CbParams classes below handle callback parameters */
// Maintains parameters common to all comm callbacks
void *data; // cbdata-protected
/** The connection which this call pertains to.
- * \itemize On accept() calls this is the new client connection.
- * \itemize On connect() finished calls this is the newely opened connection.
- * \itemize On write calls this is the connection just written to.
- * \itemize On read calls this is the connection just read from.
- * \itemize On close calls this describes the connection which is now closed.
- * \itemize 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.
+ * - On accept() calls this is the new client connection.
+ * - On connect() finished calls this is the newely opened connection.
+ * - On write calls this is the connection just written to.
+ * - 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::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::COMM_ERROR.
int fd; ///< FD which the call was about. Set by the async call creator.
private:
{
public:
CommAcceptCbParams(void *aData);
+
+ void print(std::ostream &os) const;
+
+ /// Transaction which this call is part of.
+ MasterXaction::Pointer xaction;
};
// connect parameters
return dp->params;
}
-
// All job dialers with comm parameters are merged into one since they
// all have exactly one callback argument and differ in Params type only
template <class C, class Params_>
typedef Params_ Params;
typedef void (C::*Method)(const Params &io);
- CommCbMemFunT(const CbcPointer<C> &job, Method meth): JobDialer<C>(job),
- CommDialerParamsT<Params_>(job.get()),
- method(meth) {}
+ CommCbMemFunT(const CbcPointer<C> &aJob, Method aMeth): JobDialer<C>(aJob),
+ CommDialerParamsT<Params_>(aJob->toCbdata()),
+ method(aMeth) {}
virtual bool canDial(AsyncCall &c) {
return JobDialer<C>::canDial(c) &&
virtual void doDial() { ((&(*this->job))->*method)(this->params); }
};
-
// accept (IOACB) dialer
class CommAcceptCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommAcceptCbParams>
+ public CommDialerParamsT<CommAcceptCbParams>
{
public:
typedef CommAcceptCbParams Params;
// connect (CNCB) dialer
class CommConnectCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommConnectCbParams>
+ public CommDialerParamsT<CommConnectCbParams>
{
public:
typedef CommConnectCbParams Params;
CNCB *handler;
};
-
// read/write (IOCB) dialer
class CommIoCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommIoCbParams>
+ public CommDialerParamsT<CommIoCbParams>
{
public:
typedef CommIoCbParams Params;
IOCB *handler;
};
-
// close (CLCB) dialer
class CommCloseCbPtrFun: public CallDialer,
- public CommDialerParamsT<CommCloseCbParams>
+ public CommDialerParamsT<CommCloseCbParams>
{
public:
typedef CommCloseCbParams Params;
};
class CommTimeoutCbPtrFun:public CallDialer,
- public CommDialerParamsT<CommTimeoutCbParams>
+ public CommDialerParamsT<CommTimeoutCbParams>
{
public:
typedef CommTimeoutCbParams Params;
/// FD event (FDECB) dialer
class FdeCbPtrFun: public CallDialer,
- public CommDialerParamsT<FdeCbParams>
+ public CommDialerParamsT<FdeCbParams>
{
public:
typedef FdeCbParams Params;
const char *callName, const Dialer &aDialer);
inline CommCbFunPtrCallT(const CommCbFunPtrCallT &o) :
- AsyncCall(o.debugSection, o.debugLevel, o.name),
- dialer(o.dialer) {}
+ AsyncCall(o.debugSection, o.debugLevel, o.name),
+ dialer(o.dialer) {}
~CommCbFunPtrCallT() {}
template <class Dialer>
CommCbFunPtrCallT<Dialer>::CommCbFunPtrCallT(int aDebugSection, int aDebugLevel,
const char *callName, const Dialer &aDialer):
- AsyncCall(aDebugSection, aDebugLevel, callName),
- dialer(aDialer)
+ AsyncCall(aDebugSection, aDebugLevel, callName),
+ dialer(aDialer)
{
}
-
template <class Dialer>
bool
CommCbFunPtrCallT<Dialer>::canFire()
}
#endif /* SQUID_COMMCALLS_H */
+