]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: spoa_example: Count the number of frames processed by each worker
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 23 Jan 2018 13:46:51 +0000 (14:46 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 Feb 2018 15:00:32 +0000 (16:00 +0100)
This is done for debug purpose. This way, it is easy to know if the load is
equally distributed between workers.

contrib/spoa_example/spoa.c

index d8defd192aab61c17d51c6ce6be542913d1e2614..026f25680f8660c6b58fe651e7d423b1d63c6b12 100644 (file)
@@ -150,6 +150,7 @@ struct worker {
        struct list         clients;
 
        struct list         frames;
+       unsigned int        nbframes;
 };
 
 
@@ -1287,7 +1288,7 @@ worker_monitor_cb(evutil_socket_t fd, short events, void *arg)
 {
        struct worker *worker = arg;
 
-       LOG(worker, "%u clients connected", worker->nbclients);
+       LOG(worker, "%u clients connected (%u frames)", worker->nbclients, worker->nbframes);
 }
 
 static void
@@ -1330,7 +1331,7 @@ process_frame_cb(evutil_socket_t fd, short events, void *arg)
                                goto stop_processing;
                        if (spoe_decode_data(&p, end, &data, &type) == -1)
                                goto skip_message;
-
+                       frame->worker->nbframes++;
                        if (type == SPOE_DATA_T_IPV4)
                                check_ipv4_reputation(frame, &data.ipv4);
                        if (type == SPOE_DATA_T_IPV6)
@@ -1819,6 +1820,7 @@ main(int argc, char **argv)
 
                w->id        = i+1;
                w->nbclients = 0;
+               w->nbframes  = 0;
                LIST_INIT(&w->engines);
                LIST_INIT(&w->clients);
                LIST_INIT(&w->frames);