Willy Tarreau | 81f38d6 | 2015-04-13 17:11:11 +0200 | [diff] [blame] | 1 | /* |
| 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 Tarreau | 3c595ac | 2015-04-19 09:59:31 +0200 | [diff] [blame] | 19 | #include <proto/stream.h> |
| 20 | #include <proto/stream_interface.h> |
Willy Tarreau | 81f38d6 | 2015-04-13 17:11:11 +0200 | [diff] [blame] | 21 | |
| 22 | struct list applet_runq = LIST_HEAD_INIT(applet_runq); |
Willy Tarreau | 3c595ac | 2015-04-19 09:59:31 +0200 | [diff] [blame] | 23 | |
| 24 | void 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 Tarreau | fe12793 | 2015-04-21 19:23:39 +0200 | [diff] [blame^] | 40 | /* 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 Tarreau | 3c595ac | 2015-04-19 09:59:31 +0200 | [diff] [blame] | 47 | curr->applet->fct(curr); |
Willy Tarreau | d4da196 | 2015-04-20 01:31:23 +0200 | [diff] [blame] | 48 | si_applet_done(si); |
Willy Tarreau | 3c595ac | 2015-04-19 09:59:31 +0200 | [diff] [blame] | 49 | } |
| 50 | } |