[dovecot-cvs] dovecot/src/lib-index mail-transaction-log.c, 1.111.2.8, 1.111.2.9
tss at dovecot.org
tss at dovecot.org
Wed Jan 17 18:53:26 UTC 2007
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv32643
Modified Files:
Tag: branch_1_0
mail-transaction-log.c
Log Message:
Don't rename() .log to .log.2, because it temporarily loses the log file.
Use unlink() + link() instead.
Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.111.2.8
retrieving revision 1.111.2.9
diff -u -d -r1.111.2.8 -r1.111.2.9
--- mail-transaction-log.c 17 Jan 2007 16:17:38 -0000 1.111.2.8
+++ mail-transaction-log.c 17 Jan 2007 18:53:24 -0000 1.111.2.9
@@ -560,9 +560,19 @@
/* keep two log files */
if (rename_existing) {
+ /* rename() would be nice and easy way to do this, except then
+ there's a race condition between the rename and
+ file_dotlock_replace(). during that time the log file
+ doesn't exist, which could cause problems. */
path2 = t_strconcat(file->filepath, ".2", NULL);
- if (rename(file->filepath, path2) < 0 && errno != ENOENT) {
- mail_index_set_error(index, "rename(%s, %s) failed: %m",
+ if (unlink(path2) < 0 && errno != ENOENT) {
+ mail_index_set_error(index, "unlink(%s) failed: %m",
+ path2);
+ /* try to link() anyway */
+ }
+ if (link(file->filepath, path2) < 0 &&
+ errno != ENOENT && errno != EEXIST) {
+ mail_index_set_error(index, "link(%s, %s) failed: %m",
file->filepath, path2);
/* ignore the error. we don't care that much about the
second log file and we're going to overwrite this
More information about the dovecot-cvs
mailing list