]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: ostream-file now automatically corks during flush callback.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 1 Jul 2016 00:03:02 +0000 (03:03 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 6 Jul 2016 13:01:50 +0000 (16:01 +0300)
src/lib/ostream-file.c

index a1c71c5a72d5962bed0d1ac0b710ae13e16316f1..7fc4c27ea6c7fc2fe2b01a6eff725d4444de3c33 100644 (file)
@@ -462,6 +462,7 @@ static void o_stream_grow_buffer(struct file_ostream *fstream, size_t bytes)
 static void stream_send_io(struct file_ostream *fstream)
 {
        struct ostream *ostream = &fstream->ostream.ostream;
+       bool use_cork = !fstream->ostream.corked;
        int ret;
 
        /* Set flush_pending = FALSE first before calling the flush callback,
@@ -471,10 +472,14 @@ static void stream_send_io(struct file_ostream *fstream)
        fstream->flush_pending = FALSE;
 
        o_stream_ref(ostream);
+       if (use_cork)
+               o_stream_cork(ostream);
        if (fstream->ostream.callback != NULL)
                ret = fstream->ostream.callback(fstream->ostream.context);
        else
                ret = o_stream_file_flush(&fstream->ostream);
+       if (use_cork)
+               o_stream_uncork(ostream);
 
        if (ret == 0)
                fstream->flush_pending = TRUE;