Skip to content

Commit

Permalink
lib: ostream-file now automatically corks during flush callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen authored and GitLab committed Jul 6, 2016
1 parent 8b3f557 commit 89d88a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/ostream-file.c
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit 89d88a5

Please sign in to comment.