From ade6a48883cc1f4070cc2bc8a1342197ab6a1eb4 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 28 Jun 2018 11:51:22 +0300 Subject: [PATCH] dict-file: If write failed, file was left locked --- src/lib-dict/dict-file.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib-dict/dict-file.c b/src/lib-dict/dict-file.c index 93a0751fce..1f83b67082 100644 --- a/src/lib-dict/dict-file.c +++ b/src/lib-dict/dict-file.c @@ -596,7 +596,12 @@ file_dict_write_changes(struct dict_transaction_memory_context *ctx, *error_r = t_strdup_printf("write(%s) failed: %s", temp_path, o_stream_get_error(output)); o_stream_destroy(&output); - i_close_fd(&fd); + if (dotlock != NULL) + file_dotlock_delete(&dotlock); + else { + i_close_fd(&fd); + file_unlock(&lock); + } return -1; } o_stream_destroy(&output); @@ -616,6 +621,8 @@ file_dict_write_changes(struct dict_transaction_memory_context *ctx, i_close_fd(&fd); return -1; } + /* dict->fd is locked, not the new fd. We're closing dict->fd + so we can just free the lock struct. */ file_lock_free(&lock); } -- 2.47.3