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