]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Clarified fs_write_stream_abort() API and dropped its _async().
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 1 Jun 2016 14:06:28 +0000 (17:06 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 1 Jun 2016 14:08:36 +0000 (17:08 +0300)
We can't handle an abort after an async fs_write_stream_finish() is already
going.

src/lib-fs/fs-api-private.h
src/lib-fs/fs-api.c
src/lib-fs/fs-api.h

index 5e152988a891b783e72c203268852a65a850728b..8889e6fd3a5a35075780140c34feecdc08518dfd 100644 (file)
@@ -48,6 +48,8 @@ struct fs_vfuncs {
 
        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,
index d371a604d77db9bb5bdbee00b138e3488f2aeaba..97551be7ea76202fe633b64277c973861b9fd66f 100644 (file)
@@ -697,21 +697,18 @@ int fs_write_stream_finish_async(struct fs_file *file)
 
 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,
index 92a32fc5f42e4fcaf5db85c3baa2cb58805c1c92..d5702533f876a87f334f93f3b94b06fc65eb6622 100644 (file)
@@ -268,11 +268,10 @@ int fs_write_stream_finish(struct fs_file *file, struct ostream **output);
 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