Mercurial > dovecot > core-2.2
comparison src/lib/test-istream-multiplex.c @ 22577:c6c9c24d6182
lib: iostream-multiplex tests - Fix hangs by setting the pipe fds non-blocking
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 05 Oct 2017 20:25:29 +0300 |
parents | 7db517071db5 |
children | 1a7bbda6284b |
comparison
equal
deleted
inserted
replaced
22576:707ae9de3812 | 22577:c6c9c24d6182 |
---|---|
1 /* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */ | 1 /* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */ |
2 | 2 |
3 #include "test-lib.h" | 3 #include "test-lib.h" |
4 #include "ioloop.h" | 4 #include "ioloop.h" |
5 #include "fd-set-nonblock.h" | |
5 #include "str.h" | 6 #include "str.h" |
6 #include "crc32.h" | 7 #include "crc32.h" |
7 #include "randgen.h" | 8 #include "randgen.h" |
8 #include "istream-private.h" | 9 #include "istream-private.h" |
9 #include "istream-multiplex.h" | 10 #include "istream-multiplex.h" |
282 struct ioloop *ioloop = io_loop_create(); | 283 struct ioloop *ioloop = io_loop_create(); |
283 io_loop_set_current(ioloop); | 284 io_loop_set_current(ioloop); |
284 | 285 |
285 int fds[2]; | 286 int fds[2]; |
286 test_assert(pipe(fds) == 0); | 287 test_assert(pipe(fds) == 0); |
288 fd_set_nonblock(fds[0], TRUE); | |
289 fd_set_nonblock(fds[1], TRUE); | |
287 struct ostream *os = o_stream_create_fd(fds[1], (size_t)-1, FALSE); | 290 struct ostream *os = o_stream_create_fd(fds[1], (size_t)-1, FALSE); |
288 struct istream *is = i_stream_create_fd(fds[0], 10 + rand() % 10, FALSE); | 291 struct istream *is = i_stream_create_fd(fds[0], 10 + rand() % 10, FALSE); |
289 | 292 |
290 struct istream *chan0 = i_stream_create_multiplex(is, (size_t)-1); | 293 struct istream *chan0 = i_stream_create_multiplex(is, (size_t)-1); |
291 struct istream *chan1 = i_stream_multiplex_add_channel(chan0, 1); | 294 struct istream *chan1 = i_stream_multiplex_add_channel(chan0, 1); |