annotate src/lib-index/mail-transaction-log-append.c @ 22576:707ae9de3812

lib: istream-multiplex - Minor code cleanup Avoid propagating the error twice, and avoid any confusion about what "got" actually contains.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 05 Oct 2017 20:24:11 +0300
parents ccbdafa83dbc
children cb108f786fb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21390
2e2563132d5f Updated copyright notices to include the year 2017.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents: 21389
diff changeset
1 /* Copyright (c) 2003-2017 Dovecot authors, see the included COPYING file */
3148
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
3470
346a494c2feb Moved array declaration to array-decl.h and include it in lib.h. So array.h
Timo Sirainen <tss@iki.fi>
parents: 3322
diff changeset
4 #include "array.h"
3148
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "write-full.h"
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "mail-index-private.h"
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "mail-transaction-log-private.h"
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
9 void mail_transaction_log_append_add(struct mail_transaction_log_append_ctx *ctx,
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
10 enum mail_transaction_type type,
9258
665ea7a8d26e Tests are now run on "make check". Added initial tests for lib-index.
Timo Sirainen <tss@iki.fi>
parents: 9254
diff changeset
11 const void *data, size_t size)
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
12 {
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
13 struct mail_transaction_header hdr;
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
14
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
15 i_assert((type & MAIL_TRANSACTION_TYPE_MASK) != 0);
9258
665ea7a8d26e Tests are now run on "make check". Added initial tests for lib-index.
Timo Sirainen <tss@iki.fi>
parents: 9254
diff changeset
16 i_assert((size % 4) == 0);
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
17
9258
665ea7a8d26e Tests are now run on "make check". Added initial tests for lib-index.
Timo Sirainen <tss@iki.fi>
parents: 9254
diff changeset
18 if (size == 0)
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
19 return;
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
20
21389
59437f8764c6 global: Replaced all instances of memset(p, 0, sizeof(*p)) with the new i_zero() macro.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents: 19799
diff changeset
21 i_zero(&hdr);
14581
4b1309d171ff Added MAIL_INDEX_TRANSACTION_FLAG_SYNC
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
22 hdr.type = type | ctx->trans_flags;
9624
2558ba736207 Keep track of expunged messages' GUIDs and expose them via mailbox_get_expunges().
Timo Sirainen <tss@iki.fi>
parents: 9393
diff changeset
23 if (type == MAIL_TRANSACTION_EXPUNGE ||
2558ba736207 Keep track of expunged messages' GUIDs and expose them via mailbox_get_expunges().
Timo Sirainen <tss@iki.fi>
parents: 9393
diff changeset
24 type == MAIL_TRANSACTION_EXPUNGE_GUID)
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
25 hdr.type |= MAIL_TRANSACTION_EXPUNGE_PROT;
14581
4b1309d171ff Added MAIL_INDEX_TRANSACTION_FLAG_SYNC
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
26 if (type == MAIL_TRANSACTION_BOUNDARY)
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
27 hdr.type |= MAIL_TRANSACTION_EXTERNAL;
9258
665ea7a8d26e Tests are now run on "make check". Added initial tests for lib-index.
Timo Sirainen <tss@iki.fi>
parents: 9254
diff changeset
28 hdr.size = sizeof(hdr) + size;
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
29 hdr.size = mail_index_uint32_to_offset(hdr.size);
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
30
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
31 buffer_append(ctx->output, &hdr, sizeof(hdr));
9258
665ea7a8d26e Tests are now run on "make check". Added initial tests for lib-index.
Timo Sirainen <tss@iki.fi>
parents: 9254
diff changeset
32 buffer_append(ctx->output, data, size);
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
33
21876
ccbdafa83dbc lib-index: Don't increase modseq for backend/dirty flag changes
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21390
diff changeset
34 mail_transaction_update_modseq(&hdr, data, &ctx->new_highest_modseq,
ccbdafa83dbc lib-index: Don't increase modseq for backend/dirty flag changes
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 21390
diff changeset
35 MAIL_TRANSACTION_LOG_HDR_VERSION(&ctx->log->head->hdr));
15367
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
36 ctx->transaction_count++;
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
37 }
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
38
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
39 static int
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
40 log_buffer_move_to_memory(struct mail_transaction_log_append_ctx *ctx)
3148
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 {
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
42 struct mail_transaction_log_file *file = ctx->log->head;
3833
318c70c1d4ec Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents: 3829
diff changeset
43
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
44 /* first we need to truncate this latest write so that log syncing
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
45 doesn't break */
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
46 if (ftruncate(file->fd, file->sync_offset) < 0) {
9393
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
47 mail_index_file_set_syscall_error(ctx->log->index,
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
48 file->filepath,
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
49 "ftruncate()");
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
50 }
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
51
9393
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
52 if (mail_index_move_to_memory(ctx->log->index) < 0)
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
53 return -1;
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
54 i_assert(MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file));
3833
318c70c1d4ec Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents: 3829
diff changeset
55
9393
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
56 i_assert(file->buffer_offset + file->buffer->used == file->sync_offset);
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
57 buffer_append_buf(file->buffer, ctx->output, 0, (size_t)-1);
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
58 file->sync_offset = file->buffer_offset + file->buffer->used;
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
59 return 0;
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
60 }
3833
318c70c1d4ec Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents: 3829
diff changeset
61
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
62 static int log_buffer_write(struct mail_transaction_log_append_ctx *ctx)
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
63 {
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
64 struct mail_transaction_log_file *file = ctx->log->head;
3833
318c70c1d4ec Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents: 3829
diff changeset
65
9393
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
66 if (ctx->output->used == 0)
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
67 return 0;
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
68
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
69 if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) {
9097
da5f1b89d4e1 indexes: Error handling fixes.
Timo Sirainen <tss@iki.fi>
parents: 9001
diff changeset
70 if (file->buffer == NULL) {
da5f1b89d4e1 indexes: Error handling fixes.
Timo Sirainen <tss@iki.fi>
parents: 9001
diff changeset
71 file->buffer = buffer_create_dynamic(default_pool, 4096);
da5f1b89d4e1 indexes: Error handling fixes.
Timo Sirainen <tss@iki.fi>
parents: 9001
diff changeset
72 file->buffer_offset = sizeof(file->hdr);
da5f1b89d4e1 indexes: Error handling fixes.
Timo Sirainen <tss@iki.fi>
parents: 9001
diff changeset
73 }
5790
e1347a122140 Fixed in-memory indexes
Timo Sirainen <tss@iki.fi>
parents: 5749
diff changeset
74 buffer_append_buf(file->buffer, ctx->output, 0, (size_t)-1);
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
75 file->sync_offset = file->buffer_offset + file->buffer->used;
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
76 return 0;
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
77 }
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
78
15367
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
79 if (write_full(file->fd, ctx->output->data, ctx->output->used) < 0) {
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
80 /* write failure, fallback to in-memory indexes. */
9393
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
81 mail_index_file_set_syscall_error(ctx->log->index,
5235
660763f5e75a If write fails with "not enough space" error, log it instead of silently
Timo Sirainen <tss@iki.fi>
parents: 5013
diff changeset
82 file->filepath,
15367
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
83 "write_full()");
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
84 return log_buffer_move_to_memory(ctx);
3833
318c70c1d4ec Beginnings of fallbacking to in-memory indexes when write fails with "out of
Timo Sirainen <tss@iki.fi>
parents: 3829
diff changeset
85 }
3243
40b4ba3c55b8 In-memory indexes work again. Just pass dir as NULL to mail_index_alloc().
Timo Sirainen <tss@iki.fi>
parents: 3215
diff changeset
86
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
87 i_assert(!ctx->sync_includes_this ||
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
88 file->sync_offset + ctx->output->used ==
5749
420a386fa27a int/ext/mailbox sync offset changes: Combined mailbox and int offsets to
Timo Sirainen <tss@iki.fi>
parents: 5715
diff changeset
89 file->max_tail_offset);
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
90
9696
126132cb1c19 index: Removed duplication of mail_index_open_flags from struct mail_index.
Timo Sirainen <tss@iki.fi>
parents: 9691
diff changeset
91 if ((ctx->want_fsync &&
11634
7f19062f58fd Renamed fsync_disable to mail_fsync=optimized|always|never.
Timo Sirainen <tss@iki.fi>
parents: 11360
diff changeset
92 file->log->index->fsync_mode != FSYNC_MODE_NEVER) ||
7f19062f58fd Renamed fsync_disable to mail_fsync=optimized|always|never.
Timo Sirainen <tss@iki.fi>
parents: 11360
diff changeset
93 file->log->index->fsync_mode == FSYNC_MODE_ALWAYS) {
6796
587a9d3054c1 If mail_nfs_index=yes, we need to call fdatasync() for all written
Timo Sirainen <tss@iki.fi>
parents: 6736
diff changeset
94 if (fdatasync(file->fd) < 0) {
9393
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
95 mail_index_file_set_syscall_error(ctx->log->index,
6796
587a9d3054c1 If mail_nfs_index=yes, we need to call fdatasync() for all written
Timo Sirainen <tss@iki.fi>
parents: 6736
diff changeset
96 file->filepath,
587a9d3054c1 If mail_nfs_index=yes, we need to call fdatasync() for all written
Timo Sirainen <tss@iki.fi>
parents: 6736
diff changeset
97 "fdatasync()");
587a9d3054c1 If mail_nfs_index=yes, we need to call fdatasync() for all written
Timo Sirainen <tss@iki.fi>
parents: 6736
diff changeset
98 return log_buffer_move_to_memory(ctx);
587a9d3054c1 If mail_nfs_index=yes, we need to call fdatasync() for all written
Timo Sirainen <tss@iki.fi>
parents: 6736
diff changeset
99 }
587a9d3054c1 If mail_nfs_index=yes, we need to call fdatasync() for all written
Timo Sirainen <tss@iki.fi>
parents: 6736
diff changeset
100 }
587a9d3054c1 If mail_nfs_index=yes, we need to call fdatasync() for all written
Timo Sirainen <tss@iki.fi>
parents: 6736
diff changeset
101
11360
8b67ccc4e2af lib-index: Recent "save transaction commits to memory" may have assert-crashed sometimes.
Timo Sirainen <tss@iki.fi>
parents: 11314
diff changeset
102 if (file->mmap_base == NULL && file->buffer != NULL) {
11314
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
103 /* we're reading from a file. avoid re-reading the data that
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
104 we just wrote. this is also important for some NFS clients,
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
105 which for some reason sometimes can't read() this data we
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
106 just wrote in the same process */
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
107 i_assert(file->buffer_offset +
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
108 file->buffer->used == file->sync_offset);
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
109 buffer_append(file->buffer, ctx->output->data,
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
110 ctx->output->used);
664d1b2f6b46 lib-index, mmap_disable=yes: Save data also to memory after appending to transaction log.
Timo Sirainen <tss@iki.fi>
parents: 10582
diff changeset
111 }
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
112 file->sync_offset += ctx->output->used;
3148
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
113 return 0;
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
114 }
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
115
7563
6de1aed24ce5 Added mail_index_ext_reset_inc() to atomically increase extension's
Timo Sirainen <tss@iki.fi>
parents: 7226
diff changeset
116 static void
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
117 log_append_sync_offset_if_needed(struct mail_transaction_log_append_ctx *ctx)
5897
3ec9ce7cd5e7 Implemented mail_index_update_header_ext()
Timo Sirainen <tss@iki.fi>
parents: 5849
diff changeset
118 {
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
119 struct mail_transaction_log_file *file = ctx->log->head;
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
120 struct mail_transaction_header_update *u;
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
121 struct mail_transaction_header *hdr;
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
122 uint32_t offset;
10404
f8151445662e Removed buffer_create_static_hard().
Timo Sirainen <tss@iki.fi>
parents: 9696
diff changeset
123 buffer_t buf;
f8151445662e Removed buffer_create_static_hard().
Timo Sirainen <tss@iki.fi>
parents: 9696
diff changeset
124 unsigned char update_data[sizeof(*u) + sizeof(offset)];
5283
8f9af66ee313 If transaction log grows larger than 1MB, rotate it even if it was created
Timo Sirainen <tss@iki.fi>
parents: 5278
diff changeset
125
17609
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
126 if (!ctx->index_sync_transaction) {
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
127 /* this is a non-syncing transaction. update the tail offset
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
128 only if we're already writing something else to transaction
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
129 log anyway. */
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
130 i_assert(!ctx->tail_offset_changed);
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
131 /* FIXME: For now we never do this update, because it would
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
132 cause errors about shrinking tail offsets with old Dovecot
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
133 versions. This is anyway just an optimization, so it doesn't
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
134 matter all that much if we don't do it here. Finish this
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
135 in v2.3. */
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
136 /*if (ctx->output->used == 0)*/
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
137 return;
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
138 } else if (file->max_tail_offset == file->sync_offset) {
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
139 /* we're synced all the way to tail offset, so this sync
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
140 transaction can also be included in the same tail offset. */
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
141 if (ctx->output->used == 0 && !ctx->tail_offset_changed) {
12640
19ffd1889f40 lib-index: Avoid writing tail offset unnecessarily to transaction log file.
Timo Sirainen <tss@iki.fi>
parents: 12493
diff changeset
142 /* nothing to write here after all (e.g. all unchanged
19ffd1889f40 lib-index: Avoid writing tail offset unnecessarily to transaction log file.
Timo Sirainen <tss@iki.fi>
parents: 12493
diff changeset
143 flag updates were dropped by export) */
19ffd1889f40 lib-index: Avoid writing tail offset unnecessarily to transaction log file.
Timo Sirainen <tss@iki.fi>
parents: 12493
diff changeset
144 return;
19ffd1889f40 lib-index: Avoid writing tail offset unnecessarily to transaction log file.
Timo Sirainen <tss@iki.fi>
parents: 12493
diff changeset
145 }
19ffd1889f40 lib-index: Avoid writing tail offset unnecessarily to transaction log file.
Timo Sirainen <tss@iki.fi>
parents: 12493
diff changeset
146
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
147 /* FIXME: when we remove exclusive log locking, we
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
148 can't rely on this. then write non-changed offset + check
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
149 real offset + rewrite the new offset if other transactions
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
150 weren't written in the middle */
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
151 file->max_tail_offset += ctx->output->used +
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
152 sizeof(*hdr) + sizeof(*u) + sizeof(offset);
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
153 ctx->sync_includes_this = TRUE;
17609
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
154 } else {
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
155 /* This is a syncing transaction. Since we're finishing a sync,
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
156 we may need to update the tail offset even if we don't have
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
157 anything else to do. */
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
158 }
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
159 offset = file->max_tail_offset;
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
160
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
161 if (file->saved_tail_offset == offset)
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
162 return;
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
163 i_assert(offset > file->saved_tail_offset);
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
164
15034
7efef678bca8 Renamed buffer_create_*data() to buffer_create_from_*data() for consistency.
Timo Sirainen <tss@iki.fi>
parents: 14581
diff changeset
165 buffer_create_from_data(&buf, update_data, sizeof(update_data));
10404
f8151445662e Removed buffer_create_static_hard().
Timo Sirainen <tss@iki.fi>
parents: 9696
diff changeset
166 u = buffer_append_space_unsafe(&buf, sizeof(*u));
5749
420a386fa27a int/ext/mailbox sync offset changes: Combined mailbox and int offsets to
Timo Sirainen <tss@iki.fi>
parents: 5715
diff changeset
167 u->offset = offsetof(struct mail_index_header, log_file_tail_offset);
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
168 u->size = sizeof(offset);
10404
f8151445662e Removed buffer_create_static_hard().
Timo Sirainen <tss@iki.fi>
parents: 9696
diff changeset
169 buffer_append(&buf, &offset, sizeof(offset));
9254
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
170
0e407ad46307 More cleanups to transaction log writing code.
Timo Sirainen <tss@iki.fi>
parents: 9252
diff changeset
171 mail_transaction_log_append_add(ctx, MAIL_TRANSACTION_HEADER_UPDATE,
10404
f8151445662e Removed buffer_create_static_hard().
Timo Sirainen <tss@iki.fi>
parents: 9696
diff changeset
172 buf.data, buf.used);
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
173 }
3296
c2b8904dc21b mmap_disable=yes: Transaction log might have been rotated before everything
Timo Sirainen <tss@iki.fi>
parents: 3254
diff changeset
174
5013
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
175 static int
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
176 mail_transaction_log_append_locked(struct mail_transaction_log_append_ctx *ctx)
3148
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
177 {
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
178 struct mail_transaction_log_file *file = ctx->log->head;
15367
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
179 struct mail_transaction_boundary *boundary;
5689
c2362f144f15 Initial commit for major index file code cleanup.
Timo Sirainen <tss@iki.fi>
parents: 5657
diff changeset
180
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
181 if (file->sync_offset < file->last_size) {
5285
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
182 /* there is some garbage at the end of the transaction log
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
183 (eg. previous write failed). remove it so reader doesn't
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
184 break because of it. */
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
185 buffer_set_used_size(file->buffer,
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
186 file->sync_offset - file->buffer_offset);
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
187 if (!MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) {
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
188 if (ftruncate(file->fd, file->sync_offset) < 0) {
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
189 mail_index_file_set_syscall_error(ctx->log->index,
5285
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
190 file->filepath, "ftruncate()");
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
191 }
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
192 }
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
193 }
a09da370923d If write to transaction log fails, we may later need to truncate the file so
Timo Sirainen <tss@iki.fi>
parents: 5283
diff changeset
194
15367
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
195 /* don't include log_file_tail_offset update in the transaction */
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
196 boundary = buffer_get_space_unsafe(ctx->output,
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
197 sizeof(struct mail_transaction_header),
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
198 sizeof(*boundary));
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
199 boundary->size = ctx->output->used;
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
200
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
201 if (ctx->transaction_count <= 2) {
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
202 /* 0-1 changes. don't bother with the boundary */
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
203 unsigned int boundary_size =
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
204 sizeof(struct mail_transaction_header) +
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
205 sizeof(*boundary);
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
206
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
207 buffer_delete(ctx->output, 0, boundary_size);
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
208 }
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
209
17609
16d4cf2c0d65 lib-index: Don't update log_file_tail_offset unnecessarily.
Timo Sirainen <tss@iki.fi>
parents: 17130
diff changeset
210 log_append_sync_offset_if_needed(ctx);
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
211 if (log_buffer_write(ctx) < 0)
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
212 return -1;
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
213 file->sync_highest_modseq = ctx->new_highest_modseq;
5655
501aab713b0d Write transactions with two pwrite() calls instead of lots of tiny ones.
Timo Sirainen <tss@iki.fi>
parents: 5653
diff changeset
214 return 0;
3148
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
215 }
d9327a3dbf97 forgot to add
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
216
14581
4b1309d171ff Added MAIL_INDEX_TRANSACTION_FLAG_SYNC
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
217 int mail_transaction_log_append_begin(struct mail_index *index,
4b1309d171ff Added MAIL_INDEX_TRANSACTION_FLAG_SYNC
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
218 enum mail_transaction_type flags,
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
219 struct mail_transaction_log_append_ctx **ctx_r)
5013
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
220 {
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
221 struct mail_transaction_log_append_ctx *ctx;
15367
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
222 struct mail_transaction_boundary boundary;
5013
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
223
12249
41e99ee5c1dd lib-index: Avoid unnecessary pread()s at end of transaction log file.
Timo Sirainen <tss@iki.fi>
parents: 11634
diff changeset
224 if (!index->log_sync_locked) {
19799
8dfbf0629359 lib-index: Small improvements to logging the reason for long transaction log lock waits
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19552
diff changeset
225 if (mail_transaction_log_lock_head(index->log, "appending") < 0)
5013
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
226 return -1;
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
227 }
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
228 ctx = i_new(struct mail_transaction_log_append_ctx, 1);
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
229 ctx->log = index->log;
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
230 ctx->output = buffer_create_dynamic(default_pool, 1024);
14581
4b1309d171ff Added MAIL_INDEX_TRANSACTION_FLAG_SYNC
Timo Sirainen <tss@iki.fi>
parents: 14133
diff changeset
231 ctx->trans_flags = flags;
5013
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
232
21389
59437f8764c6 global: Replaced all instances of memset(p, 0, sizeof(*p)) with the new i_zero() macro.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents: 19799
diff changeset
233 i_zero(&boundary);
15367
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
234 mail_transaction_log_append_add(ctx, MAIL_TRANSACTION_BOUNDARY,
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
235 &boundary, sizeof(boundary));
751181168b72 lib-index: Write to transaction log using O_APPEND flag.
Timo Sirainen <tss@iki.fi>
parents: 15034
diff changeset
236
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
237 *ctx_r = ctx;
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
238 return 0;
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
239 }
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
240
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
241 int mail_transaction_log_append_commit(struct mail_transaction_log_append_ctx **_ctx)
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
242 {
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
243 struct mail_transaction_log_append_ctx *ctx = *_ctx;
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
244 struct mail_index *index = ctx->log->index;
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
245 int ret = 0;
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
246
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
247 *_ctx = NULL;
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
248
9393
50b879627fb1 Fixed bugs caused by recent mail-transaction-log-append refactoring.
Timo Sirainen <tss@iki.fi>
parents: 9258
diff changeset
249 ret = mail_transaction_log_append_locked(ctx);
12249
41e99ee5c1dd lib-index: Avoid unnecessary pread()s at end of transaction log file.
Timo Sirainen <tss@iki.fi>
parents: 11634
diff changeset
250 if (!index->log_sync_locked)
17927
fce66ec2ac1c lib-index: Include reason string in warnings about keeping transaction log locked for too long.
Timo Sirainen <tss@iki.fi>
parents: 17609
diff changeset
251 mail_transaction_log_file_unlock(index->log->head, "appending");
9252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
252
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
253 buffer_free(&ctx->output);
937dca181d77 Moved transaction commiting code to mail-index-transaction-*.c
Timo Sirainen <tss@iki.fi>
parents: 9097
diff changeset
254 i_free(ctx);
5013
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
255 return ret;
6c76ed030b60 Fixed a race condition in transaction log rotation, which could have caused
Timo Sirainen <tss@iki.fi>
parents: 4451
diff changeset
256 }