mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
gsocket: Don't g_error() if file-descriptor is not a socket
This code was out of date with current coding practices. Nowadays it's common to receive file descriptors over environment variables from other processes like systemd. The unit files that control these file descriptors are configurable by sysadmins. It is not (necessarily) a programmer error when g_socket_details_from_fd() is called with a file descriptor that is not a socket. It can also be a system and/or configuration error. https://bugzilla.gnome.org/show_bug.cgi?id=746339
This commit is contained in:
parent
a9c8cc143c
commit
f405f42115
@ -318,24 +318,6 @@ g_socket_details_from_fd (GSocket *socket)
|
||||
if (!g_socket_get_option (socket, SOL_SOCKET, SO_TYPE, &value, NULL))
|
||||
{
|
||||
errsv = get_socket_errno ();
|
||||
|
||||
switch (errsv)
|
||||
{
|
||||
#ifdef ENOTSOCK
|
||||
case ENOTSOCK:
|
||||
#else
|
||||
#ifdef WSAENOTSOCK
|
||||
case WSAENOTSOCK:
|
||||
#endif
|
||||
#endif
|
||||
case EBADF:
|
||||
/* programmer error */
|
||||
g_error ("creating GSocket from fd %d: %s\n",
|
||||
fd, socket_strerror (errsv));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -1060,6 +1042,9 @@ g_socket_new (GSocketFamily family,
|
||||
* On success, the returned #GSocket takes ownership of @fd. On failure, the
|
||||
* caller must close @fd themselves.
|
||||
*
|
||||
* Since GLib 2.46, it is no longer a fatal error to call this on a non-socket
|
||||
* descriptor. Instead, a GError will be set with code %G_IO_ERROR_FAILED
|
||||
*
|
||||
* Returns: a #GSocket or %NULL on error.
|
||||
* Free the returned object with g_object_unref().
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user