dovecot-1.2: fts squat: Some error handling fixes fixes.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Oct 5 16:12:30 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/87936290b682
changeset: 8235:87936290b682
user: Timo Sirainen <tss at iki.fi>
date: Sun Oct 05 16:12:27 2008 +0300
description:
fts squat: Some error handling fixes fixes.
diffstat:
1 file changed, 11 insertions(+), 7 deletions(-)
src/plugins/fts-squat/squat-trie.c | 18 +++++++++++-------
diffs (48 lines):
diff -r 4d40d93842e3 -r 87936290b682 src/plugins/fts-squat/squat-trie.c
--- a/src/plugins/fts-squat/squat-trie.c Sun Oct 05 16:01:04 2008 +0300
+++ b/src/plugins/fts-squat/squat-trie.c Sun Oct 05 16:12:27 2008 +0300
@@ -285,6 +285,8 @@ static int squat_trie_lock(struct squat_
struct dotlock **dotlock_r)
{
int ret;
+
+ i_assert(trie->fd != -1);
*file_lock_r = NULL;
*dotlock_r = NULL;
@@ -1396,7 +1398,8 @@ squat_trie_renumber_uidlists(struct squa
} else {
ret = squat_trie_renumber_uidlists2(ctx, rebuild_ctx, iter);
}
- squat_trie_iterate_deinit(iter);
+ if (squat_trie_iterate_deinit(iter) < 0)
+ ret = -1;
/* lock the trie before we rename uidlist */
i_assert(ctx->file_lock == NULL && ctx->dotlock == NULL);
@@ -1644,18 +1647,19 @@ static int squat_trie_write(struct squat
path = trie->path;
ctx->compress_nodes =
trie->hdr.used_file_size == sizeof(trie->hdr);
+
+ if (trie->hdr.used_file_size == 0) {
+ /* lock before opening the file, in case we reopen it */
+ if (squat_trie_write_lock(ctx) < 0)
+ return -1;
+ }
output = o_stream_create_fd(trie->fd, 0, FALSE);
o_stream_cork(output);
if (trie->hdr.used_file_size != 0)
o_stream_seek(output, trie->hdr.used_file_size);
- else {
- if (squat_trie_write_lock(ctx) < 0) {
- o_stream_unref(&output);
- return -1;
- }
+ else
o_stream_send(output, &trie->hdr, sizeof(trie->hdr));
- }
}
ctx->output = output;
More information about the dovecot-cvs
mailing list