[glib] gsocket: Don't g_error() if file-descriptor is not a socket
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gsocket: Don't g_error() if file-descriptor is not a socket
- Date: Thu, 2 Jul 2015 10:27:51 +0000 (UTC)
commit f405f4211565fde3c58f3da9b18ddcdc5d82ccf2
Author: Stef Walter <stefw redhat com>
Date: Tue Mar 17 13:06:02 2015 +0100
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
gio/gsocket.c | 21 +++------------------
1 files changed, 3 insertions(+), 18 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index 7d6e91d..6856d0e 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -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().
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]