[glib: 6/12] gio: compile GUnixConnection on all platforms
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 6/12] gio: compile GUnixConnection on all platforms
- Date: Wed, 26 Jan 2022 15:11:49 +0000 (UTC)
commit 83d45c4f35dc87ba71145283b88b00cd3f44caba
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Wed Jan 19 15:52:15 2022 +0400
gio: compile GUnixConnection on all platforms
On !UNIX, return an error for send_fd() & receive_fd().
(the unixfdmessage unit is not compiled on !UNIX)
The header is installed under the common GIO include directory.
Ensure G_TYPE_UNIX_CONNECTION is registered on all platforms.
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
docs/reference/gio/meson.build | 1 -
gio/gsocketconnection.c | 2 --
gio/gunixconnection.c | 23 ++++++++++++++++++++---
gio/meson.build | 4 ++--
4 files changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/docs/reference/gio/meson.build b/docs/reference/gio/meson.build
index dba062055..bb14e6923 100644
--- a/docs/reference/gio/meson.build
+++ b/docs/reference/gio/meson.build
@@ -108,7 +108,6 @@ if get_option('gtk_doc')
if host_system == 'windows'
ignore_headers += [
'gfiledescriptorbased.h',
- 'gunixconnection.h',
'gunixmounts.h',
'gunixfdlist.h',
'gunixfdmessage.h',
diff --git a/gio/gsocketconnection.c b/gio/gsocketconnection.c
index 37d5d330c..64fe9753b 100644
--- a/gio/gsocketconnection.c
+++ b/gio/gsocketconnection.c
@@ -615,9 +615,7 @@ g_socket_connection_factory_register_type (GType g_type,
static void
init_builtin_types (void)
{
-#ifndef G_OS_WIN32
g_type_ensure (G_TYPE_UNIX_CONNECTION);
-#endif
g_type_ensure (G_TYPE_TCP_CONNECTION);
}
diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c
index e9e2f75f0..e89aba6ca 100644
--- a/gio/gunixconnection.c
+++ b/gio/gunixconnection.c
@@ -24,7 +24,9 @@
#include <errno.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
/**
* SECTION:gunixconnection
@@ -39,9 +41,12 @@
* It contains functions to do some of the UNIX socket specific
* functionality like passing file descriptors.
*
- * Note that `<gio/gunixconnection.h>` belongs to the UNIX-specific
- * GIO interfaces, thus you have to use the `gio-unix-2.0.pc`
- * pkg-config file when using it.
+ * Since GLib 2.72, #GUnixConnection is available on all platforms. It requires
+ * underlying system support (such as Windows 10 with `AF_UNIX`) at run time.
+ *
+ * Before GLib 2.72, `<gio/gunixconnection.h>` belonged to the UNIX-specific GIO
+ * interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file when
+ * using it. This is no longer necessary since GLib 2.72.
*
* Since: 2.22
*/
@@ -86,6 +91,7 @@ g_unix_connection_send_fd (GUnixConnection *connection,
GCancellable *cancellable,
GError **error)
{
+#ifdef G_OS_UNIX
GSocketControlMessage *scm;
GSocket *socket;
@@ -114,6 +120,11 @@ g_unix_connection_send_fd (GUnixConnection *connection,
g_object_unref (scm);
return TRUE;
+#else
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Sending FD is not supported"));
+ return FALSE;
+#endif
}
/**
@@ -139,6 +150,7 @@ g_unix_connection_receive_fd (GUnixConnection *connection,
GCancellable *cancellable,
GError **error)
{
+#ifdef G_OS_UNIX
GSocketControlMessage **scms;
gint *fds, nfd, fd, nscm;
GUnixFDMessage *fdmsg;
@@ -221,6 +233,11 @@ g_unix_connection_receive_fd (GUnixConnection *connection,
}
return fd;
+#else
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Receiving FD is not supported"));
+ return -1;
+#endif
}
static void
diff --git a/gio/meson.build b/gio/meson.build
index 9e7539edd..d6a3d2d76 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -346,7 +346,6 @@ if host_system != 'windows'
unix_sources = files(
'gfiledescriptorbased.c',
'giounix-private.c',
- 'gunixconnection.c',
'gunixfdlist.c',
'gunixfdmessage.c',
'gunixmount.c',
@@ -374,7 +373,6 @@ if host_system != 'windows'
gio_unix_include_headers = files(
'gfiledescriptorbased.h',
- 'gunixconnection.h',
'gunixmounts.h',
'gunixfdlist.h',
'gunixfdmessage.h',
@@ -565,6 +563,7 @@ gio_sources = files(
'gdtlsclientconnection.c',
'gdtlsserverconnection.c',
'gunionvolumemonitor.c',
+ 'gunixconnection.c',
'gunixcredentialsmessage.c',
'gunixsocketaddress.c',
'gvfs.c',
@@ -702,6 +701,7 @@ gio_headers = files(
'gdtlsconnection.h',
'gdtlsclientconnection.h',
'gdtlsserverconnection.h',
+ 'gunixconnection.h',
'gunixcredentialsmessage.h',
'gunixsocketaddress.h',
'gvfs.h',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]