Merge branch 'socket-ready-fixes' into 'main'

Socket & readiness fixes

See merge request GNOME/glib!3668
This commit is contained in:
Philip Withnall 2023-11-06 14:35:23 +00:00
commit 113063e413
6 changed files with 13 additions and 5 deletions

View File

@ -517,6 +517,7 @@ typedef enum {
* @G_IO_ERROR_NOT_CONNECTED: Transport endpoint is not connected. Since 2.44
* @G_IO_ERROR_MESSAGE_TOO_LARGE: Message too large. Since 2.48.
* @G_IO_ERROR_NO_SUCH_DEVICE: No such device found. Since 2.74
* @G_IO_ERROR_DESTINATION_UNSET: Destination address unset. Since 2.80
*
* Error codes returned by GIO functions.
*
@ -587,6 +588,7 @@ typedef enum {
G_IO_ERROR_NOT_CONNECTED,
G_IO_ERROR_MESSAGE_TOO_LARGE,
G_IO_ERROR_NO_SUCH_DEVICE GIO_AVAILABLE_ENUMERATOR_IN_2_74,
G_IO_ERROR_DESTINATION_UNSET GIO_AVAILABLE_ENUMERATOR_IN_2_80,
} GIOErrorEnum;

View File

@ -228,6 +228,12 @@ g_io_error_from_errno (gint err_no)
break;
#endif
#ifdef EDESTADDRREQ
case EDESTADDRREQ:
return G_IO_ERROR_DESTINATION_UNSET;
break;
#endif
#ifdef EMSGSIZE
case EMSGSIZE:
return G_IO_ERROR_MESSAGE_TOO_LARGE;

View File

@ -4060,7 +4060,7 @@ socket_source_dispatch (GSource *source,
#endif
timeout = g_source_get_ready_time (source);
if (timeout >= 0 && timeout < g_source_get_time (source) &&
if (timeout >= 0 && timeout <= g_source_get_time (source) &&
!g_socket_is_closed (socket_source->socket))
{
socket->priv->timed_out = TRUE;

View File

@ -557,7 +557,7 @@ test_error_from_errno (void)
#ifdef EDESTADDRREQ
g_assert_cmpuint (g_io_error_from_errno (EDESTADDRREQ), ==,
G_IO_ERROR_FAILED);
G_IO_ERROR_DESTINATION_UNSET);
#endif
#ifdef EPROTOTYPE

View File

@ -777,7 +777,7 @@ test_ip_sync_dgram (GSocketFamily family)
len = g_socket_send_messages (client, m, G_N_ELEMENTS (m), 0, NULL, &error);
/* This error code may vary between platforms and over time; it is not guaranteed API: */
#ifndef G_OS_WIN32
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_DESTINATION_UNSET);
#else
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_CONNECTED);
#endif

View File

@ -1952,8 +1952,8 @@ g_source_set_ready_time (GSource *source,
* Gets the "ready time" of @source, as set by
* g_source_set_ready_time().
*
* Any time before the current monotonic time (including 0) is an
* indication that the source will fire immediately.
* Any time before or equal to the current monotonic time (including 0)
* is an indication that the source will fire immediately.
*
* Returns: the monotonic ready time, -1 for "never"
**/