MAJOR: poll: only rely on wake_expired_tasks() to compute the wait delay

Actually, HAProxy uses the function "process_runnable_tasks" and
"wake_expired_tasks" to get the next task which can expires.

If a task is added with "task_schedule" or other method during
the execution of an other task, the expiration of this new task
is not taken into account, and the execution of this task can be
too late.

Actualy, HAProxy seems to be no sensitive to this bug.

This fix moves the call to process_runnable_tasks() before the timeout
calculation and ensures that all wakeups are processed together. Only
wake_expired_tasks() needs to return a timeout now.
diff --git a/src/task.c b/src/task.c
index 74ae1c9..4985aa2 100644
--- a/src/task.c
+++ b/src/task.c
@@ -118,9 +118,9 @@
 
 /*
  * Extract all expired timers from the timer queue, and wakes up all
- * associated tasks. Returns the date of next event (or eternity) in <next>.
+ * associated tasks. Returns the date of next event (or eternity).
  */
-void wake_expired_tasks(int *next)
+int wake_expired_tasks()
 {
 	struct task *task;
 	struct eb32_node *eb;
@@ -139,8 +139,7 @@
 
 		if (likely(tick_is_lt(now_ms, eb->key))) {
 			/* timer not expired yet, revisit it later */
-			*next = eb->key;
-			return;
+			return eb->key;
 		}
 
 		/* timer looks expired, detach it from the queue */
@@ -172,9 +171,8 @@
 		task_wakeup(task, TASK_WOKEN_TIMER);
 	}
 
-	/* We have found no task to expire in any tree */
-	*next = TICK_ETERNITY;
-	return;
+	/* No task is expired */
+	return TICK_ETERNITY;
 }
 
 /* The run queue is chronologically sorted in a tree. An insertion counter is
@@ -187,11 +185,10 @@
  *
  * The function adjusts <next> if a new event is closer.
  */
-void process_runnable_tasks(int *next)
+void process_runnable_tasks()
 {
 	struct task *t;
 	unsigned int max_processed;
-	int expire;
 
 	run_queue_cur = run_queue; /* keep a copy for reporting */
 	nb_tasks_cur = nb_tasks;
@@ -206,8 +203,6 @@
 	if (likely(niced_tasks))
 		max_processed = (max_processed + 3) / 4;
 
-	expire = *next;
-
 	while (max_processed--) {
 		/* Note: this loop is one of the fastest code path in
 		 * the whole program. It should not be re-arranged
@@ -245,13 +240,10 @@
 
 		if (likely(t != NULL)) {
 			t->state &= ~TASK_RUNNING;
-			if (t->expire) {
+			if (t->expire)
 				task_queue(t);
-				expire = tick_first_2nz(expire, t->expire);
-			}
 		}
 	}
-	*next = expire;
 }
 
 /* perform minimal intializations, report 0 in case of error, 1 if OK. */