]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
dtio_find_msg loop roundrobin instead of first queue only, with
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 23 Jan 2020 09:34:38 +0000 (10:34 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Thu, 23 Jan 2020 09:34:38 +0000 (10:34 +0100)
state in the dtio struct for loop iterator.

dnstap/dtstream.c
dnstap/dtstream.h

index e414d5d02517d54e08e92f1d9daba87a6a419551..c3270a00822cd6a35541acf670fbd8cf44937bb4 100644 (file)
@@ -221,6 +221,7 @@ int dt_io_thread_register_queue(struct dt_io_thread* dtio,
        item->queue = mq;
        item->next = dtio->io_list;
        dtio->io_list = item;
+       dtio->io_list_iter = NULL;
        return 1;
 }
 
@@ -235,6 +236,7 @@ void dt_io_thread_unregister_queue(struct dt_io_thread* dtio,
                        else dtio->io_list = item->next;
                        /* the queue itself only registered, not deleted */
                        free(item);
+                       dtio->io_list_iter = NULL;
                        return;
                }
                prev = item;
@@ -283,7 +285,16 @@ static int dtio_find_in_queue(struct dt_io_thread* dtio,
 /** find a new message to write, search message queues, false if none */
 static int dtio_find_msg(struct dt_io_thread* dtio)
 {
-       struct dt_io_list_item* item = dtio->io_list;
+       struct dt_io_list_item* item;
+
+       if(dtio->io_list_iter)
+               item = dtio->io_list_iter;
+       else    item = dtio->io_list;
+       /* use the next queue for the next message lookup,
+        * if we hit the end(NULL) the NULL restarts the iter at start. */
+       if(item)
+               dtio->io_list_iter = item->next;
+
        while(item) {
                if(dtio_find_in_queue(dtio, item->queue))
                        return 1;
index 7641ffbd6db6e6b34cfb82e82343a766d2eb107a..3c5bd9a4e8abc4e5b18368485a4d7b70ce82a003 100644 (file)
@@ -93,6 +93,10 @@ struct dt_io_thread {
        void* event_base;
        /** list of queues that is registered to get written */
        struct dt_io_list_item* io_list;
+       /** iterator point in the io_list, to pick from them in a
+        * round-robin fashion, instead of only from the first when busy.
+        * if NULL it means start at the start of the list. */
+       struct dt_io_list_item* io_list_iter;
        /** thread id, of the io thread */
        ub_thread_type tid;
        /** file descriptor that the thread writes to */