if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE)
return mail_set_aborted(mail);
- mail->transaction->stats_stat_lookup_count++;
+ mail->transaction->stats.stat_lookup_count++;
path = cydir_mail_get_path(mail);
if (stat(path, st_r) < 0) {
if (errno == ENOENT)
int fd;
if (mail->data.stream == NULL) {
- _mail->transaction->stats_open_lookup_count++;
+ _mail->transaction->stats.open_lookup_count++;
path = cydir_mail_get_path(_mail);
fd = open(path, O_RDONLY);
if (fd == -1) {
if (storage->v.mail_open(mail, &offset, &file) < 0)
return -1;
- _mail->transaction->stats_fstat_lookup_count++;
+ _mail->transaction->stats.fstat_lookup_count++;
if (dbox_file_stat(file, &st) < 0) {
if (errno == ENOENT)
mail_set_expunged(_mail);
}
if (!dbox_file_is_open(mail->open_file))
- _mail->transaction->stats_open_lookup_count++;
+ _mail->transaction->stats.open_lookup_count++;
if (dbox_file_open(mail->open_file, &deleted) <= 0)
return -1;
if (deleted) {
if (!sdbox_mail_file_set(mail)) {
if (!dbox_file_is_open(mail->open_file))
- _mail->transaction->stats_open_lookup_count++;
+ _mail->transaction->stats.open_lookup_count++;
if (dbox_file_open(mail->open_file, &deleted) <= 0)
return -1;
if (deleted) {
*value_r = index_mail_get_parsed_header(mail, field_idx);
return 0;
}
- _mail->transaction->stats_cache_hit_count++;
+ _mail->transaction->stats.cache_hit_count++;
data = buffer_get_modifiable_data(dest, &len);
if (len == 0) {
if (mail_cache_lookup_headers(_mail->transaction->cache_view, dest,
_mail->seq, headers->idx,
headers->count) > 0) {
- _mail->transaction->stats_cache_hit_count++;
+ _mail->transaction->stats.cache_hit_count++;
if (mail->data.filter_stream != NULL)
i_stream_destroy(&mail->data.filter_stream);
mail->data.filter_stream =
ret = mail_cache_lookup_field(mail->mail.mail.transaction->cache_view,
buf, mail->data.seq, field_idx);
if (ret > 0)
- mail->mail.mail.transaction->stats_cache_hit_count++;
+ mail->mail.mail.transaction->stats.cache_hit_count++;
return ret;
}
static unsigned long long
search_get_cost(struct mailbox_transaction_context *trans)
{
- return trans->stats_open_lookup_count * SEARCH_COST_DENTRY +
- trans->stats_stat_lookup_count * SEARCH_COST_DENTRY +
- trans->stats_fstat_lookup_count * SEARCH_COST_ATTR +
- trans->stats_cache_hit_count * SEARCH_COST_CACHE +
- trans->stats_files_read_count * SEARCH_COST_FILES_READ +
- (trans->stats_files_read_bytes/1024) * SEARCH_COST_KBYTE;
+ return trans->stats.open_lookup_count * SEARCH_COST_DENTRY +
+ trans->stats.stat_lookup_count * SEARCH_COST_DENTRY +
+ trans->stats.fstat_lookup_count * SEARCH_COST_ATTR +
+ trans->stats.cache_hit_count * SEARCH_COST_CACHE +
+ trans->stats.files_read_count * SEARCH_COST_FILES_READ +
+ (trans->stats.files_read_bytes/1024) * SEARCH_COST_KBYTE;
}
static int search_match_once(struct index_search_context *ctx)
ret = i_stream_read_copy_from_parent(&stream->istream);
if (ret > 0) {
- mstream->trans->stats_files_read_bytes += ret;
+ mstream->trans->stats.files_read_bytes += ret;
if (!mstream->files_read_increased) {
mstream->files_read_increased = TRUE;
- mstream->trans->stats_files_read_count++;
+ mstream->trans->stats.files_read_count++;
}
}
return ret;
ctx.fd = -1;
ctx.path = NULL;
- mail->transaction->stats_open_lookup_count++;
+ mail->transaction->stats.open_lookup_count++;
if (!mail->saving) {
if (maildir_file_do(mbox, mail->uid, do_open, &ctx) < 0)
return NULL;
}
if (imail->data.stream != NULL) {
- mail->transaction->stats_fstat_lookup_count++;
+ mail->transaction->stats.fstat_lookup_count++;
stp = i_stream_stat(imail->data.stream, FALSE);
if (stp == NULL)
return -1;
*st = *stp;
} else if (!mail->saving) {
- mail->transaction->stats_stat_lookup_count++;
+ mail->transaction->stats.stat_lookup_count++;
ret = maildir_file_do(mbox, mail->uid, do_stat, st);
if (ret <= 0) {
if (ret == 0)
return -1;
}
} else {
- mail->transaction->stats_stat_lookup_count++;
+ mail->transaction->stats.stat_lookup_count++;
path = maildir_save_file_get_path(mail->transaction, mail->seq);
if (stat(path, st) < 0) {
mail_storage_set_critical(mail->box->storage,
if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE)
return mail_set_aborted(mail);
- mail->transaction->stats_fstat_lookup_count++;
+ mail->transaction->stats.fstat_lookup_count++;
st = i_stream_stat(mail->box->input, TRUE);
if (st == NULL) {
mail_storage_set_critical(mail->box->storage,
struct mail_storage_module_register *reg;
};
+struct mailbox_transaction_stats {
+ unsigned long open_lookup_count;
+ unsigned long stat_lookup_count;
+ unsigned long fstat_lookup_count;
+ /* number of files we've opened and read */
+ unsigned long files_read_count;
+ /* number of bytes we've had to read from files */
+ unsigned long long files_read_bytes;
+ /* number of cache lookup hits */
+ unsigned long cache_hit_count;
+};
+
struct mailbox_transaction_context {
struct mailbox *box;
enum mailbox_transaction_flags flags;
struct mail_save_context *save_ctx;
/* these statistics are never reset by mail-storage API: */
-
- unsigned long stats_open_lookup_count;
- unsigned long stats_stat_lookup_count;
- unsigned long stats_fstat_lookup_count;
- /* number of files we've opened and read */
- unsigned long stats_files_read_count;
- /* number of bytes we've had to read from files */
- unsigned long long stats_files_read_bytes;
- /* number of cache lookup hits */
- unsigned long stats_cache_hit_count;
-
+ struct mailbox_transaction_stats stats;
/* Set to TRUE to update stats_* fields */
unsigned int stats_track:1;
};