[dovecot-cvs] dovecot/src/lib-index mail-transaction-log-append.c,
1.1, 1.2 mail-transaction-log.c, 1.86,
1.87 mail-transaction-log.h, 1.24, 1.25
cras at dovecot.org
cras at dovecot.org
Sat Mar 5 12:19:40 EET 2005
- Previous message: [dovecot-cvs] dovecot/src/auth auth-worker-client.c, NONE,
1.1 auth-worker-client.h, NONE, 1.1 auth-worker-server.c, NONE,
1.1 auth-worker-server.h, NONE, 1.1 passdb-blocking.c, NONE,
1.1 passdb-blocking.h, NONE, 1.1 userdb-blocking.c, NONE,
1.1 userdb-blocking.h, NONE, 1.1
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-transaction-log.c, 1.87,
1.88
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv6020/lib-index
Modified Files:
mail-transaction-log-append.c mail-transaction-log.c
mail-transaction-log.h
Log Message:
Added versioning to transaction log header. Added create_stamp to its
header and it's not used to determine if the transaction log should be
rotated, not the last time the log was updated. So now if the log is over
128kB, it's rotated as soon as it's at least 5 minutes old.
Index: mail-transaction-log-append.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log-append.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mail-transaction-log-append.c 8 Feb 2005 22:50:26 -0000 1.1
+++ mail-transaction-log-append.c 5 Mar 2005 10:19:37 -0000 1.2
@@ -344,7 +344,7 @@
}
if (log->head->sync_offset > MAIL_TRANSACTION_LOG_ROTATE_SIZE &&
- log->head->last_mtime <
+ (time_t)log->head->hdr.create_stamp <
ioloop_time - MAIL_TRANSACTION_LOG_ROTATE_MIN_TIME) {
/* we might want to rotate, but check first that everything is
synced in index. */
Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- mail-transaction-log.c 8 Feb 2005 12:28:12 -0000 1.86
+++ mail-transaction-log.c 5 Mar 2005 10:19:37 -0000 1.87
@@ -50,8 +50,11 @@
t_pop();
va_end(va);
- /* this may have happened because of broken index. make sure it's ok. */
- (void)mail_index_fsck(file->log->index);
+ if (file->log->index->log != NULL) {
+ /* this may have happened because of broken index.
+ make sure it's ok. */
+ (void)mail_index_fsck(file->log->index);
+ }
}
static int
@@ -295,6 +298,22 @@
return 0;
}
+ if (file->hdr.major_version != MAIL_TRANSACTION_LOG_MAJOR_VERSION) {
+ /* incompatible version - fix silently */
+ return 0;
+ }
+ if (file->hdr.hdr_size < MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE) {
+ mail_transaction_log_file_set_corrupted(file,
+ "Header size too small");
+ return 0;
+ }
+ if (file->hdr.hdr_size < sizeof(file->hdr)) {
+ /* @UNSAFE: smaller than we expected - zero out the fields we
+ shouldn't have filled */
+ memset(PTR_OFFSET(&file->hdr, file->hdr.hdr_size), 0,
+ sizeof(file->hdr) - file->hdr.hdr_size);
+ }
+
if (file->hdr.indexid == 0) {
/* corrupted */
mail_index_set_error(file->log->index,
@@ -311,10 +330,9 @@
/* index file was probably just rebuilt and we don't know
about it yet */
- mail_index_set_error(file->log->index,
- "Transaction log file %s: invalid indexid (%u != %u)",
- file->filepath, file->hdr.indexid,
- file->log->index->indexid);
+ mail_transaction_log_file_set_corrupted(file,
+ "invalid indexid (%u != %u)",
+ file->hdr.indexid, file->log->index->indexid);
return 0;
}
return 1;
@@ -355,7 +373,11 @@
}
memset(&hdr, 0, sizeof(hdr));
+ hdr.major_version = MAIL_TRANSACTION_LOG_MAJOR_VERSION;
+ hdr.minor_version = MAIL_TRANSACTION_LOG_MINOR_VERSION;
+ hdr.hdr_size = sizeof(struct mail_transaction_log_header);
hdr.indexid = index->indexid;
+ hdr.create_stamp = ioloop_time;
if (index->fd != -1) {
if (mail_index_lock_shared(index, TRUE, &lock_id) < 0)
@@ -450,7 +472,6 @@
file->st_dev = st.st_dev;
file->st_ino = st.st_ino;
file->last_mtime = st.st_mtime;
- file->sync_offset = sizeof(struct mail_transaction_log_header);
ret = mail_transaction_log_file_read_hdr(file);
if (ret == 0) {
@@ -491,6 +512,8 @@
sync_offset from it so we don't have to read the whole log
file from beginning. */
file->sync_offset = log->index->map->hdr.log_file_int_offset;
+ } else {
+ file->sync_offset = file->hdr.hdr_size;
}
for (p = &log->tail; *p != NULL; p = &(*p)->next) {
@@ -790,10 +813,10 @@
return 0;
}
- if (start_offset < sizeof(file->hdr)) {
+ if (start_offset < file->hdr.hdr_size) {
mail_transaction_log_file_set_corrupted(file,
"offset (%"PRIuUOFF_T") < header size (%"PRIuSIZE_T")",
- start_offset, sizeof(file->hdr));
+ start_offset, file->hdr.hdr_size);
return -1;
}
Index: mail-transaction-log.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- mail-transaction-log.h 5 Feb 2005 12:01:49 -0000 1.24
+++ mail-transaction-log.h 5 Mar 2005 10:19:37 -0000 1.25
@@ -1,15 +1,24 @@
#ifndef __MAIL_TRANSACTION_LOG_H
#define __MAIL_TRANSACTION_LOG_H
+#define MAIL_TRANSACTION_LOG_MAJOR_VERSION 1
+#define MAIL_TRANSACTION_LOG_MINOR_VERSION 0
+#define MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE 24
+
#define MAIL_TRANSACTION_LOG_PREFIX ".log"
#define MAIL_TRANSACTION_LOG_ROTATE_SIZE (1024*128)
#define MAIL_TRANSACTION_LOG_ROTATE_MIN_TIME (60*5)
struct mail_transaction_log_header {
+ uint8_t major_version;
+ uint8_t minor_version;
+ uint16_t hdr_size;
+
uint32_t indexid;
uint32_t file_seq;
uint32_t prev_file_seq;
uint32_t prev_file_offset;
+ uint32_t create_stamp;
};
enum mail_transaction_type {
- Previous message: [dovecot-cvs] dovecot/src/auth auth-worker-client.c, NONE,
1.1 auth-worker-client.h, NONE, 1.1 auth-worker-server.c, NONE,
1.1 auth-worker-server.h, NONE, 1.1 passdb-blocking.c, NONE,
1.1 passdb-blocking.h, NONE, 1.1 userdb-blocking.c, NONE,
1.1 userdb-blocking.h, NONE, 1.1
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-transaction-log.c, 1.87,
1.88
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list