dovecot-2.2: Merged changes from v2.1 tree.
dovecot at dovecot.org
dovecot at dovecot.org
Mon Feb 25 17:48:21 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/d3815278ed19
changeset: 15956:d3815278ed19
user: Timo Sirainen <tss at iki.fi>
date: Mon Feb 25 17:29:28 2013 +0200
description:
Merged changes from v2.1 tree.
diffstat:
src/imap/cmd-list.c | 4 +-
src/indexer/indexer-worker.c | 4 +-
src/lib-dict/dict-client.c | 12 ++++---
src/lib-dict/dict-sql.c | 3 +
src/lib-index/mail-transaction-log-file.c | 3 +-
src/lib-lda/duplicate.c | 11 +++++-
src/lib-storage/index/dbox-common/dbox-file-fix.c | 14 +++++++-
src/lib-storage/index/dbox-common/dbox-file.h | 3 +-
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 6 ++-
src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c | 2 +-
src/lib-storage/index/index-status.c | 13 ++++++-
src/lib-storage/index/index-storage.h | 2 +-
src/lib-storage/index/index-sync.c | 4 +-
src/lib-storage/index/maildir/maildir-sync.c | 11 +++++++
src/lib-storage/mail-storage.c | 7 ++++
src/plugins/fts-solr/fts-backend-solr.c | 25 ++++++++++-----
src/plugins/fts/fts-build-mail.c | 3 +-
src/plugins/quota/Makefile.am | 1 +
18 files changed, 95 insertions(+), 33 deletions(-)
diffs (truncated from 407 to 300 lines):
diff -r 539baf0adc2e -r d3815278ed19 src/imap/cmd-list.c
--- a/src/imap/cmd-list.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/imap/cmd-list.c Mon Feb 25 17:29:28 2013 +0200
@@ -397,7 +397,7 @@
return TRUE;
}
if (imap_utf7_to_utf8(pattern, str) == 0)
- pattern = t_strdup(str_c(str));
+ pattern = p_strdup(cmd->pool, str_c(str));
array_append(&patterns, &pattern, 1);
str_truncate(str, 0);
}
@@ -408,7 +408,7 @@
return TRUE;
}
if (imap_utf7_to_utf8(pattern, str) == 0)
- pattern = str_c(str);
+ pattern = p_strdup(cmd->pool, str_c(str));
p_array_init(&patterns, cmd->pool, 1);
array_append(&patterns, &pattern, 1);
diff -r 539baf0adc2e -r d3815278ed19 src/indexer/indexer-worker.c
--- a/src/indexer/indexer-worker.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/indexer/indexer-worker.c Mon Feb 25 17:29:28 2013 +0200
@@ -45,6 +45,8 @@
int main(int argc, char *argv[])
{
+ enum master_service_flags service_flags =
+ MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN;
enum mail_storage_service_flags storage_service_flags =
MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT |
MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP |
@@ -52,7 +54,7 @@
MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT;
int c;
- master_service = master_service_init("indexer-worker", 0,
+ master_service = master_service_init("indexer-worker", service_flags,
&argc, &argv, "D");
while ((c = master_getopt(master_service)) > 0) {
switch (c) {
diff -r 539baf0adc2e -r d3815278ed19 src/lib-dict/dict-client.c
--- a/src/lib-dict/dict-client.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-dict/dict-client.c Mon Feb 25 17:29:28 2013 +0200
@@ -262,15 +262,17 @@
i_error("dict-client: Unknown transaction id %u", id);
return;
}
- if (ctx->callback != NULL)
- ctx->callback(ret, ctx->context);
- DLLIST_REMOVE(&dict->transactions, ctx);
- i_free(ctx);
-
+ /* the callback may call the dict code again, so remove this
+ transaction before calling it */
i_assert(dict->async_commits > 0);
if (--dict->async_commits == 0)
io_remove(&dict->io);
+ DLLIST_REMOVE(&dict->transactions, ctx);
+
+ if (ctx->callback != NULL)
+ ctx->callback(ret, ctx->context);
+ i_free(ctx);
}
static ssize_t client_dict_read_timeout(struct client_dict *dict)
diff -r 539baf0adc2e -r d3815278ed19 src/lib-dict/dict-sql.c
--- a/src/lib-dict/dict-sql.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-dict/dict-sql.c Mon Feb 25 17:29:28 2013 +0200
@@ -353,6 +353,9 @@
if (map == NULL)
return FALSE;
+ if (ctx->result != NULL)
+ sql_result_unref(ctx->result);
+
T_BEGIN {
string_t *query = t_str_new(256);
diff -r 539baf0adc2e -r d3815278ed19 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-index/mail-transaction-log-file.c Mon Feb 25 17:29:28 2013 +0200
@@ -1721,7 +1721,7 @@
}
if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) {
- if (start_offset < file->buffer_offset) {
+ if (start_offset < file->buffer_offset || file->buffer == NULL) {
/* we had moved the log to memory but failed to read
the beginning of the log file */
mail_index_set_error(index,
@@ -1729,7 +1729,6 @@
file->filepath);
return 0;
}
- i_assert(file->buffer != NULL);
return log_file_map_check_offsets(file, start_offset,
end_offset);
}
diff -r 539baf0adc2e -r d3815278ed19 src/lib-lda/duplicate.c
--- a/src/lib-lda/duplicate.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-lda/duplicate.c Mon Feb 25 17:29:28 2013 +0200
@@ -209,9 +209,16 @@
file->path = p_strdup(pool, ctx->path);
file->new_fd = file_dotlock_open(&ctx->dotlock_set, file->path, 0,
&file->dotlock);
- if (file->new_fd == -1)
- i_error("file_dotlock_create(%s) failed: %m", file->path);
+ if (file->new_fd != -1)
+ ;
+ else if (errno != EAGAIN)
+ i_error("file_dotlock_open(%s) failed: %m", file->path);
+ else {
+ i_error("Creating lock file for %s timed out in %u secs",
+ file->path, ctx->dotlock_set.timeout);
+ }
hash_table_create(&file->hash, pool, 0, duplicate_hash, duplicate_cmp);
+
(void)duplicate_read(file);
return file;
}
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-common/dbox-file-fix.c
--- a/src/lib-storage/index/dbox-common/dbox-file-fix.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-file-fix.c Mon Feb 25 17:29:28 2013 +0200
@@ -299,7 +299,7 @@
{
struct ostream *output;
const char *dir, *p, *temp_path, *broken_path;
- bool deleted;
+ bool deleted, have_messages;
int fd, ret;
i_assert(dbox_file_is_open(file));
@@ -318,6 +318,7 @@
ret = dbox_file_fix_write_stream(file, start_offset, temp_path, output);
if (ret < 0)
o_stream_ignore_last_errors(output);
+ have_messages = output->offset > file->file_header_size;
o_stream_unref(&output);
if (close(fd) < 0) {
mail_storage_set_critical(&file->storage->storage,
@@ -343,6 +344,15 @@
i_warning("dbox: Copy of the broken file saved to %s",
broken_path);
}
+ if (!have_messages) {
+ /* the resulting file has no messages. just delete the file. */
+ dbox_file_close(file);
+ if (unlink(temp_path) < 0)
+ i_error("unlink(%s) failed: %m", temp_path);
+ if (unlink(file->cur_path) < 0)
+ i_error("unlink(%s) failed: %m", file->cur_path);
+ return 0;
+ }
if (rename(temp_path, file->cur_path) < 0) {
mail_storage_set_critical(&file->storage->storage,
"rename(%s, %s) failed: %m",
@@ -358,5 +368,5 @@
file->cur_path);
return -1;
}
- return 0;
+ return 1;
}
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-common/dbox-file.h
--- a/src/lib-storage/index/dbox-common/dbox-file.h Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-file.h Mon Feb 25 17:29:28 2013 +0200
@@ -190,7 +190,8 @@
/* Fix a broken dbox file by rename()ing over it with a fixed file. Everything
before start_offset is assumed to be valid and is simply copied. The file
- is reopened afterwards. Returns 0 if ok, -1 if I/O error. */
+ is reopened afterwards. Returns 1 if ok, 0 if the resulting file has no
+ mails and was deleted, -1 if I/O error. */
int dbox_file_fix(struct dbox_file *file, uoff_t start_offset);
/* Delete the given dbox file. Returns 1 if deleted, 0 if file wasn't found
or -1 if error. */
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Mon Feb 25 17:29:28 2013 +0200
@@ -153,9 +153,11 @@
/* use existing file header if it was ok */
prev_offset = offset;
}
- if (dbox_file_fix(file, prev_offset) < 0) {
- ret = -1;
+ if ((ret = dbox_file_fix(file, prev_offset)) < 0)
break;
+ if (ret == 0) {
+ /* file was deleted */
+ return 1;
}
fixed = TRUE;
if (!first) {
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c
--- a/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-sync-rebuild.c Mon Feb 25 17:29:28 2013 +0200
@@ -39,7 +39,7 @@
ret = dbox_file_seek(file, 0);
}
if (ret == 0) {
- if ((ret = dbox_file_fix(file, 0)) == 0)
+ if ((ret = dbox_file_fix(file, 0)) > 0)
ret = dbox_file_seek(file, 0);
}
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/index-status.c
--- a/src/lib-storage/index/index-status.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/index-status.c Mon Feb 25 17:29:28 2013 +0200
@@ -113,9 +113,16 @@
hdr = mail_index_get_header(box->view);
status_r->messages = hdr->messages_count;
if ((items & STATUS_RECENT) != 0) {
- /* make sure recent count is set, in case syncing hasn't
- been done yet */
- index_sync_update_recent_count(box);
+ if ((box->flags & MAILBOX_FLAG_DROP_RECENT) != 0) {
+ /* recent flags are set and dropped by the previous
+ sync while index was locked. if we updated the
+ recent flags here we'd have a race condition. */
+ i_assert(box->synced);
+ } else {
+ /* make sure recent count is set, in case we haven't
+ synced yet */
+ index_sync_update_recent_count(box);
+ }
status_r->recent = index_mailbox_get_recent_count(box);
i_assert(status_r->recent <= status_r->messages);
}
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/index-storage.h
--- a/src/lib-storage/index/index-storage.h Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/index-storage.h Mon Feb 25 17:29:28 2013 +0200
@@ -37,7 +37,7 @@
struct mail_cache_field *cache_fields;
ARRAY_TYPE(seq_range) recent_flags;
- uint32_t recent_flags_prev_uid;
+ uint32_t recent_flags_prev_uid, recent_flags_last_check_nextuid;
uint32_t recent_flags_count;
uint32_t vsize_hdr_ext_id;
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/index-sync.c
--- a/src/lib-storage/index/index-sync.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/index-sync.c Mon Feb 25 17:29:28 2013 +0200
@@ -367,7 +367,9 @@
uint32_t seq1, seq2;
hdr = mail_index_get_header(box->view);
- if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) {
+ if (hdr->first_recent_uid > ibox->recent_flags_prev_uid ||
+ hdr->next_uid > ibox->recent_flags_last_check_nextuid) {
+ ibox->recent_flags_last_check_nextuid = hdr->next_uid;
if (mail_index_lookup_seq_range(box->view,
hdr->first_recent_uid,
hdr->next_uid,
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Feb 25 17:29:28 2013 +0200
@@ -288,6 +288,7 @@
const char *fname1, *path1, *path2;
const char *new_fname, *new_path;
struct stat st1, st2;
+ uoff_t size;
fname1 = maildir_uidlist_sync_get_full_filename(ctx->uidlist_sync_ctx,
fname2);
@@ -330,6 +331,16 @@
}
new_fname = maildir_filename_generate();
+ /* preserve S= and W= sizes if they're available.
+ (S=size is required for zlib plugin to work) */
+ if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_FILE_SIZE, &size)) {
+ new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T,
+ new_fname, MAILDIR_EXTRA_FILE_SIZE, size);
+ }
+ if (maildir_filename_get_size(fname2, MAILDIR_EXTRA_VIRTUAL_SIZE, &size)) {
+ new_fname = t_strdup_printf("%s,%c=%"PRIuUOFF_T,
+ new_fname, MAILDIR_EXTRA_VIRTUAL_SIZE, size);
+ }
new_path = t_strconcat(mailbox_get_path(&ctx->mbox->box),
"/new/", new_fname, NULL);
diff -r 539baf0adc2e -r d3815278ed19 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Mon Feb 25 17:25:10 2013 +0200
+++ b/src/lib-storage/mail-storage.c Mon Feb 25 17:29:28 2013 +0200
@@ -1036,6 +1036,13 @@
{
time_t mtime;
+ if ((box->flags & MAILBOX_FLAG_READONLY) != 0) {
+ /* most importantly we don't do this because we want to avoid
+ a loop: mdbox storage rebuild -> mailbox_open() ->
+ mailbox_mark_index_deleted() -> mailbox_sync() ->
+ mdbox storage rebuild. */
+ return FALSE;
+ }
if (mail_index_get_modification_time(box->index, &mtime) < 0)
More information about the dovecot-cvs
mailing list