Fix poll able streams for Darwin (and probably BSD)

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.
This commit is contained in:
John Ralls
2012-11-09 09:22:19 -08:00
parent 5588d47985
commit b65dac802e
5 changed files with 12 additions and 0 deletions

View File

@@ -1016,6 +1016,12 @@ test_converter_pollable (void)
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,