Skip to content

Commit

Permalink
lib: iostream-temp: Fixed sending more output after o_stream_send_ist…
Browse files Browse the repository at this point in the history
…ream()
  • Loading branch information
sirainen committed May 18, 2016
1 parent c076ad6 commit 25ec868
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/iostream-temp.c
Expand Up @@ -30,6 +30,8 @@ struct temp_ostream {
uoff_t fd_size;
};

static int o_stream_temp_dup_cancel(struct temp_ostream *tstream);

static void
o_stream_temp_close(struct iostream_private *stream,
bool close_parent ATTR_UNUSED)
Expand Down Expand Up @@ -104,6 +106,10 @@ o_stream_temp_sendv(struct ostream_private *stream,
unsigned int i;

tstream->flags &= ~IOSTREAM_TEMP_FLAG_TRY_FD_DUP;
if (tstream->dupstream != NULL) {
if (o_stream_temp_dup_cancel(tstream) < 0)
return -1;
}

if (tstream->fd != -1)
return o_stream_temp_fd_sendv(tstream, iov, iov_count);
Expand Down
10 changes: 10 additions & 0 deletions src/lib/test-iostream-temp.c
Expand Up @@ -76,6 +76,16 @@ static void test_iostream_temp_istream(void)
test_expect_no_more_errors();
o_stream_destroy(&output);

/* non-working fd-dup: write data after sending istream */
i_stream_seek(input, 0);
output = iostream_temp_create_sized(".intentional-nonexistent-error/",
IOSTREAM_TEMP_FLAG_TRY_FD_DUP, "test", 4);
test_assert(o_stream_send_istream(output, input) > 0);
test_expect_errors(1);
test_assert(o_stream_send(output, "1", 1) == 1);
test_expect_no_more_errors();
o_stream_destroy(&output);

/* non-working fd-dup: send two istreams */
i_stream_seek(input, 0);
input2 = i_stream_create_limit(input, (uoff_t)-1);
Expand Down

0 comments on commit 25ec868

Please sign in to comment.