{
}
+/* FdeCbParams */
+
+FdeCbParams::FdeCbParams(void *aData):
+ CommCommonCbParams(aData)
+{
+}
/* CommAcceptCbPtrFun */
params.print(os);
os << ')';
}
+
+/* FdeCbPtrFun */
+
+FdeCbPtrFun::FdeCbPtrFun(FDECB *aHandler, const FdeCbParams &aParams) :
+ CommDialerParamsT<FdeCbParams>(aParams),
+ handler(aHandler)
+{
+}
+
+void
+FdeCbPtrFun::dial()
+{
+ handler(params);
+}
+
+void
+FdeCbPtrFun::print(std::ostream &os) const
+{
+ os << '(';
+ params.print(os);
+ os << ')';
+}
* - I/O (IOCB)
* - timeout (CTCB)
* - close (CLCB)
+ * and a special callback kind for passing pipe FD, disk FD or fd_table index 'FD' to the handler:
+ * - FD passing callback (FDECB)
*/
class CommAcceptCbParams;
class CommCloseCbParams;
typedef void CLCB(const CommCloseCbParams ¶ms);
+class FdeCbParams;
+typedef void FDECB(const FdeCbParams ¶ms);
+
/*
* TODO: When there are no function-pointer-based callbacks left, all
* this complexity can be removed. Jobs that need comm services will just
comm_err_t flag; ///< comm layer result status.
int xerrno; ///< The last errno to occur. non-zero if flag is COMM_ERR.
- int fd; // raw FD which the call was about. use conn instead for new code.
+ int fd; ///< FD which the call was about. Set by the async call creator.
private:
// should not be needed and not yet implemented
CommCommonCbParams &operator =(const CommCommonCbParams ¶ms);
CommTimeoutCbParams(void *aData);
};
+/// Special Calls parameter, for direct use of an FD without a controlling Comm::Connection
+/// This is used for pipe() FD with helpers, and internally by Comm when handling some special FD actions.
+class FdeCbParams: public CommCommonCbParams
+{
+public:
+ FdeCbParams(void *aData);
+ // TODO make this a standalone object with FD value and pointer to fde table entry.
+ // that requires all the existing Comm handlers to be updated first though
+};
+
// Interface to expose comm callback parameters of all comm dialers.
// GetCommParams() uses this interface to access comm parameters.
template <class Params_>
CTCB *handler;
};
+/// FD event (FDECB) dialer
+class FdeCbPtrFun: public CallDialer,
+ public CommDialerParamsT<FdeCbParams>
+{
+public:
+ typedef FdeCbParams Params;
+
+ FdeCbPtrFun(FDECB *aHandler, const Params &aParams);
+ void dial();
+ virtual void print(std::ostream &os) const;
+
+public:
+ FDECB *handler;
+};
+
// AsyncCall to comm handlers implemented as global functions.
// The dialer is one of the Comm*CbPtrFunT above
// TODO: Get rid of this class by moving canFire() to canDial() method
#if USE_SSL
void
-commStartSslClose(const CommCloseCbParams ¶ms)
+commStartSslClose(const FdeCbParams ¶ms)
{
assert(&fd_table[params.fd].ssl);
ssl_shutdown_method(fd_table[params.fd].ssl);
#endif
void
-comm_close_complete(const CommCloseCbParams ¶ms)
+comm_close_complete(const FdeCbParams ¶ms)
{
#if USE_SSL
fde *F = &fd_table[params.fd];
#if USE_SSL
if (F->ssl) {
- // XXX: make this a generic async call passing one FD parameter. No need to use CommCloseCbParams
AsyncCall::Pointer startCall=commCbCall(5,4, "commStartSslClose",
- CommCloseCbPtrFun(commStartSslClose, NULL));
- CommCloseCbParams &startParams = GetCommParams<CommCloseCbParams>(startCall);
+ FdeCbPtrFun(commStartSslClose, NULL));
+ FdeCbParams &startParams = GetCommParams<FdeCbParams>(startCall);
startParams.fd = fd;
ScheduleCallHere(startCall);
}
AsyncCall::Pointer completeCall=commCbCall(5,4, "comm_close_complete",
- CommCloseCbPtrFun(comm_close_complete, NULL));
- CommCloseCbParams &completeParams = GetCommParams<CommCloseCbParams>(completeCall);
+ FdeCbPtrFun(comm_close_complete, NULL));
+ FdeCbParams &completeParams = GetCommParams<FdeCbParams>(completeCall);
completeParams.fd = fd;
// must use async call to wait for all callbacks
// scheduled before comm_close() to finish