]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict-file: If write failed, file was left locked
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 28 Jun 2018 08:51:22 +0000 (11:51 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 22 Aug 2018 09:50:08 +0000 (12:50 +0300)
src/lib-dict/dict-file.c

index 93a0751fce2a6063e409f26fdf1f62eb6bde023e..1f83b6708228dc2e1515ca86eb5f13c3ac6b6fde 100644 (file)
@@ -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);
        }