From: Timo Sirainen Date: Thu, 28 Jun 2018 08:51:22 +0000 (+0300) Subject: dict-file: If write failed, file was left locked X-Git-Tag: 2.3.4~275 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ade6a48883cc1f4070cc2bc8a1342197ab6a1eb4;p=thirdparty%2Fdovecot%2Fcore.git dict-file: If write failed, file was left locked --- 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); }