changeset 5312:5d1c8fd5a83e HEAD

Don't give "Unexpected garbage at EOF" error if we don't see a full transaction header's worth of data. It could be just that another process is in the middle of writing the first header.
author Timo Sirainen <tss@iki.fi>
date Thu, 15 Mar 2007 03:05:17 +0200
parents 09b5de33144e
children f17cd7735f8d
files src/lib-index/mail-transaction-log.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log.c	Wed Mar 14 21:39:25 2007 +0200
+++ b/src/lib-index/mail-transaction-log.c	Thu Mar 15 03:05:17 2007 +0200
@@ -1104,7 +1104,7 @@
 {
         const struct mail_transaction_header *hdr;
 	const void *data;
-	size_t size;
+	size_t size, avail;
 	uint32_t hdr_size = 0;
 
 	data = buffer_get_data(file->buffer, &size);
@@ -1131,7 +1131,8 @@
 		file->sync_offset += hdr_size;
 	}
 
-	if (file->sync_offset - file->buffer_offset != size) {
+	avail = file->sync_offset - file->buffer_offset;
+	if (avail != size && avail >= sizeof(*hdr)) {
 		/* record goes outside the file we've seen. or if
 		   we're accessing the log file via unlocked mmaped
 		   memory, it may be just that the memory was updated