]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Include sync timing information in tagged command replies.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 16 May 2016 21:00:43 +0000 (00:00 +0300)
committerGitLab <gitlab@git.dovecot.net>
Tue, 17 May 2016 20:56:23 +0000 (23:56 +0300)
Show it only when it's larger than 0 to avoid unnecessary output.

src/imap/imap-client.c
src/imap/imap-client.h
src/imap/imap-sync.c

index 6392d5ff76f10814e0cdcf799843d8c8f22eea27..b5046015643f4c778701d522445a73c299685f77 100644 (file)
@@ -480,6 +480,7 @@ client_cmd_append_timing_stats(struct client_command_context *cmd,
 {
        unsigned int msecs_in_cmd, msecs_in_ioloop;
        uint64_t ioloop_wait_usecs;
+       unsigned int msecs_since_cmd;
 
        if (cmd->start_time.tv_sec == 0)
                return;
@@ -488,12 +489,19 @@ client_cmd_append_timing_stats(struct client_command_context *cmd,
        msecs_in_cmd = (cmd->running_usecs + 999) / 1000;
        msecs_in_ioloop = (ioloop_wait_usecs -
                           cmd->start_ioloop_wait_usecs + 999) / 1000;
+       msecs_since_cmd = timeval_diff_msecs(&ioloop_timeval,
+                                            &cmd->last_run_timeval);
 
        if (str_data(str)[str_len(str)-1] == '.')
                str_truncate(str, str_len(str)-1);
-       str_printfa(str, " (%d.%03d + %d.%03d secs).",
+       str_printfa(str, " (%d.%03d + %d.%03d ",
                    msecs_in_cmd / 1000, msecs_in_cmd % 1000,
                    msecs_in_ioloop / 1000, msecs_in_ioloop % 1000);
+       if (msecs_since_cmd > 0) {
+               str_printfa(str, "+ %d.%03d ",
+                           msecs_since_cmd / 1000, msecs_since_cmd % 1000);
+       }
+       str_append(str, "secs).");
 }
 
 void client_send_tagline(struct client_command_context *cmd, const char *data)
@@ -721,6 +729,7 @@ struct client_command_context *client_command_alloc(struct client *client)
        cmd->client = client;
        cmd->pool = client->command_pool;
        cmd->start_time = ioloop_timeval;
+       cmd->last_run_timeval = ioloop_timeval;
        cmd->start_ioloop_wait_usecs = io_loop_get_wait_usecs(current_ioloop);
        p_array_init(&cmd->module_contexts, cmd->pool, 5);
 
index 394b59cc19d867c894472e5764e10c59f5f97ed8..9b5415e26f20fd83232658c72061e3c7e123fc97 100644 (file)
@@ -79,6 +79,9 @@ struct client_command_context {
        /* time when command handling was started - typically this is after
           reading all the parameters. */
        struct timeval start_time;
+       /* time when command handling was last finished. this is before
+          mailbox syncing is done. */
+       struct timeval last_run_timeval;
        /* io_loop_get_wait_usecs()'s value when the command was started */
        uint64_t start_ioloop_wait_usecs;
        /* how many usecs this command itself has spent running */
index 50ef1f3048a3056782036c5a6a7d094042ccc6ac..27f31d054301eeaddebdf5886a54975e9e0a349f 100644 (file)
@@ -762,6 +762,7 @@ bool cmd_sync(struct client_command_context *cmd, enum mailbox_sync_flags flags,
        if (cmd->cancel)
                return TRUE;
 
+       cmd->last_run_timeval = ioloop_timeval;
        if (client->mailbox == NULL) {
                /* no mailbox selected, no point in delaying the sync */
                if (tagline != NULL)