Lines Matching defs:channel

35 static void test_multiplex_channel_write(struct test_channel *channel)
40 o_stream_nsend(channel->out, buf, len);
41 o_stream_nsend(channel->out_alt, buf, len);
44 static void test_multiplex_stream_write(struct ostream *channel ATTR_UNUSED)
53 static void test_istream_multiplex_stream_read(struct test_channel *channel)
58 if (i_stream_read(channel->in) > 0) {
59 data = i_stream_get_data(channel->in, &siz);
60 buffer_append(channel->received, data, siz);
61 i_stream_skip(channel->in, siz);
65 static void test_istream_read_alt(struct test_channel *channel)
70 if (i_stream_read(channel->in_alt) > 0) {
71 data = i_stream_get_data(channel->in_alt, &siz);
72 buffer_append(channel->received_alt, data, siz);
73 i_stream_skip(channel->in_alt, siz);
77 static void setup_channel(struct test_channel *channel,
80 /* setup first channel */
81 channel->in = is;
82 channel->out = os;
83 channel->io = io_add_istream(is, test_istream_multiplex_stream_read,
84 channel);
85 test_assert(pipe(channel->fds) == 0);
86 fd_set_nonblock(channel->fds[0], TRUE);
87 fd_set_nonblock(channel->fds[1], TRUE);
88 channel->in_alt = i_stream_create_fd(channel->fds[0], (size_t)-1);
89 channel->out_alt = o_stream_create_fd(channel->fds[1], IO_BLOCK_SIZE);
90 channel->io_alt = io_add_istream(channel->in_alt, test_istream_read_alt,
91 channel);
92 channel->received = buffer_create_dynamic(default_pool, 32768);
93 channel->received_alt = buffer_create_dynamic(default_pool, 32768);
96 static void teardown_channel(struct test_channel *channel)
98 test_assert(memcmp(channel->received->data,
99 channel->received_alt->data,
100 channel->received->used) == 0);
101 test_assert(channel->received->used == channel->received_alt->used);
103 buffer_free(&channel->received);
104 buffer_free(&channel->received_alt);
106 io_remove(&channel->io);
107 io_remove(&channel->io_alt);
108 i_stream_unref(&channel->in);
109 test_assert(o_stream_finish(channel->out) > 0);
110 o_stream_unref(&channel->out);
111 i_stream_unref(&channel->in_alt);
112 test_assert(o_stream_finish(channel->out_alt) > 0);
113 o_stream_unref(&channel->out_alt);
114 i_close_fd(&channel->fds[0]);
115 i_close_fd(&channel->fds[1]);