--- /dev/null
+#ifndef SQUID_BASE_ASYNCCBDATACALLS_H
+#define SQUID_BASE_ASYNCCBDATACALLS_H
+
+#include "base/AsyncCall.h"
+#include "base/CbcPointer.h"
+
+// dialer to run cbdata callback functions as Async Calls
+// to ease the transition of these cbdata objects to full Jobs
+template<class Argument1>
+class UnaryCbdataDialer : public CallDialer
+{
+public:
+ typedef void Handler(Argument1 *);
+
+ UnaryCbdataDialer(Handler *aHandler, Argument1 *aArg) :
+ arg1(aArg),
+ handler(aHandler)
+ {}
+
+ virtual bool canDial(AsyncCall &call) { return arg1.valid(); }
+ void dial(AsyncCall &call) { handler(arg1.get()); }
+ virtual void print(std::ostream &os) const { os << '(' << arg1 << ')'; }
+
+public:
+ CbcPointer<Argument1> arg1;
+ Handler *handler;
+};
+
+// helper function to simplify Dialer creation.
+template <class Argument1>
+UnaryCbdataDialer<Argument1>
+cbdataDialer(typename UnaryCbdataDialer<Argument1>::Handler *handler, Argument1 *arg1)
+{
+ return UnaryCbdataDialer<Argument1>(handler, arg1);
+}
+
+#endif
*/
#include "squid.h"
+#include "base/AsyncCbdataCalls.h"
#include "comm.h"
#include "comm/Connection.h"
#include "comm/Write.h"
static IOCB helperHandleRead;
static IOCB helperStatefulHandleRead;
-static CLCB helperServerFree;
-static CLCB helperStatefulServerFree;
+static void helperServerFree(helper_server *srv);
+static void helperStatefulServerFree(helper_stateful_server *srv);
static void Enqueue(helper * hlp, helper_request *);
static helper_request *Dequeue(helper * hlp);
static helper_stateful_request *StatefulDequeue(statefulhelper * hlp);
if (wfd != rfd)
commSetNonBlocking(wfd);
- comm_add_close_handler(rfd, helperServerFree, srv);
+ AsyncCall::Pointer closeCall = asyncCall(5,4, "helperServerFree", cbdataDialer(helperServerFree, srv));
+ comm_add_close_handler(rfd, closeCall);
AsyncCall::Pointer call = commCbCall(5,4, "helperHandleRead",
CommIoCbPtrFun(helperHandleRead, srv));
if (wfd != rfd)
commSetNonBlocking(wfd);
- comm_add_close_handler(rfd, helperStatefulServerFree, srv);
+ AsyncCall::Pointer closeCall = asyncCall(5,4, "helperStatefulServerFree", cbdataDialer(helperStatefulServerFree, srv));
+ comm_add_close_handler(rfd, closeCall);
AsyncCall::Pointer call = commCbCall(5,4, "helperStatefulHandleRead",
CommIoCbPtrFun(helperStatefulHandleRead, srv));
/* ====================================================================== */
static void
-helperServerFree(const CommCloseCbParams ¶ms)
+helperServerFree(helper_server *srv)
{
- helper_server *srv = (helper_server *)params.data;
helper *hlp = srv->parent;
helper_request *r;
int i, concurrency = hlp->childs.concurrency;
if (!srv->flags.shutdown) {
assert(hlp->childs.n_active > 0);
hlp->childs.n_active--;
- debugs(84, DBG_CRITICAL, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << " (FD " << params.fd << ") exited");
+ debugs(84, DBG_CRITICAL, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << " exited");
if (hlp->childs.needNew() > 0) {
debugs(80, 1, "Too few " << hlp->id_name << " processes are running (need " << hlp->childs.needNew() << "/" << hlp->childs.n_max << ")");
}
static void
-helperStatefulServerFree(const CommCloseCbParams ¶ms)
+helperStatefulServerFree(helper_stateful_server *srv)
{
- helper_stateful_server *srv = (helper_stateful_server *)params.data;
statefulhelper *hlp = srv->parent;
helper_stateful_request *r;
if (!srv->flags.shutdown) {
assert( hlp->childs.n_active > 0);
hlp->childs.n_active--;
- debugs(84, 0, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << " (FD " << params.fd << ") exited");
+ debugs(84, 0, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << " exited");
if (hlp->childs.needNew() > 0) {
debugs(80, 1, "Too few " << hlp->id_name << " processes are running (need " << hlp->childs.needNew() << "/" << hlp->childs.n_max << ")");