mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
GSocket: fix GIOCondition on timed-out socket operation
The docs for g_socket_set_timeout() claimed that if an async operation timed out, the GIOCondition passed to the source callback would be G_IO_IN or G_IO_OUT (thus prompting the caller to call g_socket_receive/send and get a G_IO_ERROR_TIMED_OUT), but in fact it ended up being 0, and gio/tests/socket.c was erroneously testing for that instead of the correct value. Fix this.
This commit is contained in:
@@ -2439,7 +2439,6 @@ socket_source_prepare (GSource *source,
|
||||
if (*timeout < 0)
|
||||
{
|
||||
socket_source->socket->priv->timed_out = TRUE;
|
||||
socket_source->pollfd.revents = socket_source->condition & (G_IO_IN | G_IO_OUT);
|
||||
*timeout = 0;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2476,6 +2475,8 @@ socket_source_dispatch (GSource *source,
|
||||
#ifdef G_OS_WIN32
|
||||
socket_source->pollfd.revents = update_condition (socket_source->socket);
|
||||
#endif
|
||||
if (socket_source->socket->priv->timed_out)
|
||||
socket_source->pollfd.revents |= socket_source->condition & (G_IO_IN | G_IO_OUT);
|
||||
|
||||
return (*func) (socket_source->socket,
|
||||
socket_source->pollfd.revents & socket_source->condition,
|
||||
|
Reference in New Issue
Block a user