# HG changeset patch # User Timo Sirainen # Date 1032590156 -10800 # Node ID 51eea5cbb0756746e8202e203890a65a4db2080e # Parent e5fdb222d38a25c55a5d7a031859f0e84f5694de switching modifylog crashed. diff -r e5fdb222d38a -r 51eea5cbb075 src/lib-index/mail-modifylog.c --- a/src/lib-index/mail-modifylog.c Fri Sep 20 18:58:23 2002 +0300 +++ b/src/lib-index/mail-modifylog.c Sat Sep 21 09:35:56 2002 +0300 @@ -198,6 +198,9 @@ modifylog_set_syscall_error(log, "munmap()"); } log->mmap_base = NULL; + log->mmap_full_length = 0; + log->mmap_used_length = 0; + log->header = NULL; if (log->fd != -1) { if (close(log->fd) < 0) @@ -607,14 +610,20 @@ return mail_modifylog_open_or_create(index); } -static void mail_modifylog_try_switch_file(MailModifyLog *log) +static int mail_modifylog_try_switch_file(MailModifyLog *log) { const char *path; + if (log->anon_mmap) + return TRUE; + path = t_strconcat(log->index->filepath, log->second_log ? ".log" : ".log.2", NULL); - (void)modifylog_open_and_init_file(log, path); + if (modifylog_open_and_init_file(log, path)) + return mmap_update(log, TRUE); + else + return TRUE; } int mail_modifylog_mark_synced(MailModifyLog *log) @@ -641,8 +650,7 @@ if (log->mmap_used_length > MAX_MODIFYLOG_SIZE) { /* if the other file isn't locked, switch to it */ - mail_modifylog_try_switch_file(log); - return TRUE; + return mail_modifylog_try_switch_file(log); } return TRUE;