Darwin's poll doesn't change revents if there are no available events, though it returns 0. Initialize the fd.revents to 0 so that the test passes.
That reveals a test failure, though, because with socket streams it takes time for an event to pass through the socket. Provide an 80-usec delay to allow time for the propagation.
gint result;
poll_fd.fd = socket->priv->fd;
poll_fd.events = condition;
+ poll_fd.revents = 0;
do
result = g_poll (&poll_fd, 1, 0);
poll_fd.fd = unix_stream->priv->fd;
poll_fd.events = G_IO_IN;
+ poll_fd.revents = 0;
do
result = g_poll (&poll_fd, 1, 0);
poll_fd.fd = unix_stream->priv->fd;
poll_fd.events = G_IO_OUT;
+ poll_fd.revents = 0;
do
result = g_poll (&poll_fd, 1, 0);
socket_out = NULL;
}
+ /* Wait a few ticks to check for the pipe to propagate the
+ * write. Finesses the race condition in the following test,
+ * where is_readable fails because the write hasn't propagated,
+ * but the read then succeeds because it has. */
+ g_usleep (80L);
+
is_readable = g_pollable_input_stream_is_readable (pollable_in);
res = g_pollable_input_stream_read_nonblocking (pollable_in,
inptr, 1,
nwrote = g_output_stream_write (out, buf, 2, NULL, &error);
g_assert_no_error (error);
g_assert_cmpint (nwrote, ==, 2);
+/* Give the pipe a few ticks to propagate the write for sockets. On my
+ * iMac i7, 40 works, 30 doesn't. */
+ g_usleep (80L);
check_source_readability_callback (GINT_TO_POINTER (TRUE));