mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-04 02:06:18 +01:00
Merge branch 'wip/silviol/gsocket_flags'
This commit is contained in:
commit
290c9ee655
@ -2711,8 +2711,6 @@ g_socket_accept (GSocket *socket,
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_ACCEPT);
|
||||
|
||||
if ((ret = accept (socket->priv->fd, NULL, 0)) < 0)
|
||||
{
|
||||
int errsv = get_socket_errno ();
|
||||
@ -2727,6 +2725,8 @@ g_socket_accept (GSocket *socket,
|
||||
errsv == EAGAIN)
|
||||
#endif
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_ACCEPT);
|
||||
|
||||
if (socket->priv->blocking)
|
||||
{
|
||||
if (!g_socket_condition_wait (socket,
|
||||
@ -2743,6 +2743,8 @@ g_socket_accept (GSocket *socket,
|
||||
break;
|
||||
}
|
||||
|
||||
win32_unset_event_mask (socket, FD_ACCEPT);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
{
|
||||
/* The socket inherits the accepting sockets event mask and even object,
|
||||
@ -2834,8 +2836,6 @@ g_socket_connect (GSocket *socket,
|
||||
|
||||
while (1)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_CONNECT);
|
||||
|
||||
if (connect (socket->priv->fd, &buffer.sa,
|
||||
g_socket_address_get_native_size (address)) < 0)
|
||||
{
|
||||
@ -2850,6 +2850,8 @@ g_socket_connect (GSocket *socket,
|
||||
if (errsv == WSAEWOULDBLOCK)
|
||||
#endif
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_CONNECT);
|
||||
|
||||
if (socket->priv->blocking)
|
||||
{
|
||||
if (g_socket_condition_wait (socket, G_IO_OUT, cancellable, error))
|
||||
@ -2875,6 +2877,8 @@ g_socket_connect (GSocket *socket,
|
||||
break;
|
||||
}
|
||||
|
||||
win32_unset_event_mask (socket, FD_CONNECT);
|
||||
|
||||
socket->priv->connected_read = TRUE;
|
||||
socket->priv->connected_write = TRUE;
|
||||
|
||||
@ -3068,8 +3072,6 @@ g_socket_receive_with_timeout (GSocket *socket,
|
||||
|
||||
while (1)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_READ);
|
||||
|
||||
if ((ret = recv (socket->priv->fd, buffer, size, 0)) < 0)
|
||||
{
|
||||
int errsv = get_socket_errno ();
|
||||
@ -3084,6 +3086,8 @@ g_socket_receive_with_timeout (GSocket *socket,
|
||||
errsv == EAGAIN)
|
||||
#endif
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_READ);
|
||||
|
||||
if (timeout != 0)
|
||||
{
|
||||
if (!block_on_timeout (socket, G_IO_IN, timeout, start_time,
|
||||
@ -3094,10 +3098,14 @@ g_socket_receive_with_timeout (GSocket *socket,
|
||||
}
|
||||
}
|
||||
|
||||
win32_unset_event_mask (socket, FD_READ);
|
||||
|
||||
socket_set_error_lazy (error, errsv, _("Error receiving data: %s"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
win32_unset_event_mask (socket, FD_READ);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3263,8 +3271,6 @@ g_socket_send_with_timeout (GSocket *socket,
|
||||
|
||||
while (1)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_WRITE);
|
||||
|
||||
if ((ret = send (socket->priv->fd, (const char *)buffer, size, G_SOCKET_DEFAULT_SEND_FLAGS)) < 0)
|
||||
{
|
||||
int errsv = get_socket_errno ();
|
||||
@ -3279,6 +3285,8 @@ g_socket_send_with_timeout (GSocket *socket,
|
||||
errsv == EAGAIN)
|
||||
#endif
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_WRITE);
|
||||
|
||||
if (timeout != 0)
|
||||
{
|
||||
if (!block_on_timeout (socket, G_IO_OUT, timeout, start_time,
|
||||
@ -4755,8 +4763,6 @@ g_socket_send_message_with_timeout (GSocket *socket,
|
||||
|
||||
while (1)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_WRITE);
|
||||
|
||||
if (address)
|
||||
result = WSASendTo (socket->priv->fd,
|
||||
bufs, num_vectors,
|
||||
@ -4778,6 +4784,8 @@ g_socket_send_message_with_timeout (GSocket *socket,
|
||||
|
||||
if (errsv == WSAEWOULDBLOCK)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_WRITE);
|
||||
|
||||
if (timeout != 0)
|
||||
{
|
||||
if (!block_on_timeout (socket, G_IO_OUT, timeout,
|
||||
@ -5225,8 +5233,6 @@ g_socket_receive_message_with_timeout (GSocket *socket,
|
||||
/* do it */
|
||||
while (1)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_READ);
|
||||
|
||||
addrlen = sizeof addr;
|
||||
if (address)
|
||||
result = WSARecvFrom (socket->priv->fd,
|
||||
@ -5248,6 +5254,8 @@ g_socket_receive_message_with_timeout (GSocket *socket,
|
||||
|
||||
if (errsv == WSAEWOULDBLOCK)
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_READ);
|
||||
|
||||
if (timeout != 0)
|
||||
{
|
||||
if (!block_on_timeout (socket, G_IO_IN, timeout,
|
||||
@ -5261,6 +5269,7 @@ g_socket_receive_message_with_timeout (GSocket *socket,
|
||||
socket_set_error_lazy (error, errsv, _("Error receiving message: %s"));
|
||||
return -1;
|
||||
}
|
||||
win32_unset_event_mask (socket, FD_READ);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,13 @@ poll_source_callback (GPollableInputStream *in,
|
||||
gssize nread;
|
||||
gboolean *success = user_data;
|
||||
|
||||
g_assert_true (g_pollable_input_stream_is_readable (G_POLLABLE_INPUT_STREAM (in)));
|
||||
|
||||
nread = g_pollable_input_stream_read_nonblocking (in, buf, 2, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (nread, ==, 2);
|
||||
g_assert_cmpstr (buf, ==, "x");
|
||||
g_assert_false (g_pollable_input_stream_is_readable (G_POLLABLE_INPUT_STREAM (in)));
|
||||
|
||||
*success = TRUE;
|
||||
return G_SOURCE_REMOVE;
|
||||
@ -65,9 +68,13 @@ write_callback (gpointer user_data)
|
||||
gssize nwrote;
|
||||
GError *error = NULL;
|
||||
|
||||
g_assert_true (g_pollable_output_stream_is_writable (G_POLLABLE_OUTPUT_STREAM (out)));
|
||||
|
||||
nwrote = g_output_stream_write (out, buf, 2, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (nwrote, ==, 2);
|
||||
g_assert_true (g_pollable_output_stream_is_writable (G_POLLABLE_OUTPUT_STREAM (out)));
|
||||
|
||||
/* Give the pipe a few ticks to propagate the write for sockets. On my
|
||||
* iMac i7, 40 works, 30 doesn't. */
|
||||
g_usleep (80L);
|
||||
|
Loading…
Reference in New Issue
Block a user