mail-transaction-log-private.h revision c25356d5978632df6203437e1953bcb29e0c736f
cc833a7a4e2258afdc834ace4bfe6579820a1df3Timo Sirainen/* Synchronization can take a while sometimes, especially when copying lots of
cc833a7a4e2258afdc834ace4bfe6579820a1df3Timo Sirainen#define MAIL_TRANSCATION_LOG_LOCK_TIMEOUT (3*60)
cc833a7a4e2258afdc834ace4bfe6579820a1df3Timo Sirainen#define MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT (3*60)
7e235b3a5f622813121cd18f351e036650aaf8f8Timo Sirainen/* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */
366eb7178f2c90d97134e0c2d1958f93fcdaba12Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*32)
7e235b3a5f622813121cd18f351e036650aaf8f8Timo Sirainen/* If log is larger than MAX_SIZE, rotate regardless of the time */
7e235b3a5f622813121cd18f351e036650aaf8f8Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_MAX_SIZE (1024*1024)
fadd878cd6098f5b873c21c121209a922679dae4Timo Sirainen#define MAIL_TRANSACTION_LOG_ROTATE_TIME (60*5)
471e447023ab73a73f0f78da2afc0c55905330ddTimo Sirainen/* Delete .log.2 files older than this many seconds */
471e447023ab73a73f0f78da2afc0c55905330ddTimo Sirainen#define MAIL_TRANSACTION_LOG2_STALE_SECS (60*30)
4b231ca0bbe3b536acbd350101e183441ce0247aTimo Sirainen#define MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file) ((file)->fd == -1)
bbce20cb4e5739e9a06058cf8ee1f38a7f6884f6Timo Sirainen /* refcount=0 is a valid state. files start that way, and they're
bbce20cb4e5739e9a06058cf8ee1f38a7f6884f6Timo Sirainen freed only when mail_transaction_logs_clean() is called. */
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen /* points to the next uncommitted transaction. usually same as EOF. */
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen /* saved_tail_offset is the offset that was last written to transaction
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen log. max_tail_offset is what should be written to the log the next
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen time a transaction is written. transaction log handling may update
51795bfe9d05d92fe942cb451aec2b9d16d32a11Timo Sirainen max_tail_offset automatically by making it skip external transactions
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen after the last saved offset (to avoid re-reading them unneededly). */
45e62043058738e294f89504c319d852e25943ccTimo Sirainen /* files is a linked list of all the opened log files. the list is
45e62043058738e294f89504c319d852e25943ccTimo Sirainen sorted by the log file sequence, so that transaction views can use
45e62043058738e294f89504c319d852e25943ccTimo Sirainen them easily. head contains a pointer to the newest log file. */
45e62043058738e294f89504c319d852e25943ccTimo Sirainen struct mail_transaction_log_file *files, *head;
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen /* open_file is used temporarily while opening the log file.
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen if _open() failed, it's left there for _create(). */
13c6532dc104d23061e6901783ceb1ff8872c206Timo Sirainen struct dotlock_settings dotlock_settings, new_dotlock_settings;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmail_transaction_log_file_set_corrupted(struct mail_transaction_log_file *file,
6eb30032b4a50c383dea4c9c74342d906de6ad36Timo Sirainen const char *fmt, ...)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenmail_transaction_log_file_alloc_in_memory(struct mail_transaction_log *log);
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainenmail_transaction_log_file_alloc(struct mail_transaction_log *log,
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen const char *path);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenvoid mail_transaction_log_file_free(struct mail_transaction_log_file **file);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenint mail_transaction_log_file_open(struct mail_transaction_log_file *file,
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainenint mail_transaction_log_file_create(struct mail_transaction_log_file *file,
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainenint mail_transaction_log_file_lock(struct mail_transaction_log_file *file);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenint mail_transaction_log_find_file(struct mail_transaction_log *log,
2e99f3f3bb35715ce5e0a75a2f2a9bac3ab4224bTimo Sirainen/* Returns 1 if ok, 0 if file is corrupted or offset range is invalid,
2e99f3f3bb35715ce5e0a75a2f2a9bac3ab4224bTimo Sirainen -1 if I/O error */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenint mail_transaction_log_file_map(struct mail_transaction_log_file *file,
902222fb0928d1701f20a384b73f327b1d9a15ddTimo Sirainenvoid mail_transaction_log_file_move_to_memory(struct mail_transaction_log_file
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_transaction_logs_clean(struct mail_transaction_log *log);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenbool mail_transaction_log_want_rotate(struct mail_transaction_log *log);
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainenint mail_transaction_log_rotate(struct mail_transaction_log *log, bool reset);
b87a4156eca6dcf6b29c504eb0cb9be2fdb11b63Timo Sirainenint mail_transaction_log_lock_head(struct mail_transaction_log *log);