]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] show sess: report number of calls to each task
authorWilly Tarreau <w@1wt.eu>
Sat, 28 Mar 2009 16:54:35 +0000 (17:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 28 Mar 2009 16:54:35 +0000 (17:54 +0100)
For debugging purposes, it can be useful to know how many times each
task has been called.

include/proto/task.h
include/types/task.h
src/dumpstats.c
src/task.c

index 19aab61679e375bbc5f17eefd5387719459bd4ca..62f83e3f54f6e4bd719cdaaf05ad96c631e75899 100644 (file)
@@ -173,6 +173,7 @@ static inline struct task *task_init(struct task *t)
        t->rq.node.leaf_p = NULL;
        t->state = TASK_SLEEPING;
        t->nice = 0;
+       t->calls = 0;
        return t;
 }
 
index 13e2aacd1f5d174bc418482b550ba61f3f7aa852..641cb17cd9ce0fe62fd08b33e9ac6336033adefd 100644 (file)
@@ -50,6 +50,7 @@ struct task {
        struct eb32_node rq;            /* ebtree node used to hold the task in the run queue */
        int state;                      /* task state : bit field of TASK_* */
        int expire;                     /* next expiration date for this task, in ticks */
+       unsigned int calls;             /* number of times ->process() was called */
        struct task * (*process)(struct task *t);  /* the function which processes the task */
        void *context;                  /* the task's context */
        int nice;                       /* the task's current nice value from -1024 to +1024 */
index fd38f95ddfdd16ab13bdc0ffbb07e5b0d83ebe7c..2178f7949fdfda259508223c2018dff2feab475c 100644 (file)
@@ -1209,10 +1209,11 @@ void stats_dump_sess_to_buffer(struct session *s, struct buffer *rep)
                        }
 
                        chunk_printf(&msg, sizeof(trash),
-                                    " si=(%d,%d) as=%d ts=%02x age=%s",
+                                    " si=(%d,%d) as=%d ts=%02x age=%s calls=%d",
                                     curr_sess->si[0].state, curr_sess->si[1].state,
                                     curr_sess->ana_state, curr_sess->task->state,
-                                    human_time(now.tv_sec - curr_sess->logs.tv_accept.tv_sec, 1));
+                                    human_time(now.tv_sec - curr_sess->logs.tv_accept.tv_sec, 1),
+                                    curr_sess->task->calls);
 
                        if (task_in_rq(curr_sess->task))
                                chunk_printf(&msg, sizeof(trash), " run(nice=%d)\n", curr_sess->task->nice);
index 95a00faed264b309a2e22c534d92c1d47b31a1fa..5336c20e9db6ad1a845eb8221df2adcbe3b08cc4 100644 (file)
@@ -219,6 +219,7 @@ void process_runnable_tasks(int *next)
                /* This is an optimisation to help the processor's branch
                 * predictor take this most common call.
                 */
+               t->calls++;
                if (likely(t->process == process_session))
                        t = process_session(t);
                else