From: Timo Sirainen Date: Mon, 24 Oct 2016 09:16:48 +0000 (+0300) Subject: lib: Added ioloop_global_wait_usecs X-Git-Tag: 2.2.26~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f820a25aa0e27a087a3b7085f75165b65a7f67b8;p=thirdparty%2Fdovecot%2Fcore.git lib: Added ioloop_global_wait_usecs This is helpful when multiple ioloops aren't used and io_loop_get_wait_usecs() can't be easily used for all of them. --- diff --git a/src/lib/ioloop.c b/src/lib/ioloop.c index 2a12d9c7ee..f8d1901fa2 100644 --- a/src/lib/ioloop.c +++ b/src/lib/ioloop.c @@ -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; diff --git a/src/lib/ioloop.h b/src/lib/ioloop.h index 4db2903482..c33d841064 100644 --- a/src/lib/ioloop.h +++ b/src/lib/ioloop.h @@ -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).