[dovecot-cvs] dovecot/src/lib-index mail-transaction-log-private.h, 1.14, 1.15 mail-transaction-log-view.c, 1.46, 1.47 mail-transaction-log.c, 1.113, 1.114
tss at dovecot.org
tss at dovecot.org
Sun Nov 12 11:15:43 UTC 2006
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv12077
Modified Files:
mail-transaction-log-private.h mail-transaction-log-view.c
mail-transaction-log.c
Log Message:
Code cleanup
Index: mail-transaction-log-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log-private.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mail-transaction-log-private.h 8 Nov 2006 17:04:00 -0000 1.14
+++ mail-transaction-log-private.h 12 Nov 2006 11:15:38 -0000 1.15
@@ -38,9 +38,10 @@
struct mail_transaction_log {
struct mail_index *index;
struct mail_transaction_log_view *views;
- /* head is the latest log file. tail is a linked list of older
- files. head isn't part of that linked list at all (ugh) */
- struct mail_transaction_log_file *head, *tail;
+ /* files is a linked list of all the opened log files. the list is
+ sorted by the log file sequence, so that transaction views can use
+ them easily. head contains a pointer to the newest log file. */
+ struct mail_transaction_log_file *files, *head;
unsigned int dotlock_count;
struct dotlock_settings dotlock_settings, new_dotlock_settings;
Index: mail-transaction-log-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log-view.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mail-transaction-log-view.c 12 Nov 2006 11:13:17 -0000 1.46
+++ mail-transaction-log-view.c 12 Nov 2006 11:15:38 -0000 1.47
@@ -104,10 +104,10 @@
}
}
- if (min_file_seq == view->log->tail->hdr.prev_file_seq &&
- min_file_offset == view->log->tail->hdr.prev_file_offset) {
+ if (min_file_seq == view->log->files->hdr.prev_file_seq &&
+ min_file_offset == view->log->files->hdr.prev_file_offset) {
/* we can skip this */
- min_file_seq = view->log->tail->hdr.file_seq;
+ min_file_seq = view->log->files->hdr.file_seq;
min_file_offset = 0;
if (min_file_seq > max_file_seq) {
Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- mail-transaction-log.c 8 Nov 2006 17:04:01 -0000 1.113
+++ mail-transaction-log.c 12 Nov 2006 11:15:38 -0000 1.114
@@ -270,7 +270,7 @@
if (log->head != NULL)
log->head->refcount--;
mail_transaction_logs_clean(log);
- i_assert(log->tail == NULL);
+ i_assert(log->files == NULL);
*_log = NULL;
log->index->log = NULL;
@@ -280,14 +280,20 @@
static void
mail_transaction_log_file_free(struct mail_transaction_log_file *file)
{
- int old_errno = errno;
+ struct mail_transaction_log_file **p;
+ int old_errno = errno;
mail_transaction_log_file_unlock(file);
+ for (p = &file->log->files; *p != NULL; p = &(*p)->next) {
+ if (*p == file) {
+ *p = file->next;
+ break;
+ }
+ }
+
if (file == file->log->head)
file->log->head = NULL;
- if (file == file->log->tail)
- file->log->tail = file->next;
if (file->buffer != NULL)
buffer_free(file->buffer);
@@ -422,7 +428,7 @@
If we're opening head log file, make sure the sequence is larger
than any existing one. */
if (head) {
- for (f = file->log->tail; f != NULL; f = f->next) {
+ for (f = file->log->files; f != NULL; f = f->next) {
if (f->hdr.file_seq >= file->hdr.file_seq) {
mail_transaction_log_file_set_corrupted(file,
"invalid new transaction log sequence "
@@ -432,7 +438,7 @@
}
}
} else {
- for (f = file->log->tail; f != NULL; f = f->next) {
+ for (f = file->log->files; f != NULL; f = f->next) {
if (f->hdr.file_seq == file->hdr.file_seq) {
mail_transaction_log_file_set_corrupted(file,
"old transaction log already opened "
@@ -629,7 +635,7 @@
}
/* append to end of list. */
- for (p = &log->tail; *p != NULL; p = &(*p)->next)
+ for (p = &log->files; *p != NULL; p = &(*p)->next)
i_assert((*p)->hdr.file_seq < file->hdr.file_seq);
*p = file;
}
@@ -643,7 +649,7 @@
file->sync_offset = file->hdr.hdr_size;
/* insert it to correct position */
- for (p = &log->tail; *p != NULL; p = &(*p)->next) {
+ for (p = &log->files; *p != NULL; p = &(*p)->next) {
i_assert((*p)->hdr.file_seq != file->hdr.file_seq);
if ((*p)->hdr.file_seq > file->hdr.file_seq)
break;
@@ -855,16 +861,13 @@
void mail_transaction_logs_clean(struct mail_transaction_log *log)
{
- struct mail_transaction_log_file **p, *next;
+ struct mail_transaction_log_file *file, *next;
- for (p = &log->tail; *p != NULL; ) {
- if ((*p)->refcount != 0)
- p = &(*p)->next;
- else {
- next = (*p)->next;
- mail_transaction_log_file_free(*p);
- *p = next;
- }
+ for (file = log->files; file != NULL; file = next) {
+ next = file->next;
+
+ if (file->refcount == 0)
+ mail_transaction_log_file_free(file);
}
}
@@ -984,7 +987,7 @@
return -1;
}
- for (file = log->tail; file != NULL; file = file->next) {
+ for (file = log->files; file != NULL; file = file->next) {
if (file->hdr.file_seq == file_seq) {
*file_r = file;
return 1;
@@ -1014,7 +1017,7 @@
}
/* see if we have it already opened */
- for (file = log->tail; file != NULL; file = file->next) {
+ for (file = log->files; file != NULL; file = file->next) {
if (file->st_ino == st.st_ino &&
CMP_DEV_T(file->st_dev, st.st_dev)) {
if (close(fd) < 0)
More information about the dovecot-cvs
mailing list