From: Timo Sirainen Date: Wed, 15 Jul 2009 22:29:21 +0000 (-0400) Subject: Added mail_transaction_log_get_tail(). X-Git-Tag: 2.0.alpha1~417 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ee5f5427b36ea30a01561b35f4002232db7b061;p=thirdparty%2Fdovecot%2Fcore.git Added mail_transaction_log_get_tail(). --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index 9fc6e9de43..dc1debeab4 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -487,6 +487,18 @@ void mail_transaction_log_get_head(struct mail_transaction_log *log, *file_offset_r = log->head->sync_offset; } +void mail_transaction_log_get_tail(struct mail_transaction_log *log, + uint32_t *file_seq_r) +{ + struct mail_transaction_log_file *tail, *file = log->files; + + for (tail = file; file->next != NULL; file = file->next) { + if (file->hdr.file_seq + 1 != file->next->hdr.file_seq) + tail = file->next; + } + *file_seq_r = tail->hdr.file_seq; +} + bool mail_transaction_log_is_head_prev(struct mail_transaction_log *log, uint32_t file_seq, uoff_t file_offset) { diff --git a/src/lib-index/mail-transaction-log.h b/src/lib-index/mail-transaction-log.h index 3e43340fe3..3566e20773 100644 --- a/src/lib-index/mail-transaction-log.h +++ b/src/lib-index/mail-transaction-log.h @@ -245,6 +245,9 @@ void mail_transaction_log_sync_unlock(struct mail_transaction_log *log); /* Returns the current head. Works only when log is locked. */ void mail_transaction_log_get_head(struct mail_transaction_log *log, uint32_t *file_seq_r, uoff_t *file_offset_r); +/* Returns the current tail from which all files are open to head. */ +void mail_transaction_log_get_tail(struct mail_transaction_log *log, + uint32_t *file_seq_r); /* Returns TRUE if given seq/offset is current head log's rotate point. */ bool mail_transaction_log_is_head_prev(struct mail_transaction_log *log, uint32_t file_seq, uoff_t file_offset);