mail-transaction-log-private.h revision 2e99f3f3bb35715ce5e0a75a2f2a9bac3ab4224b
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen#if 0 // FIXME
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen/* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*4)
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen/* If log is larger than MAX_SIZE, rotate regardless of the time */
636f017be100bce67d66fd3ae1544a47681efd33Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MAX_SIZE (1024*16)
06ff2a72c39cb34cc6425f17fc82c5e93fef2018Timo Sirainen#define MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file) ((file)->fd == -1)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*256)
de76b960297406115cf6bae473f004c08174b16aTimo Sirainen/* If log is larger than MAX_SIZE, rotate regardless of the time */
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MAX_SIZE (1024*1024)
3ddbbe03fe74b3ee7b1dff4e08ec706d7880d052Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_TIME (60*5)
61530b48694398df42744204e35535dbe3f745c4Timo Sirainen#define MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file) ((file)->fd == -1)
6789ed17e7ca4021713507baf0dcf6979bb42e0cTimo Sirainen /* refcount=0 is a valid state. files start that way, and they're
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen freed only when mail_transaction_logs_clean() is called. */
67c25cb4af273aff7384d5028d459cc9afdf8712Timo Sirainen /* points to the next uncommitted transaction. usually same as EOF. */
67c25cb4af273aff7384d5028d459cc9afdf8712Timo Sirainen /* saved_offset is the offset that was last written to transaction log.
fde0b1793a2842da00eaa105d5e13fec465f0443Timo Sirainen max_offset is what should be written to the log the next time a
fde0b1793a2842da00eaa105d5e13fec465f0443Timo Sirainen transaction is written. transaction log handling may update
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen max_offset automatically by making it skip external transactions
d244c6cadd5f077f5d0f1e00c3652d0108a2d908Timo Sirainen after the last saved offset (to avoid re-reading them unneededly). */
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo Sirainen uoff_t mailbox_sync_saved_offset, mailbox_sync_max_offset;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* files is a linked list of all the opened log files. the list is
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen sorted by the log file sequence, so that transaction views can use
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainen them easily. head contains a pointer to the newest log file. */
d244c6cadd5f077f5d0f1e00c3652d0108a2d908Timo Sirainen struct mail_transaction_log_file *files, *head;
fde0b1793a2842da00eaa105d5e13fec465f0443Timo Sirainen /* open_file is used temporarily while opening the log file.
fde0b1793a2842da00eaa105d5e13fec465f0443Timo Sirainen if _open() failed, it's left there for _create(). */
baf1148108b7d9739626b47cc57298c36929586aTimo Sirainen struct dotlock_settings dotlock_settings, new_dotlock_settings;
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainenmail_transaction_log_file_set_corrupted(struct mail_transaction_log_file *file,
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainen const char *fmt, ...)
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenmail_transaction_log_file_alloc_in_memory(struct mail_transaction_log *log);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenmail_transaction_log_file_alloc(struct mail_transaction_log *log,
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen const char *path);
efe78d3ba24fc866af1c79b9223dc0809ba26cadStephan Boschvoid mail_transaction_log_file_free(struct mail_transaction_log_file **file);
e82e363e7a6917f470412d629db6c5b1f5891a35Timo Sirainenint mail_transaction_log_file_open(struct mail_transaction_log_file *file,
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenint mail_transaction_log_file_create(struct mail_transaction_log_file *file);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenint mail_transaction_log_file_lock(struct mail_transaction_log_file *file);
d6c5ceea8521b92d10e51a59da00c792f6140b1dTimo Sirainenint mail_transaction_log_find_file(struct mail_transaction_log *log,
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen/* Returns 1 if ok, 0 if file is corrupted or offset range is invalid,
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainen -1 if I/O error */
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenint mail_transaction_log_file_map(struct mail_transaction_log_file *file,
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenvoid mail_transaction_log_file_move_to_memory(struct mail_transaction_log_file
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenvoid mail_transaction_logs_clean(struct mail_transaction_log *log);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenbool mail_transaction_log_want_rotate(struct mail_transaction_log *log);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenint mail_transaction_log_rotate(struct mail_transaction_log *log);
51cbc45fc1ac5dde29bc2adbb175945df1b4f7d4Timo Sirainenint mail_transaction_log_lock_head(struct mail_transaction_log *log);