dovecot-2.2: lib-fs: Small code cleanup for handling write_strea...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Aug 16 11:15:00 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/2f1378beeef6
changeset: 18935:2f1378beeef6
user: Timo Sirainen <tss at iki.fi>
date: Sun Aug 16 13:10:48 2015 +0200
description:
lib-fs: Small code cleanup for handling write_stream_finish()
diffstat:
src/lib-fs/fs-api.c | 39 ++++++++++++++++++++-------------------
1 files changed, 20 insertions(+), 19 deletions(-)
diffs (69 lines):
diff -r 295fd771e02d -r 2f1378beeef6 src/lib-fs/fs-api.c
--- a/src/lib-fs/fs-api.c Sun Aug 16 13:07:21 2015 +0200
+++ b/src/lib-fs/fs-api.c Sun Aug 16 13:10:48 2015 +0200
@@ -555,9 +555,25 @@
return file->output;
}
+static int fs_write_stream_finish_int(struct fs_file *file, bool success)
+{
+ int ret;
+
+ T_BEGIN {
+ ret = file->fs->v.write_stream_finish(file, success);
+ } T_END;
+ if (ret == 0) {
+ file->metadata_changed = FALSE;
+ } else {
+ /* write didn't finish yet. this shouldn't happen if we
+ indicated a failure. */
+ i_assert(success);
+ }
+ return ret;
+}
+
int fs_write_stream_finish(struct fs_file *file, struct ostream **output)
{
- int ret;
bool success = TRUE;
i_assert(*output == file->output || *output == NULL);
@@ -573,24 +589,12 @@
success = FALSE;
}
}
- T_BEGIN {
- ret = file->fs->v.write_stream_finish(file, success);
- } T_END;
- if (ret != 0)
- file->metadata_changed = FALSE;
- return ret;
+ return fs_write_stream_finish_int(file, success);
}
int fs_write_stream_finish_async(struct fs_file *file)
{
- int ret;
-
- T_BEGIN {
- ret = file->fs->v.write_stream_finish(file, TRUE);
- } T_END;
- if (ret != 0)
- file->metadata_changed = FALSE;
- return ret;
+ return fs_write_stream_finish_int(file, TRUE);
}
void fs_write_stream_abort(struct fs_file *file, struct ostream **output)
@@ -600,10 +604,7 @@
*output = NULL;
if (file->output != NULL)
o_stream_ignore_last_errors(file->output);
- T_BEGIN {
- (void)file->fs->v.write_stream_finish(file, FALSE);
- } T_END;
- file->metadata_changed = FALSE;
+ (void)fs_write_stream_finish_int(file, FALSE);
}
void fs_write_set_hash(struct fs_file *file, const struct hash_method *method,
More information about the dovecot-cvs
mailing list