int (*write)(struct fs_file *file, const void *data, size_t size);
void (*write_stream)(struct fs_file *file);
+ /* After write_stream_finish() is called once, all the following
+ (async) calls will have success==TRUE. */
int (*write_stream_finish)(struct fs_file *file, bool success);
int (*lock)(struct fs_file *file, unsigned int secs,
void fs_write_stream_abort(struct fs_file *file, struct ostream **output)
{
+ int ret;
+
i_assert(*output == file->output);
+ i_assert(file->output != NULL);
+ i_assert(output != &file->output);
*output = NULL;
- if (file->output != NULL)
- o_stream_ignore_last_errors(file->output);
+ o_stream_ignore_last_errors(file->output);
/* make sure we don't have an old error lying around */
fs_set_error(file->fs, "Write aborted");
- (void)fs_write_stream_finish_int(file, FALSE);
-}
-
-void fs_write_stream_abort_async(struct fs_file *file)
-{
- i_assert(file->output == NULL);
-
- fs_write_stream_abort(file, &file->output);
+ ret = fs_write_stream_finish_int(file, FALSE);
+ i_assert(ret != 0);
}
void fs_write_set_hash(struct fs_file *file, const struct hash_method *method,
int fs_write_stream_finish_async(struct fs_file *file);
/* Abort writing via stream. Anything written to the stream is discarded.
o_stream_ignore_last_errors() is called on the output stream so the caller
- doesn't need to do it. */
+ doesn't need to do it. This must not be called after
+ fs_write_stream_finish(), i.e. it can't be used to abort a pending async
+ write. */
void fs_write_stream_abort(struct fs_file *file, struct ostream **output);
-/* Abort writing to a stream after fs_write_stream_finish() was already
- called. */
-void fs_write_stream_abort_async(struct fs_file *file);
/* Set a hash to the following write. The storage can then verify that the
input data matches the specified hash, or fail if it doesn't. Typically