dovecot-2.2: Added mail_temp_scan_interval setting and changed i...
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 20 03:26:30 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/370e1f945c01
changeset: 14379:370e1f945c01
user: Timo Sirainen <tss at iki.fi>
date: Fri Mar 23 13:44:54 2012 +0200
description:
Added mail_temp_scan_interval setting and changed its default from 8h -> 1w.
diffstat:
doc/example-config/conf.d/10-mail.conf | 4 ++++
src/lib-storage/index/dbox-common/dbox-storage.c | 7 +++++--
src/lib-storage/index/dbox-common/dbox-storage.h | 2 --
src/lib-storage/index/dbox-multi/mdbox-map.c | 8 ++++++--
src/lib-storage/index/maildir/maildir-storage.c | 7 +++++--
src/lib-storage/index/maildir/maildir-storage.h | 2 --
src/lib-storage/mail-storage-settings.c | 2 ++
src/lib-storage/mail-storage-settings.h | 1 +
8 files changed, 23 insertions(+), 10 deletions(-)
diffs (144 lines):
diff -r 091b9f49f24f -r 370e1f945c01 doc/example-config/conf.d/10-mail.conf
--- a/doc/example-config/conf.d/10-mail.conf Fri Mar 23 13:35:05 2012 +0200
+++ b/doc/example-config/conf.d/10-mail.conf Fri Mar 23 13:44:54 2012 +0200
@@ -227,6 +227,10 @@
# some mailbox formats and/or operating systems.
#mail_prefetch_count = 0
+# How often to scan for stale temporary files and delete them. These should
+# exist only after Dovecot dies in the middle of saving mails.
+#mail_temp_scan_interval = 1w
+
##
## Maildir-specific settings
##
diff -r 091b9f49f24f -r 370e1f945c01 src/lib-storage/index/dbox-common/dbox-storage.c
--- a/src/lib-storage/index/dbox-common/dbox-storage.c Fri Mar 23 13:35:05 2012 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-storage.c Fri Mar 23 13:44:54 2012 +0200
@@ -147,15 +147,18 @@
dbox_cleanup_if_exists(struct mailbox_list *list, const char *path)
{
struct stat st;
+ unsigned int interval = list->mail_set->mail_temp_scan_interval;
if (stat(path, &st) < 0)
return FALSE;
/* check once in a while if there are temp files to clean up */
- if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) {
+ if (interval == 0) {
+ /* disabled */
+ } else if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) {
/* there haven't been any changes to this directory since we
last checked it. */
- } else if (st.st_atime < ioloop_time - DBOX_TMP_SCAN_SECS) {
+ } else if (st.st_atime < ioloop_time - interval) {
/* time to scan */
const char *prefix =
mailbox_list_get_global_temp_prefix(list);
diff -r 091b9f49f24f -r 370e1f945c01 src/lib-storage/index/dbox-common/dbox-storage.h
--- a/src/lib-storage/index/dbox-common/dbox-storage.h Fri Mar 23 13:35:05 2012 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-storage.h Fri Mar 23 13:44:54 2012 +0200
@@ -18,8 +18,6 @@
#define DBOX_TRASH_DIR_NAME "trash"
#define DBOX_MAILDIR_NAME "dbox-Mails"
-/* How often to scan for stale temp files (based on dir's atime) */
-#define DBOX_TMP_SCAN_SECS (8*60*60)
/* Delete temp files having ctime older than this. */
#define DBOX_TMP_DELETE_SECS (36*60*60)
diff -r 091b9f49f24f -r 370e1f945c01 src/lib-storage/index/dbox-multi/mdbox-map.c
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Mar 23 13:35:05 2012 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Mar 23 13:44:54 2012 +0200
@@ -133,16 +133,20 @@
static void mdbox_map_cleanup(struct mdbox_map *map)
{
+ unsigned int interval =
+ MAP_STORAGE(map)->set->mail_temp_scan_interval;
struct stat st;
if (stat(map->path, &st) < 0)
return;
/* check once in a while if there are temp files to clean up */
- if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) {
+ if (interval == 0) {
+ /* disabled */
+ } else if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) {
/* there haven't been any changes to this directory since we
last checked it. */
- } else if (st.st_atime < ioloop_time - DBOX_TMP_SCAN_SECS) {
+ } else if (st.st_atime < ioloop_time - interval) {
/* time to scan */
(void)unlink_old_files(map->path, DBOX_TEMP_FILE_PREFIX,
ioloop_time - DBOX_TMP_DELETE_SECS);
diff -r 091b9f49f24f -r 370e1f945c01 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c Fri Mar 23 13:35:05 2012 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.c Fri Mar 23 13:44:54 2012 +0200
@@ -201,6 +201,7 @@
static int maildir_check_tmp(struct mail_storage *storage, const char *dir)
{
+ unsigned int interval = storage->set->mail_temp_scan_interval;
const char *path;
struct stat st;
@@ -218,10 +219,12 @@
return -1;
}
- if (st.st_atime > st.st_ctime + MAILDIR_TMP_DELETE_SECS) {
+ if (interval == 0) {
+ /* disabled */
+ } else if (st.st_atime > st.st_ctime + MAILDIR_TMP_DELETE_SECS) {
/* the directory should be empty. we won't do anything
until ctime changes. */
- } else if (st.st_atime < ioloop_time - MAILDIR_TMP_SCAN_SECS) {
+ } else if (st.st_atime < ioloop_time - interval) {
/* time to scan */
(void)unlink_old_files(path, "",
ioloop_time - MAILDIR_TMP_DELETE_SECS);
diff -r 091b9f49f24f -r 370e1f945c01 src/lib-storage/index/maildir/maildir-storage.h
--- a/src/lib-storage/index/maildir/maildir-storage.h Fri Mar 23 13:35:05 2012 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.h Fri Mar 23 13:44:54 2012 +0200
@@ -31,8 +31,6 @@
calculating file's virtual size (added missing CRs). */
#define MAILDIR_EXTRA_VIRTUAL_SIZE 'W'
-/* How often to scan tmp/ directory for old files (based on dir's atime) */
-#define MAILDIR_TMP_SCAN_SECS (8*60*60)
/* Delete files having ctime older than this from tmp/. 36h is standard. */
#define MAILDIR_TMP_DELETE_SECS (36*60*60)
diff -r 091b9f49f24f -r 370e1f945c01 src/lib-storage/mail-storage-settings.c
--- a/src/lib-storage/mail-storage-settings.c Fri Mar 23 13:35:05 2012 +0200
+++ b/src/lib-storage/mail-storage-settings.c Fri Mar 23 13:44:54 2012 +0200
@@ -37,6 +37,7 @@
DEF(SET_TIME, mailbox_idle_check_interval),
DEF(SET_UINT, mail_max_keyword_length),
DEF(SET_TIME, mail_max_lock_timeout),
+ DEF(SET_TIME, mail_temp_scan_interval),
DEF(SET_BOOL, mail_save_crlf),
DEF(SET_ENUM, mail_fsync),
DEF(SET_BOOL, mmap_disable),
@@ -66,6 +67,7 @@
.mailbox_idle_check_interval = 30,
.mail_max_keyword_length = 50,
.mail_max_lock_timeout = 0,
+ .mail_temp_scan_interval = 7*24*60*60,
.mail_save_crlf = FALSE,
.mail_fsync = "optimized:never:always",
.mmap_disable = FALSE,
diff -r 091b9f49f24f -r 370e1f945c01 src/lib-storage/mail-storage-settings.h
--- a/src/lib-storage/mail-storage-settings.h Fri Mar 23 13:35:05 2012 +0200
+++ b/src/lib-storage/mail-storage-settings.h Fri Mar 23 13:44:54 2012 +0200
@@ -22,6 +22,7 @@
unsigned int mailbox_idle_check_interval;
unsigned int mail_max_keyword_length;
unsigned int mail_max_lock_timeout;
+ unsigned int mail_temp_scan_interval;
bool mail_save_crlf;
const char *mail_fsync;
bool mmap_disable;
More information about the dovecot-cvs
mailing list