#include <types/applet.h>
#include <proto/connection.h>
+extern unsigned int nb_applets;
+extern unsigned int applets_active_queue;
+
extern struct list applet_active_queue;
void applet_run_active();
appctx->applet = applet;
appctx_init(appctx);
LIST_INIT(&appctx->runq);
+ nb_applets++;
}
return appctx;
}
*/
static inline void appctx_free(struct appctx *appctx)
{
- if (!LIST_ISEMPTY(&appctx->runq))
+ if (!LIST_ISEMPTY(&appctx->runq)) {
LIST_DEL(&appctx->runq);
+ applets_active_queue--;
+ }
pool_free2(pool2_connection, appctx);
+ nb_applets--;
}
/* wakes up an applet when conditions have changed */
static inline void appctx_wakeup(struct appctx *appctx)
{
- if (LIST_ISEMPTY(&appctx->runq))
+ if (LIST_ISEMPTY(&appctx->runq)) {
LIST_ADDQ(&applet_active_queue, &appctx->runq);
+ applets_active_queue++;
+ }
}
/* removes an applet from the list of active applets */
if (!LIST_ISEMPTY(&appctx->runq)) {
LIST_DEL(&appctx->runq);
LIST_INIT(&appctx->runq);
+ applets_active_queue--;
}
}
#include <proto/stream.h>
#include <proto/stream_interface.h>
+unsigned int nb_applets = 0;
+unsigned int applets_active_queue = 0;
+
struct list applet_active_queue = LIST_HEAD_INIT(applet_active_queue);
-struct list applet_run_queue = LIST_HEAD_INIT(applet_run_queue);
+struct list applet_cur_queue = LIST_HEAD_INIT(applet_cur_queue);
void applet_run_active()
{
return;
/* move active queue to run queue */
- applet_active_queue.n->p = &applet_run_queue;
- applet_active_queue.p->n = &applet_run_queue;
+ applet_active_queue.n->p = &applet_cur_queue;
+ applet_active_queue.p->n = &applet_cur_queue;
- applet_run_queue = applet_active_queue;
+ applet_cur_queue = applet_active_queue;
LIST_INIT(&applet_active_queue);
/* The list is only scanned from the head. This guarantees that if any
* applet removes another one, there is no side effect while walking
* through the list.
*/
- while (!LIST_ISEMPTY(&applet_run_queue)) {
- curr = LIST_ELEM(applet_run_queue.n, typeof(curr), runq);
+ while (!LIST_ISEMPTY(&applet_cur_queue)) {
+ curr = LIST_ELEM(applet_cur_queue.n, typeof(curr), runq);
si = curr->owner;
/* now we'll need a buffer */
curr->applet->fct(curr);
si_applet_wake_cb(si);
- if (applet_run_queue.n == &curr->runq) {
+ if (applet_cur_queue.n == &curr->runq) {
/* curr was left in the list, move it back to the active list */
LIST_DEL(&curr->runq);
LIST_ADDQ(&applet_active_queue, &curr->runq);