bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
987c15a5980f53225e60f79325c14cb2acddaabbTimo Sirainenvoid completed(enum iostream_proxy_side side ATTR_UNUSED,
987c15a5980f53225e60f79325c14cb2acddaabbTimo Sirainen enum iostream_proxy_status status ATTR_UNUSED, int *u0)
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi if (--*u0 == 0)
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi test_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sfdl) == 0);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi test_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sfdr) == 0);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi struct istream *left_in = i_stream_create_fd(sfdl[1], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi struct ostream *left_out = o_stream_create_fd(sfdl[1], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi struct istream *right_in = i_stream_create_fd(sfdr[1], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi struct ostream *right_out = o_stream_create_fd(sfdr[1], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi proxy = iostream_proxy_create(left_in, left_out, right_in, right_out);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi iostream_proxy_set_completion_callback(proxy, completed, &counter);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi left_in = i_stream_create_fd(sfdl[0], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi left_out = o_stream_create_fd(sfdl[0], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi right_in = i_stream_create_fd(sfdr[0], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi right_out = o_stream_create_fd(sfdr[0], IO_BLOCK_SIZE);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi test_assert(o_stream_send_str(left_out, "hello, world") > 0);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi test_assert(strcmp((const char*)i_stream_get_data(right_in, &bytes), "hello, world") == 0);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi test_assert(o_stream_send_str(right_out, "hello, world") > 0);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi test_assert(strcmp((const char*)i_stream_get_data(left_in, &bytes), "hello, world") == 0);
f7060b8499ed07205734cf7af94ad5405fa687b5Aki Tuomi /* close fd */