mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 01:58:54 +01:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -108,7 +108,6 @@ if get_option('gtk_doc')
 | 
				
			|||||||
  if host_system == 'windows'
 | 
					  if host_system == 'windows'
 | 
				
			||||||
    ignore_headers += [
 | 
					    ignore_headers += [
 | 
				
			||||||
      'gfiledescriptorbased.h',
 | 
					      'gfiledescriptorbased.h',
 | 
				
			||||||
      'gunixconnection.h',
 | 
					 | 
				
			||||||
      'gunixmounts.h',
 | 
					      'gunixmounts.h',
 | 
				
			||||||
      'gunixfdlist.h',
 | 
					      'gunixfdlist.h',
 | 
				
			||||||
      'gunixfdmessage.h',
 | 
					      'gunixfdmessage.h',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -615,9 +615,7 @@ g_socket_connection_factory_register_type (GType         g_type,
 | 
				
			|||||||
static void
 | 
					static void
 | 
				
			||||||
init_builtin_types (void)
 | 
					init_builtin_types (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#ifndef G_OS_WIN32
 | 
					 | 
				
			||||||
  g_type_ensure (G_TYPE_UNIX_CONNECTION);
 | 
					  g_type_ensure (G_TYPE_UNIX_CONNECTION);
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
  g_type_ensure (G_TYPE_TCP_CONNECTION);
 | 
					  g_type_ensure (G_TYPE_TCP_CONNECTION);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,7 +24,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#ifdef HAVE_UNISTD_H
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * SECTION:gunixconnection
 | 
					 * SECTION:gunixconnection
 | 
				
			||||||
@@ -39,9 +41,12 @@
 | 
				
			|||||||
 * It contains functions to do some of the UNIX socket specific
 | 
					 * It contains functions to do some of the UNIX socket specific
 | 
				
			||||||
 * functionality like passing file descriptors.
 | 
					 * functionality like passing file descriptors.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Note that `<gio/gunixconnection.h>` belongs to the UNIX-specific
 | 
					 * Since GLib 2.72, #GUnixConnection is available on all platforms. It requires
 | 
				
			||||||
 * GIO interfaces, thus you have to use the `gio-unix-2.0.pc`
 | 
					 * underlying system support (such as Windows 10 with `AF_UNIX`) at run time.
 | 
				
			||||||
 * pkg-config file when using it.
 | 
					 *
 | 
				
			||||||
 | 
					 * 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
 | 
					 * Since: 2.22
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -86,6 +91,7 @@ g_unix_connection_send_fd (GUnixConnection  *connection,
 | 
				
			|||||||
                           GCancellable     *cancellable,
 | 
					                           GCancellable     *cancellable,
 | 
				
			||||||
                           GError          **error)
 | 
					                           GError          **error)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					#ifdef G_OS_UNIX
 | 
				
			||||||
  GSocketControlMessage *scm;
 | 
					  GSocketControlMessage *scm;
 | 
				
			||||||
  GSocket *socket;
 | 
					  GSocket *socket;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -114,6 +120,11 @@ g_unix_connection_send_fd (GUnixConnection  *connection,
 | 
				
			|||||||
  g_object_unref (scm);
 | 
					  g_object_unref (scm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return TRUE;
 | 
					  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,
 | 
					                              GCancellable     *cancellable,
 | 
				
			||||||
                              GError          **error)
 | 
					                              GError          **error)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					#ifdef G_OS_UNIX
 | 
				
			||||||
  GSocketControlMessage **scms;
 | 
					  GSocketControlMessage **scms;
 | 
				
			||||||
  gint *fds, nfd, fd, nscm;
 | 
					  gint *fds, nfd, fd, nscm;
 | 
				
			||||||
  GUnixFDMessage *fdmsg;
 | 
					  GUnixFDMessage *fdmsg;
 | 
				
			||||||
@@ -221,6 +233,11 @@ g_unix_connection_receive_fd (GUnixConnection  *connection,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return fd;
 | 
					  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
 | 
					static void
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -346,7 +346,6 @@ if host_system != 'windows'
 | 
				
			|||||||
  unix_sources = files(
 | 
					  unix_sources = files(
 | 
				
			||||||
    'gfiledescriptorbased.c',
 | 
					    'gfiledescriptorbased.c',
 | 
				
			||||||
    'giounix-private.c',
 | 
					    'giounix-private.c',
 | 
				
			||||||
    'gunixconnection.c',
 | 
					 | 
				
			||||||
    'gunixfdlist.c',
 | 
					    'gunixfdlist.c',
 | 
				
			||||||
    'gunixfdmessage.c',
 | 
					    'gunixfdmessage.c',
 | 
				
			||||||
    'gunixmount.c',
 | 
					    'gunixmount.c',
 | 
				
			||||||
@@ -374,7 +373,6 @@ if host_system != 'windows'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  gio_unix_include_headers = files(
 | 
					  gio_unix_include_headers = files(
 | 
				
			||||||
    'gfiledescriptorbased.h',
 | 
					    'gfiledescriptorbased.h',
 | 
				
			||||||
    'gunixconnection.h',
 | 
					 | 
				
			||||||
    'gunixmounts.h',
 | 
					    'gunixmounts.h',
 | 
				
			||||||
    'gunixfdlist.h',
 | 
					    'gunixfdlist.h',
 | 
				
			||||||
    'gunixfdmessage.h',
 | 
					    'gunixfdmessage.h',
 | 
				
			||||||
@@ -565,6 +563,7 @@ gio_sources = files(
 | 
				
			|||||||
  'gdtlsclientconnection.c',
 | 
					  'gdtlsclientconnection.c',
 | 
				
			||||||
  'gdtlsserverconnection.c',
 | 
					  'gdtlsserverconnection.c',
 | 
				
			||||||
  'gunionvolumemonitor.c',
 | 
					  'gunionvolumemonitor.c',
 | 
				
			||||||
 | 
					  'gunixconnection.c',
 | 
				
			||||||
  'gunixcredentialsmessage.c',
 | 
					  'gunixcredentialsmessage.c',
 | 
				
			||||||
  'gunixsocketaddress.c',
 | 
					  'gunixsocketaddress.c',
 | 
				
			||||||
  'gvfs.c',
 | 
					  'gvfs.c',
 | 
				
			||||||
@@ -702,6 +701,7 @@ gio_headers = files(
 | 
				
			|||||||
  'gdtlsconnection.h',
 | 
					  'gdtlsconnection.h',
 | 
				
			||||||
  'gdtlsclientconnection.h',
 | 
					  'gdtlsclientconnection.h',
 | 
				
			||||||
  'gdtlsserverconnection.h',
 | 
					  'gdtlsserverconnection.h',
 | 
				
			||||||
 | 
					  'gunixconnection.h',
 | 
				
			||||||
  'gunixcredentialsmessage.h',
 | 
					  'gunixcredentialsmessage.h',
 | 
				
			||||||
  'gunixsocketaddress.h',
 | 
					  'gunixsocketaddress.h',
 | 
				
			||||||
  'gvfs.h',
 | 
					  'gvfs.h',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user