[dovecot-cvs] dovecot/src/lib-index mail-index-lock.c, 1.54.2.2, 1.54.2.3 mail-index-view.c, 1.44.2.4, 1.44.2.5 mail-index.c, 1.230.2.13, 1.230.2.14 mail-transaction-log-view.c, 1.45.2.3, 1.45.2.4 mail-transaction-log.c, 1.111.2.7, 1.111.2.8
tss at dovecot.org
tss at dovecot.org
Wed Jan 17 16:17:42 UTC 2007
- Previous message: [dovecot-cvs] dovecot/src/lib-index mail-index-sync-ext.c, 1.22, 1.23
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-index-lock.c, 1.59, 1.60 mail-index-view.c, 1.53, 1.54 mail-index.c, 1.254, 1.255 mail-transaction-log-view.c, 1.49, 1.50 mail-transaction-log.c, 1.119, 1.120
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv28915
Modified Files:
Tag: branch_1_0
mail-index-lock.c mail-index-view.c mail-index.c
mail-transaction-log-view.c mail-transaction-log.c
Log Message:
Fixes to error handling paths.
Index: mail-index-lock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-lock.c,v
retrieving revision 1.54.2.2
retrieving revision 1.54.2.3
diff -u -d -r1.54.2.2 -r1.54.2.3
--- mail-index-lock.c 31 Dec 2006 16:09:40 -0000 1.54.2.2
+++ mail-index-lock.c 17 Jan 2007 16:17:38 -0000 1.54.2.3
@@ -341,21 +341,26 @@
static int mail_index_copy_lock_finish(struct mail_index *index)
{
+ int ret = 0;
+
if (fsync(index->fd) < 0) {
mail_index_file_set_syscall_error(index, index->copy_lock_path,
"fsync()");
- return -1;
+ ret = -1;
}
- if (rename(index->copy_lock_path, index->filepath) < 0) {
- mail_index_set_error(index, "rename(%s, %s) failed: %m",
- index->copy_lock_path, index->filepath);
- return -1;
+ if (ret == 0) {
+ if (rename(index->copy_lock_path, index->filepath) < 0) {
+ mail_index_set_error(index, "rename(%s, %s) failed: %m",
+ index->copy_lock_path,
+ index->filepath);
+ ret = -1;
+ }
}
i_free(index->copy_lock_path);
index->copy_lock_path = NULL;
- return 0;
+ return ret;
}
static int mail_index_write_map_over(struct mail_index *index)
Index: mail-index-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.44.2.4
retrieving revision 1.44.2.5
diff -u -d -r1.44.2.4 -r1.44.2.5
--- mail-index-view.c 16 Jan 2007 14:09:20 -0000 1.44.2.4
+++ mail-index-view.c 17 Jan 2007 16:17:38 -0000 1.44.2.5
@@ -69,6 +69,8 @@
#ifdef DEBUG
mail_index_view_check_nextuid(view);
#endif
+ if (mail_index_view_is_inconsistent(view))
+ return -1;
if (MAIL_INDEX_MAP_IS_IN_MEMORY(view->index->map))
return 0;
@@ -102,11 +104,11 @@
int mail_index_view_lock(struct mail_index_view *view)
{
- if (mail_index_view_is_inconsistent(view))
- return -1;
-
if (view->map != view->index->map) {
/* not head mapping, no need to lock */
+ if (mail_index_view_is_inconsistent(view))
+ return -1;
+
#ifdef DEBUG
mail_index_view_check_nextuid(view);
#endif
Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.230.2.13
retrieving revision 1.230.2.14
diff -u -d -r1.230.2.13 -r1.230.2.14
--- mail-index.c 16 Jan 2007 18:27:42 -0000 1.230.2.13
+++ mail-index.c 17 Jan 2007 16:17:38 -0000 1.230.2.14
@@ -1514,21 +1514,25 @@
index->indexid = hdr.indexid;
index->log = mail_transaction_log_open_or_create(index);
- if (index->log == NULL)
+ if (index->log == NULL) {
+ if (ret == 0)
+ index->hdr = NULL;
return -1;
+ }
if (index->fd == -1) {
- if (index->indexid != hdr.indexid) {
- /* looks like someone else created the transaction log
- before we had the chance. use its indexid so we
- don't try to create conflicting ones. */
- hdr.indexid = index->indexid;
- }
+ mail_index_header_init(&hdr);
+ index->hdr = &hdr;
+
+ /* index->indexid may be updated by transaction log opening,
+ in case someone else had already created a new log file */
+ hdr.indexid = index->indexid;
if (lock_id != 0) {
mail_index_unlock(index, lock_id);
lock_id = 0;
}
+
if (!MAIL_INDEX_IS_IN_MEMORY(index)) {
if (mail_index_create(index, &hdr) < 0) {
/* fallback to in-memory index */
@@ -1540,6 +1544,7 @@
}
created = TRUE;
}
+ i_assert(index->hdr != &hdr);
if (lock_id == 0) {
if (mail_index_lock_shared(index, FALSE, &lock_id) < 0)
Index: mail-transaction-log-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log-view.c,v
retrieving revision 1.45.2.3
retrieving revision 1.45.2.4
diff -u -d -r1.45.2.3 -r1.45.2.4
--- mail-transaction-log-view.c 18 Nov 2006 21:01:08 -0000 1.45.2.3
+++ mail-transaction-log-view.c 17 Jan 2007 16:17:38 -0000 1.45.2.4
@@ -148,14 +148,16 @@
if (max_file_offset == 0 && min_file_seq == max_file_seq)
max_file_offset = min_file_offset;
}
-
- /* check these later than others as index file may have corrupted
- log_file_offset. we should have recreated the log file and
- skipped min_file_seq file above.. max_file_offset can be broken
- only if min_file_seq = max_file_seq. */
i_assert(min_file_offset >= file->hdr.hdr_size);
- i_assert(min_file_seq != max_file_seq ||
- min_file_offset <= max_file_offset);
+
+ if (min_file_seq == max_file_seq && min_file_offset > max_file_offset) {
+ /* log file offset is probably corrupted in the index file. */
+ mail_transaction_log_view_set_corrupted(view,
+ "file_seq=%u, min_file_offset (%"PRIuUOFF_T
+ ") > max_file_offset (%"PRIuUOFF_T")",
+ min_file_seq, min_file_offset, max_file_offset);
+ return -1;
+ }
end_offset = min_file_seq == max_file_seq ?
max_file_offset : (uoff_t)-1;
Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.111.2.7
retrieving revision 1.111.2.8
diff -u -d -r1.111.2.7 -r1.111.2.8
--- mail-transaction-log.c 16 Jan 2007 22:39:47 -0000 1.111.2.7
+++ mail-transaction-log.c 17 Jan 2007 16:17:38 -0000 1.111.2.8
@@ -985,6 +985,9 @@
}
}
+ if (MAIL_INDEX_IS_IN_MEMORY(log->index))
+ return 0;
+
/* see if we have it in log.2 file */
path = t_strconcat(log->index->filepath,
MAIL_TRANSACTION_LOG_SUFFIX".2", NULL);
@@ -1192,9 +1195,6 @@
return 0;
}
- if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file))
- return 1;
-
if (start_offset < file->hdr.hdr_size) {
mail_transaction_log_file_set_corrupted(file,
"offset (%"PRIuUOFF_T") < header size (%u)",
@@ -1202,6 +1202,9 @@
return -1;
}
+ if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file))
+ return 1;
+
/* with mmap_no_write we could alternatively just write to log with
msync() rather than pwrite(). but since there aren't many such OSes
left, it's easier to just use mmap_disable behavior with it */
@@ -1291,6 +1294,12 @@
return -1;
}
+ if (start_offset > file->sync_offset) {
+ mail_transaction_log_file_set_corrupted(file,
+ "start_offset (%"PRIuUOFF_T") > current sync_offset "
+ "(%"PRIuUOFF_T")", start_offset, file->sync_offset);
+ return -1;
+ }
if (end_offset != (uoff_t)-1 && end_offset > file->sync_offset) {
mail_transaction_log_file_set_corrupted(file,
"end_offset (%"PRIuUOFF_T") > current sync_offset "
- Previous message: [dovecot-cvs] dovecot/src/lib-index mail-index-sync-ext.c, 1.22, 1.23
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-index-lock.c, 1.59, 1.60 mail-index-view.c, 1.53, 1.54 mail-index.c, 1.254, 1.255 mail-transaction-log-view.c, 1.49, 1.50 mail-transaction-log.c, 1.119, 1.120
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list