extern struct list applet_runq;
+void applet_run_active();
+
/* Initializes all required fields for a new appctx. Note that it does the
* minimum acceptable initialization for an appctx. This means only the
* 3 integer states st0, st1, st2 are zeroed.
LIST_ADDQ(&applet_runq, &appctx->runq);
}
+/* removes an applet from the list of active applets */
+static inline void appctx_pause(struct appctx *appctx)
+{
+ if (!LIST_ISEMPTY(&appctx->runq)) {
+ LIST_DEL(&appctx->runq);
+ LIST_INIT(&appctx->runq);
+ }
+}
+
#endif /* _PROTO_APPLET_H */
/*
#include <common/config.h>
#include <common/mini-clist.h>
#include <proto/applet.h>
-
+#include <proto/stream.h>
+#include <proto/stream_interface.h>
struct list applet_runq = LIST_HEAD_INIT(applet_runq);
+
+void applet_run_active()
+{
+ struct appctx *curr, *back;
+ struct stream_interface *si;
+
+ list_for_each_entry_safe(curr, back, &applet_runq, runq) {
+ si = curr->owner;
+
+ /* now we'll need a buffer */
+ if (!stream_alloc_recv_buffer(si_ic(si))) {
+ si->flags |= SI_FL_WAIT_ROOM;
+ LIST_DEL(&curr->runq);
+ LIST_INIT(&curr->runq);
+ continue;
+ }
+
+ curr->applet->fct(curr);
+ /* must not dereference curr nor si now because it might have been freed */
+ }
+}
#include <types/acl.h>
#include <types/peers.h>
-#include <proto/auth.h>
#include <proto/acl.h>
+#include <proto/applet.h>
#include <proto/arg.h>
+#include <proto/auth.h>
#include <proto/backend.h>
#include <proto/channel.h>
#include <proto/checks.h>
break;
/* expire immediately if events are pending */
- if (fd_cache_num || run_queue || signal_queue_len)
+ if (fd_cache_num || run_queue || signal_queue_len || !LIST_ISEMPTY(&applet_runq))
next = now_ms;
/* The poller will ensure it returns around <next> */
cur_poller.poll(&cur_poller, next);
fd_process_cached_events();
+ applet_run_active();
}
}