mail-transaction-log-private.h revision 366eb7178f2c90d97134e0c2d1958f93fcdaba12
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen/* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*32)
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen/* If log is larger than MAX_SIZE, rotate regardless of the time */
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MAX_SIZE (1024*1024)
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_TIME (60*5)
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen#define MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file) ((file)->fd == -1)
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen /* refcount=0 is a valid state. files start that way, and they're
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen freed only when mail_transaction_logs_clean() is called. */
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen /* points to the next uncommitted transaction. usually same as EOF. */
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen /* saved_tail_offset is the offset that was last written to transaction
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen log. max_tail_offset is what should be written to the log the next
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen time a transaction is written. transaction log handling may update
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen max_tail_offset automatically by making it skip external transactions
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen after the last saved offset (to avoid re-reading them unneededly). */
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen /* files is a linked list of all the opened log files. the list is
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen sorted by the log file sequence, so that transaction views can use
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen them easily. head contains a pointer to the newest log file. */
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen struct mail_transaction_log_file *files, *head;
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen /* open_file is used temporarily while opening the log file.
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen if _open() failed, it's left there for _create(). */
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen struct dotlock_settings dotlock_settings, new_dotlock_settings;
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainenmail_transaction_log_file_set_corrupted(struct mail_transaction_log_file *file,
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainen const char *fmt, ...)
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainenmail_transaction_log_file_alloc_in_memory(struct mail_transaction_log *log);
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainenmail_transaction_log_file_alloc(struct mail_transaction_log *log,
11d72d764c104b4f1a8c44ec8a5fee420517645bTimo Sirainen const char *path);
498eecf19b1b408d5321cb048697744d7cee90b2Timo Sirainenvoid mail_transaction_log_file_free(struct mail_transaction_log_file **file);
12e5ac049bd74f8b98d9dc62adcb0bf3217beef6Martti Rannanjärviint mail_transaction_log_file_open(struct mail_transaction_log_file *file,
39025a2dabfcfaeee3790988b9ea00d19887a3d3Timo Sirainenint mail_transaction_log_file_create(struct mail_transaction_log_file *file);
11d72d764c104b4f1a8c44ec8a5fee420517645bTimo Sirainenint mail_transaction_log_file_lock(struct mail_transaction_log_file *file);
11d72d764c104b4f1a8c44ec8a5fee420517645bTimo Sirainenint mail_transaction_log_find_file(struct mail_transaction_log *log,
498eecf19b1b408d5321cb048697744d7cee90b2Timo Sirainen/* Returns 1 if ok, 0 if file is corrupted or offset range is invalid,
498eecf19b1b408d5321cb048697744d7cee90b2Timo Sirainen -1 if I/O error */
498eecf19b1b408d5321cb048697744d7cee90b2Timo Sirainenint mail_transaction_log_file_map(struct mail_transaction_log_file *file,
498eecf19b1b408d5321cb048697744d7cee90b2Timo Sirainenvoid mail_transaction_log_file_move_to_memory(struct mail_transaction_log_file
498eecf19b1b408d5321cb048697744d7cee90b2Timo Sirainenvoid mail_transaction_logs_clean(struct mail_transaction_log *log);
498eecf19b1b408d5321cb048697744d7cee90b2Timo Sirainenbool mail_transaction_log_want_rotate(struct mail_transaction_log *log);
11d72d764c104b4f1a8c44ec8a5fee420517645bTimo Sirainenint mail_transaction_log_rotate(struct mail_transaction_log *log);
12e5ac049bd74f8b98d9dc62adcb0bf3217beef6Martti Rannanjärviint mail_transaction_log_lock_head(struct mail_transaction_log *log);