2015-04-13 15:11:11 +00:00
|
|
|
/*
|
|
|
|
* Functions managing applets
|
|
|
|
*
|
|
|
|
* Copyright 2000-2015 Willy Tarreau <w@1wt.eu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <common/config.h>
|
|
|
|
#include <common/mini-clist.h>
|
|
|
|
#include <proto/applet.h>
|
2015-04-19 07:59:31 +00:00
|
|
|
#include <proto/stream.h>
|
|
|
|
#include <proto/stream_interface.h>
|
2015-04-13 15:11:11 +00:00
|
|
|
|
2015-09-25 15:39:23 +00:00
|
|
|
struct list applet_active_queue = LIST_HEAD_INIT(applet_active_queue);
|
2015-04-19 07:59:31 +00:00
|
|
|
|
|
|
|
void applet_run_active()
|
|
|
|
{
|
|
|
|
struct appctx *curr, *back;
|
|
|
|
struct stream_interface *si;
|
|
|
|
|
2015-09-25 15:39:23 +00:00
|
|
|
list_for_each_entry_safe(curr, back, &applet_active_queue, runq) {
|
2015-04-19 07:59:31 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-04-21 17:23:39 +00:00
|
|
|
/* We always pretend the applet can't get and doesn't want to
|
|
|
|
* put, it's up to it to change this if needed. This ensures
|
|
|
|
* that one applet which ignores any event will not spin.
|
|
|
|
*/
|
|
|
|
si_applet_cant_get(si);
|
|
|
|
si_applet_stop_put(si);
|
|
|
|
|
2015-04-19 07:59:31 +00:00
|
|
|
curr->applet->fct(curr);
|
2015-04-19 23:31:23 +00:00
|
|
|
si_applet_done(si);
|
2015-04-19 07:59:31 +00:00
|
|
|
}
|
|
|
|
}
|