]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: iostream-temp: Fixed sending more output after o_stream_send_istream()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 18 May 2016 14:42:06 +0000 (17:42 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 18 May 2016 14:47:44 +0000 (17:47 +0300)
src/lib/iostream-temp.c
src/lib/test-iostream-temp.c

index f3776c6af854cd34d0a2af8caafdf669d28379ef..779c4481c491ea850f7ba068ac53d89529ce88e9 100644 (file)
@@ -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)
@@ -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);
index d2978a6e2438d6ac7166c4aa9e0ce6a33456ce60..d4157ba3c5d93739cb59cb1595bfc3627e5756a0 100644 (file)
@@ -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);