blob: 481000a80b4296896ab9239580e9e83fb994b3bf [file] [log] [blame]
Willy Tarreau81f38d62015-04-13 17:11:11 +02001/*
2 * Functions managing applets
3 *
4 * Copyright 2000-2015 Willy Tarreau <w@1wt.eu>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#include <stdio.h>
14#include <stdlib.h>
15
16#include <common/config.h>
17#include <common/mini-clist.h>
18#include <proto/applet.h>
Willy Tarreau3c595ac2015-04-19 09:59:31 +020019#include <proto/stream.h>
20#include <proto/stream_interface.h>
Willy Tarreau81f38d62015-04-13 17:11:11 +020021
22struct list applet_runq = LIST_HEAD_INIT(applet_runq);
Willy Tarreau3c595ac2015-04-19 09:59:31 +020023
24void applet_run_active()
25{
26 struct appctx *curr, *back;
27 struct stream_interface *si;
28
29 list_for_each_entry_safe(curr, back, &applet_runq, runq) {
30 si = curr->owner;
31
32 /* now we'll need a buffer */
33 if (!stream_alloc_recv_buffer(si_ic(si))) {
34 si->flags |= SI_FL_WAIT_ROOM;
35 LIST_DEL(&curr->runq);
36 LIST_INIT(&curr->runq);
37 continue;
38 }
39
Willy Tarreaufe127932015-04-21 19:23:39 +020040 /* We always pretend the applet can't get and doesn't want to
41 * put, it's up to it to change this if needed. This ensures
42 * that one applet which ignores any event will not spin.
43 */
44 si_applet_cant_get(si);
45 si_applet_stop_put(si);
46
Willy Tarreau3c595ac2015-04-19 09:59:31 +020047 curr->applet->fct(curr);
Willy Tarreaud4da1962015-04-20 01:31:23 +020048 si_applet_done(si);
Willy Tarreau3c595ac2015-04-19 09:59:31 +020049 }
50}