BUG/MEDIUM: tasks: make __task_unlink_rq responsible for the rqueue size.

As __task_wakeup() is responsible for increasing
rqueue_local[tid]/global_rqueue_size, make __task_unlink_rq responsible for
decreasing it, as process_runnable_tasks() isn't the only one that removes
tasks from runqueues.
diff --git a/include/proto/task.h b/include/proto/task.h
index 3969dc3..fe4699a 100644
--- a/include/proto/task.h
+++ b/include/proto/task.h
@@ -95,8 +95,11 @@
 extern THREAD_LOCAL struct eb32sc_node *rq_next; /* Next task to be potentially run */
 #ifdef USE_THREAD
 extern struct eb_root rqueue;      /* tree constituting the run queue */
+extern int global_rqueue_size; /* Number of element sin the global runqueue */
 #endif
+
 extern struct eb_root rqueue_local[MAX_THREADS]; /* tree constituting the per-thread run queue */
+extern int rqueue_size[MAX_THREADS]; /* Number of elements in the per-thread run queue */
 extern struct list task_list[MAX_THREADS]; /* List of tasks to be run, mixing tasks and tasklets */
 extern int task_list_size[MAX_THREADS]; /* Number of task sin the task_list */
 
@@ -180,9 +183,14 @@
 static inline struct task *__task_unlink_rq(struct task *t)
 {
 	HA_ATOMIC_SUB(&tasks_run_queue, 1);
-	eb32sc_delete(&t->rq);
-	if (t->state & TASK_GLOBAL)
+#ifdef USE_THREAD
+	if (t->state & TASK_GLOBAL) {
 		HA_ATOMIC_AND(&t->state, ~TASK_GLOBAL);
+		global_rqueue_size--;
+	} else
+#endif
+		rqueue_size[tid]--;
+	eb32sc_delete(&t->rq);
 	if (likely(t->nice))
 		HA_ATOMIC_SUB(&niced_tasks, 1);
 	return t;
diff --git a/src/task.c b/src/task.c
index 94482ec..11255c3 100644
--- a/src/task.c
+++ b/src/task.c
@@ -52,10 +52,10 @@
 static struct eb_root timers;      /* sorted timers tree */
 #ifdef USE_THREAD
 struct eb_root rqueue;      /* tree constituting the run queue */
-static int global_rqueue_size; /* Number of element sin the global runqueue */
+int global_rqueue_size; /* Number of element sin the global runqueue */
 #endif
 struct eb_root rqueue_local[MAX_THREADS]; /* tree constituting the per-thread run queue */
-static int rqueue_size[MAX_THREADS]; /* Number of elements in the per-thread run queue */
+int rqueue_size[MAX_THREADS]; /* Number of elements in the per-thread run queue */
 static unsigned int rqueue_ticks;  /* insertion count */
 
 /* Puts the task <t> in run queue at a position depending on t->nice. <t> is
@@ -297,7 +297,6 @@
 
 			t = eb32sc_entry(rq_next, struct task, rq);
 			rq_next = eb32sc_next(rq_next, tid_bit);
-			global_rqueue_size--;
 
 			/* detach the task from the queue */
 			__task_unlink_rq(t);
@@ -342,7 +341,6 @@
 
 		/* detach the task from the queue */
 		__task_unlink_rq(t);
-		rqueue_size[tid]--;
 		/* And add it to the local task list */
 		task_insert_into_tasklet_list(t);
 	}