Skip to content

Commit

Permalink
dict-file: If write failed, file was left locked
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Aug 22, 2018
1 parent 48b7e30 commit ade6a48
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib-dict/dict-file.c
Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down

0 comments on commit ade6a48

Please sign in to comment.