str_append(str, cmd->name);
if (cmd->next != NULL)
str_append_c(str, ',');
- running_usecs += cmd->running_usecs;
- lock_wait_usecs += cmd->lock_wait_usecs;
- bytes_in += cmd->bytes_in;
- bytes_out += cmd->bytes_out;
+ running_usecs += cmd->stats.running_usecs;
+ lock_wait_usecs += cmd->stats.lock_wait_usecs;
+ bytes_in += cmd->stats.bytes_in;
+ bytes_out += cmd->stats.bytes_out;
last_cmd = cmd;
}
if (last_cmd == NULL)
ioloop_wait_usecs = io_loop_get_wait_usecs(current_ioloop);
msecs_in_ioloop = (ioloop_wait_usecs -
- last_cmd->start_ioloop_wait_usecs + 999) / 1000;
+ last_cmd->stats.start_ioloop_wait_usecs + 999) / 1000;
str_printfa(str, " running for %d.%03d + waiting %s for %d.%03d secs",
(int)((running_usecs+999)/1000 / 1000),
(int)((running_usecs+999)/1000 % 1000), cond_str,
uint64_t ioloop_wait_usecs;
unsigned int msecs_since_cmd;
- if (cmd->start_time.tv_sec == 0)
+ if (cmd->stats.start_time.tv_sec == 0)
return;
ioloop_wait_usecs = io_loop_get_wait_usecs(current_ioloop);
- msecs_in_cmd = (cmd->running_usecs + 999) / 1000;
+ msecs_in_cmd = (cmd->stats.running_usecs + 999) / 1000;
msecs_in_ioloop = (ioloop_wait_usecs -
- cmd->start_ioloop_wait_usecs + 999) / 1000;
+ cmd->stats.start_ioloop_wait_usecs + 999) / 1000;
msecs_since_cmd = timeval_diff_msecs(&ioloop_timeval,
- &cmd->last_run_timeval);
+ &cmd->stats.last_run_timeval);
if (str_data(str)[str_len(str)-1] == '.')
str_truncate(str, str_len(str)-1);
cmd = p_new(client->command_pool, struct client_command_context, 1);
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);
+ cmd->stats.start_time = ioloop_timeval;
+ cmd->stats.last_run_timeval = ioloop_timeval;
+ cmd->stats.start_ioloop_wait_usecs =
+ io_loop_get_wait_usecs(current_ioloop);
p_array_init(&cmd->module_contexts, cmd->pool, 5);
DLLIST_PREPEND(&client->command_queue, cmd);
CLIENT_COMMAND_STATE_DONE
};
+struct client_command_stats {
+ /* 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 */
+ uint64_t running_usecs;
+ /* how many usecs this command itself has spent waiting for locks */
+ uint64_t lock_wait_usecs;
+ /* how many bytes of client input/output command has used */
+ uint64_t bytes_in, bytes_out;
+};
+
struct client_command_context {
struct client_command_context *prev, *next;
struct client *client;
struct imap_parser *parser;
enum client_command_state state;
- /* 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 */
- uint64_t running_usecs;
- /* how many usecs this command itself has spent waiting for locks */
- uint64_t lock_wait_usecs;
- /* how many bytes of client input/output command has used */
- uint64_t bytes_in, bytes_out;
+ struct client_command_stats stats;
struct client_sync_context *sync;
finished = TRUE;
io_loop_time_refresh();
- cmd->running_usecs +=
+ cmd->stats.running_usecs +=
timeval_diff_usecs(&ioloop_timeval, &cmd_start_timeval);
- cmd->lock_wait_usecs +=
+ cmd->stats.lock_wait_usecs +=
file_lock_wait_get_total_usecs() - cmd_start_lock_waits;
- cmd->bytes_in += i_stream_get_absolute_offset(cmd->client->input) -
+ cmd->stats.bytes_in += i_stream_get_absolute_offset(cmd->client->input) -
cmd_start_bytes_in;
- cmd->bytes_out += cmd->client->output->offset - cmd_start_bytes_out;
+ cmd->stats.bytes_out += cmd->client->output->offset - cmd_start_bytes_out;
return finished;
}
if (cmd->cancel)
return TRUE;
- cmd->last_run_timeval = ioloop_timeval;
+ cmd->stats.last_run_timeval = ioloop_timeval;
if (client->mailbox == NULL) {
/* no mailbox selected, no point in delaying the sync */
if (tagline != NULL)