Skip to content

Commit

Permalink
lib: iostream-multiplex tests - Fix hangs by setting the pipe fds non…
Browse files Browse the repository at this point in the history
…-blocking
  • Loading branch information
sirainen committed Oct 5, 2017
1 parent 75ae885 commit eaf276b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/test-istream-multiplex.c
Expand Up @@ -2,6 +2,7 @@

#include "test-lib.h"
#include "ioloop.h"
#include "fd-set-nonblock.h"
#include "str.h"
#include "crc32.h"
#include "randgen.h"
Expand Down Expand Up @@ -284,6 +285,8 @@ static void test_istream_multiplex_stream(void)

int fds[2];
test_assert(pipe(fds) == 0);
fd_set_nonblock(fds[0], TRUE);
fd_set_nonblock(fds[1], TRUE);
struct ostream *os = o_stream_create_fd(fds[1], (size_t)-1, FALSE);
struct istream *is = i_stream_create_fd(fds[0], 10 + rand() % 10, FALSE);

Expand Down
5 changes: 5 additions & 0 deletions src/lib/test-multiplex.c
Expand Up @@ -3,6 +3,7 @@
#include "test-lib.h"
#include "ioloop.h"
#include "str.h"
#include "fd-set-nonblock.h"
#include "istream.h"
#include "istream-multiplex.h"
#include "ostream.h"
Expand Down Expand Up @@ -83,6 +84,8 @@ static void setup_channel(struct test_channel *channel,
channel->io = io_add_istream(is, test_istream_multiplex_stream_read,
channel);
test_assert(pipe(channel->fds) == 0);
fd_set_nonblock(channel->fds[0], TRUE);
fd_set_nonblock(channel->fds[1], TRUE);
channel->in_alt = i_stream_create_fd(channel->fds[0], (size_t)-1, FALSE);
channel->out_alt = o_stream_create_fd(channel->fds[1], IO_BLOCK_SIZE, FALSE);
channel->io_alt = io_add_istream(channel->in_alt, test_istream_read_alt,
Expand Down Expand Up @@ -119,6 +122,8 @@ static void test_multiplex_stream(void) {

int fds[2];
test_assert(pipe(fds) == 0);
fd_set_nonblock(fds[0], TRUE);
fd_set_nonblock(fds[1], TRUE);
struct ostream *os = o_stream_create_fd(fds[1], (size_t)-1, FALSE);
struct istream *is = i_stream_create_fd(fds[0], (size_t)-1, FALSE);

Expand Down
3 changes: 3 additions & 0 deletions src/lib/test-ostream-multiplex.c
Expand Up @@ -3,6 +3,7 @@
#include "test-lib.h"
#include "randgen.h"
#include "ioloop.h"
#include "fd-set-nonblock.h"
#include "str.h"
#include "istream.h"
#include "ostream-private.h"
Expand Down Expand Up @@ -108,6 +109,8 @@ static void test_ostream_multiplex_stream(void)

int fds[2];
test_assert(pipe(fds) == 0);
fd_set_nonblock(fds[0], TRUE);
fd_set_nonblock(fds[1], TRUE);
struct ostream *os = o_stream_create_fd(fds[1], (size_t)-1, FALSE);
struct istream *is = i_stream_create_fd(fds[0], (size_t)-1, FALSE);

Expand Down

0 comments on commit eaf276b

Please sign in to comment.