]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Added ioloop_global_wait_usecs
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 24 Oct 2016 09:16:48 +0000 (12:16 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 24 Oct 2016 11:26:19 +0000 (14:26 +0300)
This is helpful when multiple ioloops aren't used and
io_loop_get_wait_usecs() can't be easily used for all of them.

src/lib/ioloop.c
src/lib/ioloop.h

index 2a12d9c7ee38be71b025e7e0f76f886adb2097ea..f8d1901fa27e09584c18bb1eba85117b9dce1368 100644 (file)
@@ -15,8 +15,9 @@
 
 time_t ioloop_time = 0;
 struct timeval ioloop_timeval;
-
 struct ioloop *current_ioloop = NULL;
+uint64_t ioloop_global_wait_usecs = 0;
+
 static ARRAY(io_switch_callback_t *) io_switch_callbacks = ARRAY_INIT;
 
 static void io_loop_initialize_handler(struct ioloop *ioloop)
@@ -524,8 +525,10 @@ static void io_loop_handle_timeouts_real(struct ioloop *ioloop)
                        ioloop->time_moved_callback(ioloop->next_max_time,
                                                    ioloop_timeval.tv_sec);
                }
-               ioloop->ioloop_wait_usecs +=
+               long long diff =
                        timeval_diff_usecs(&ioloop_timeval, &prev_ioloop_timeval);
+               ioloop->ioloop_wait_usecs += diff;
+               ioloop_global_wait_usecs += diff;
        }
 
        ioloop_time = ioloop_timeval.tv_sec;
index 4db290348222a7c2c150637b7c029ea8e7794106..c33d841064635e3807d23691d4b46370e02ed064 100644 (file)
@@ -41,6 +41,8 @@ extern time_t ioloop_time;
 extern struct timeval ioloop_timeval;
 
 extern struct ioloop *current_ioloop;
+/* Number of microseconds spent on all the ioloops waiting for themselves. */
+extern uint64_t ioloop_global_wait_usecs;
 
 /* You can create different handlers for IO_READ and IO_WRITE. IO_READ and
    IO_ERROR can't use different handlers (and there's no point anyway).