Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Task management functions. |
| 3 | * |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 4 | * Copyright 2000-2009 Willy Tarreau <w@1wt.eu> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 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 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 13 | #include <common/config.h> |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 14 | #include <common/eb32tree.h> |
Willy Tarreau | c6ca1a0 | 2007-05-13 19:43:47 +0200 | [diff] [blame] | 15 | #include <common/memory.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 16 | #include <common/mini-clist.h> |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 17 | #include <common/standard.h> |
Willy Tarreau | a6a6a93 | 2007-04-28 22:40:08 +0200 | [diff] [blame] | 18 | #include <common/time.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 19 | |
Willy Tarreau | d825eef | 2007-05-12 22:35:00 +0200 | [diff] [blame] | 20 | #include <proto/proxy.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 21 | #include <proto/task.h> |
| 22 | |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 23 | struct pool_head *pool2_task; |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 24 | |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 25 | unsigned int run_queue = 0; |
Willy Tarreau | 91e9993 | 2008-06-30 07:51:00 +0200 | [diff] [blame] | 26 | unsigned int niced_tasks = 0; /* number of niced tasks in the run queue */ |
Willy Tarreau | ce44f12 | 2008-07-05 18:16:19 +0200 | [diff] [blame] | 27 | struct task *last_timer = NULL; /* optimization: last queued timer */ |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 28 | |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 29 | static struct eb_root timers[TIMER_TREES]; /* trees with MSB 00, 01, 10 and 11 */ |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 30 | static struct eb_root rqueue[TIMER_TREES]; /* trees constituting the run queue */ |
| 31 | static unsigned int rqueue_ticks; /* insertion count */ |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 32 | |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 33 | /* Puts the task <t> in run queue at a position depending on t->nice. <t> is |
| 34 | * returned. The nice value assigns boosts in 32th of the run queue size. A |
| 35 | * nice value of -1024 sets the task to -run_queue*32, while a nice value of |
| 36 | * 1024 sets the task to run_queue*32. The state flags are cleared, so the |
| 37 | * caller will have to set its flags after this call. |
| 38 | * The task must not already be in the run queue. If unsure, use the safer |
| 39 | * task_wakeup() function. |
Willy Tarreau | 91e9993 | 2008-06-30 07:51:00 +0200 | [diff] [blame] | 40 | */ |
Willy Tarreau | 4df8206 | 2008-08-29 15:26:14 +0200 | [diff] [blame] | 41 | struct task *__task_wakeup(struct task *t) |
Willy Tarreau | e33aece | 2007-04-30 13:15:14 +0200 | [diff] [blame] | 42 | { |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 43 | run_queue++; |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 44 | t->rq.key = ++rqueue_ticks; |
Willy Tarreau | 91e9993 | 2008-06-30 07:51:00 +0200 | [diff] [blame] | 45 | |
| 46 | if (likely(t->nice)) { |
| 47 | int offset; |
| 48 | |
| 49 | niced_tasks++; |
| 50 | if (likely(t->nice > 0)) |
| 51 | offset = (unsigned)((run_queue * (unsigned int)t->nice) / 32U); |
| 52 | else |
| 53 | offset = -(unsigned)((run_queue * (unsigned int)-t->nice) / 32U); |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 54 | t->rq.key += offset; |
Willy Tarreau | 91e9993 | 2008-06-30 07:51:00 +0200 | [diff] [blame] | 55 | } |
| 56 | |
Willy Tarreau | fdccded | 2008-08-29 18:19:04 +0200 | [diff] [blame] | 57 | /* clear state flags at the same time */ |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 58 | t->state &= ~TASK_WOKEN_ANY; |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 59 | |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 60 | eb32_insert(&rqueue[timer_to_tree(t->rq.key)], &t->rq); |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 61 | return t; |
Willy Tarreau | e33aece | 2007-04-30 13:15:14 +0200 | [diff] [blame] | 62 | } |
Willy Tarreau | d825eef | 2007-05-12 22:35:00 +0200 | [diff] [blame] | 63 | |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 64 | /* |
| 65 | * task_queue() |
| 66 | * |
| 67 | * Inserts a task into the wait queue at the position given by its expiration |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 68 | * date. It does not matter if the task was already in the wait queue or not, |
| 69 | * and it may even help if its position has not changed because we'll be able |
| 70 | * to return without doing anything. Tasks queued with an eternity expiration |
| 71 | * are just unlinked from the WQ. Last, tasks must not be queued further than |
| 72 | * the end of the next tree, which is between <now_ms> and <now_ms> + |
| 73 | * TIMER_SIGN_BIT ms (now+12days..24days in 32bit). |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 74 | */ |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 75 | void task_queue(struct task *task) |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 76 | { |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 77 | /* if the task is already in the wait queue, we may reuse its position |
| 78 | * or we will at least have to unlink it first. |
| 79 | */ |
| 80 | if (task_in_wq(task)) { |
Willy Tarreau | 4136522 | 2009-03-08 07:46:27 +0100 | [diff] [blame] | 81 | /* If we already have a place in the wait queue no later than the |
| 82 | * timeout we're trying to set, we'll stay there, because it is very |
| 83 | * unlikely that we will reach the timeout anyway. If the timeout |
| 84 | * has been disabled, it's useless to leave the queue as well. We'll |
| 85 | * rely on wake_expired_tasks() to catch the node and move it to the |
| 86 | * proper place should it ever happen. |
| 87 | */ |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 88 | if (!tick_isset(task->expire) || |
| 89 | ((task->wq.key - tick_to_timer(task->expire)) & TIMER_SIGN_BIT)) |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 90 | return; |
| 91 | __task_unlink_wq(task); |
| 92 | } |
| 93 | |
| 94 | /* the task is not in the queue now */ |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 95 | if (unlikely(!tick_isset(task->expire))) |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 96 | return; |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 97 | |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 98 | task->wq.key = tick_to_timer(task->expire); |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 99 | #ifdef DEBUG_CHECK_INVALID_EXPIRATION_DATES |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 100 | if ((task->wq.key - tick_to_timer(now_ms)) & TIMER_SIGN_BIT) |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 101 | /* we're queuing too far away or in the past (most likely) */ |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 102 | return; |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 103 | #endif |
Willy Tarreau | ce44f12 | 2008-07-05 18:16:19 +0200 | [diff] [blame] | 104 | |
| 105 | if (likely(last_timer && |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 106 | last_timer->wq.key == task->wq.key && |
| 107 | last_timer->wq.node.node_p && |
| 108 | last_timer->wq.node.bit == -1)) { |
Willy Tarreau | ce44f12 | 2008-07-05 18:16:19 +0200 | [diff] [blame] | 109 | /* Most often, last queued timer has the same expiration date, so |
| 110 | * if it's not queued at the root, let's queue a dup directly there. |
Willy Tarreau | 1b8ca66 | 2009-03-08 00:26:28 +0100 | [diff] [blame] | 111 | * Note that we can only use dups at the dup tree's root (bit==-1). |
Willy Tarreau | ce44f12 | 2008-07-05 18:16:19 +0200 | [diff] [blame] | 112 | */ |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 113 | eb_insert_dup(&last_timer->wq.node, &task->wq.node); |
| 114 | return; |
Willy Tarreau | ce44f12 | 2008-07-05 18:16:19 +0200 | [diff] [blame] | 115 | } |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 116 | eb32_insert(&timers[timer_to_tree(task->wq.key)], &task->wq); |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 117 | if (task->wq.node.bit == -1) |
Willy Tarreau | 1b8ca66 | 2009-03-08 00:26:28 +0100 | [diff] [blame] | 118 | last_timer = task; /* we only want dup a tree's root */ |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 119 | return; |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 120 | } |
| 121 | |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 122 | /* |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 123 | * Extract all expired timers from the timer queue, and wakes up all |
Willy Tarreau | d825eef | 2007-05-12 22:35:00 +0200 | [diff] [blame] | 124 | * associated tasks. Returns the date of next event (or eternity). |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 125 | */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 126 | void wake_expired_tasks(int *next) |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 127 | { |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 128 | struct task *task; |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 129 | struct eb32_node *eb; |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 130 | unsigned int now_tree; |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 131 | unsigned int tree; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 132 | |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 133 | /* In theory, we should : |
| 134 | * - wake all tasks from the <previous> tree |
| 135 | * - wake all expired tasks from the <current> tree |
| 136 | * - scan <next> trees for next expiration date if not found earlier. |
| 137 | * But we can do all this more easily : we scan all 3 trees before we |
| 138 | * wrap, and wake everything expired from there, then stop on the first |
| 139 | * non-expired entry. |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 140 | */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 141 | |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 142 | now_tree = timer_to_tree(tick_to_timer(now_ms)); |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 143 | tree = (now_tree - 1) & TIMER_TREE_MASK; |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 144 | do { |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 145 | eb = eb32_first(&timers[tree]); |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 146 | while (eb) { |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 147 | task = eb32_entry(eb, struct task, wq); |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 148 | if ((tick_to_timer(now_ms) - eb->key) & TIMER_SIGN_BIT) { |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 149 | /* note that we don't need this check for the <previous> |
| 150 | * tree, but it's cheaper than duplicating the code. |
| 151 | */ |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 152 | *next = timer_to_tick(eb->key); |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 153 | return; |
| 154 | } |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 155 | |
Willy Tarreau | af754fc | 2008-06-29 19:25:52 +0200 | [diff] [blame] | 156 | /* detach the task from the queue and add the task to the run queue */ |
| 157 | eb = eb32_next(eb); |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 158 | __task_unlink_wq(task); |
Willy Tarreau | 4136522 | 2009-03-08 07:46:27 +0100 | [diff] [blame] | 159 | |
| 160 | /* It is possible that this task was left at an earlier place in the |
| 161 | * tree because a recent call to task_queue() has not moved it. This |
| 162 | * happens when the new expiration date is later than the old one. |
| 163 | * Since it is very unlikely that we reach a timeout anyway, it's a |
| 164 | * lot cheaper to proceed like this because we almost never update |
| 165 | * the tree. We may also find disabled expiration dates there. Since |
| 166 | * we have detached the task from the tree, we simply call task_queue |
| 167 | * to take care of this. |
| 168 | */ |
| 169 | if (!tick_is_expired(task->expire, now_ms)) { |
| 170 | task_queue(task); |
| 171 | continue; |
| 172 | } |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 173 | task_wakeup(task, TASK_WOKEN_TIMER); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 174 | } |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 175 | tree = (tree + 1) & TIMER_TREE_MASK; |
| 176 | } while (((tree - now_tree) & TIMER_TREE_MASK) < TIMER_TREES/2); |
Willy Tarreau | 9789f7b | 2008-06-24 08:17:16 +0200 | [diff] [blame] | 177 | |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 178 | /* We have found no task to expire in any tree */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 179 | *next = TICK_ETERNITY; |
Willy Tarreau | 28c41a4 | 2008-06-29 17:00:59 +0200 | [diff] [blame] | 180 | return; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 181 | } |
| 182 | |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 183 | /* The run queue is chronologically sorted in a tree. An insertion counter is |
| 184 | * used to assign a position to each task. This counter may be combined with |
| 185 | * other variables (eg: nice value) to set the final position in the tree. The |
| 186 | * counter may wrap without a problem, of course. We then limit the number of |
Willy Tarreau | 91e9993 | 2008-06-30 07:51:00 +0200 | [diff] [blame] | 187 | * tasks processed at once to 1/4 of the number of tasks in the queue, and to |
| 188 | * 200 max in any case, so that general latency remains low and so that task |
| 189 | * positions have a chance to be considered. It also reduces the number of |
| 190 | * trees to be evaluated when no task remains. |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 191 | * |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 192 | * Just like with timers, we start with tree[(current - 1)], which holds past |
| 193 | * values, and stop when we reach the middle of the list. In practise, we visit |
| 194 | * 3 out of 4 trees. |
| 195 | * |
| 196 | * The function adjusts <next> if a new event is closer. |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 197 | */ |
Willy Tarreau | 0c303ee | 2008-07-07 00:09:58 +0200 | [diff] [blame] | 198 | void process_runnable_tasks(int *next) |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 199 | { |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 200 | struct task *t; |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 201 | struct eb32_node *eb; |
| 202 | unsigned int tree, stop; |
| 203 | unsigned int max_processed; |
Willy Tarreau | 26c2506 | 2009-03-08 09:38:41 +0100 | [diff] [blame] | 204 | int expire; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 205 | |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 206 | if (!run_queue) |
| 207 | return; |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 208 | |
Willy Tarreau | 91e9993 | 2008-06-30 07:51:00 +0200 | [diff] [blame] | 209 | max_processed = run_queue; |
| 210 | if (max_processed > 200) |
| 211 | max_processed = 200; |
| 212 | |
| 213 | if (likely(niced_tasks)) |
| 214 | max_processed /= 4; |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 215 | |
Willy Tarreau | d0a201b | 2009-03-08 15:53:06 +0100 | [diff] [blame^] | 216 | tree = timer_to_tree(rqueue_ticks); |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 217 | stop = (tree + TIMER_TREES / 2) & TIMER_TREE_MASK; |
| 218 | tree = (tree - 1) & TIMER_TREE_MASK; |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 219 | |
Willy Tarreau | 26c2506 | 2009-03-08 09:38:41 +0100 | [diff] [blame] | 220 | expire = *next; |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 221 | do { |
| 222 | eb = eb32_first(&rqueue[tree]); |
| 223 | while (eb) { |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 224 | t = eb32_entry(eb, struct task, rq); |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 225 | |
| 226 | /* detach the task from the queue and add the task to the run queue */ |
| 227 | eb = eb32_next(eb); |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 228 | __task_unlink_rq(t); |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 229 | |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 230 | t->state |= TASK_RUNNING; |
Willy Tarreau | 26c2506 | 2009-03-08 09:38:41 +0100 | [diff] [blame] | 231 | if (likely(t->process(t) != NULL)) { |
| 232 | t->state &= ~TASK_RUNNING; |
| 233 | expire = tick_first(expire, t->expire); |
| 234 | task_queue(t); |
| 235 | } |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 236 | |
| 237 | if (!--max_processed) |
Willy Tarreau | 26c2506 | 2009-03-08 09:38:41 +0100 | [diff] [blame] | 238 | goto out; |
Willy Tarreau | 58b458d | 2008-06-29 22:40:23 +0200 | [diff] [blame] | 239 | } |
| 240 | tree = (tree + 1) & TIMER_TREE_MASK; |
| 241 | } while (tree != stop); |
Willy Tarreau | 26c2506 | 2009-03-08 09:38:41 +0100 | [diff] [blame] | 242 | out: |
| 243 | *next = expire; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 244 | } |
| 245 | |
Willy Tarreau | 4726f53 | 2009-03-07 17:25:21 +0100 | [diff] [blame] | 246 | /* perform minimal intializations, report 0 in case of error, 1 if OK. */ |
| 247 | int init_task() |
| 248 | { |
| 249 | memset(&timers, 0, sizeof(timers)); |
| 250 | memset(&rqueue, 0, sizeof(rqueue)); |
| 251 | pool2_task = create_pool("task", sizeof(struct task), MEM_F_SHARED); |
| 252 | return pool2_task != NULL; |
| 253 | } |
| 254 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 255 | /* |
| 256 | * Local variables: |
| 257 | * c-indent-level: 8 |
| 258 | * c-basic-offset: 8 |
| 259 | * End: |
| 260 | */ |