From 9abae3dd78d508aea535e26a97b0be9bdf5e1f84 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 19 Nov 2012 15:55:53 +0000 Subject: [PATCH 1/3] Remove check for abstract sockets, not relevant to dbus-glib test-profile.c was its only use, and all it was used for was to listen on an abstract or path-based socket, matching what D-Bus would do, when obtaining comparative performance figures for D-Bus vs. plain Unix sockets. test-profile.c isn't normally run, only works on Unix, and the check for abstract sockets was broken on current glibc (fd.o #29895), leading to us using the non-abstract code path anyway, so this clearly wasn't very important. I'm tempted to delete test-profile.c entirely, but until then, let's just make it use path-based sockets. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=40711 Signed-off-by: Simon McVittie --- Android.mk | 1 - configure.ac | 67 ---------------------------------------------- test/core/test-profile.c | 20 +------------- 3 files changed, 1 insertion(+), 87 deletions(-) diff --git a/Android.mk b/Android.mk index 8ba5609..7d30b96 100644 --- a/Android.mk +++ b/Android.mk @@ -16,7 +16,6 @@ dbus-glib-configure-real: CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \ PKG_CONFIG_LIBDIR="$(CONFIGURE_PKG_CONFIG_LIBDIR)" \ PKG_CONFIG_TOP_BUILD_DIR=$(PKG_CONFIG_TOP_BUILD_DIR) \ - ac_cv_have_abstract_sockets=no \ ac_cv_lib_expat_XML_ParserCreate_MM=yes \ $(DBUS_GLIB_TOP)/$(CONFIGURE) --host=arm-linux-androideabi \ --disable-nls --disable-gtk-doc && \ diff --git a/configure.ac b/configure.ac index f27a407..89b097c 100644 --- a/configure.ac +++ b/configure.ac @@ -242,73 +242,6 @@ if test "x$dbus_have_socklen_t" = "xyes"; then AC_DEFINE(HAVE_SOCKLEN_T,1,[Have socklen_t type]) fi -#### Abstract sockets - -AC_LANG_PUSH(C) -AC_CACHE_CHECK([abstract socket namespace], - ac_cv_have_abstract_sockets, - [AC_RUN_IFELSE([AC_LANG_PROGRAM( -[[ -#include -#include -#include -#include -#include -#include -#include -]], -[[ - int listen_fd; - struct sockaddr_un addr; - - listen_fd = socket (PF_UNIX, SOCK_STREAM, 0); - - if (listen_fd < 0) - { - fprintf (stderr, "socket() failed: %s\n", strerror (errno)); - exit (1); - } - - memset (&addr, '\0', sizeof (addr)); - addr.sun_family = AF_UNIX; - strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test"); - addr.sun_path[0] = '\0'; /* this is what makes it abstract */ - - if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0) - { - fprintf (stderr, "Abstract socket namespace bind() failed: %s\n", - strerror (errno)); - exit (1); - } - else - exit (0); -]])], - [ac_cv_have_abstract_sockets=yes], - [ac_cv_have_abstract_sockets=no] -)]) -AC_LANG_POP(C) - -if test x$enable_abstract_sockets = xyes; then - if test x$ac_cv_have_abstract_sockets = xno; then - AC_MSG_ERROR([Abstract sockets explicitly required, and support not detected.]) - fi -fi - -if test x$enable_abstract_sockets = xno; then - ac_cv_have_abstract_sockets=no; -fi - -if test x$ac_cv_have_abstract_sockets = xyes ; then - DBUS_PATH_OR_ABSTRACT=abstract - AC_DEFINE(HAVE_ABSTRACT_SOCKETS,1,[Have abstract socket namespace]) -else - DBUS_PATH_OR_ABSTRACT=path -fi - -# this is used in addresses to prefer abstract, e.g. -# unix:path=/foo or unix:abstract=/foo -AC_SUBST(DBUS_PATH_OR_ABSTRACT) - #### Sort out XML library # see what we have diff --git a/test/core/test-profile.c b/test/core/test-profile.c index b5fd2c9..5701285 100644 --- a/test/core/test-profile.c +++ b/test/core/test-profile.c @@ -836,14 +836,6 @@ plain_sockets_init_server (ServerData *sd) _DBUS_ZERO (addr); addr.sun_family = AF_UNIX; -#ifdef HAVE_ABSTRACT_SOCKETS - /* remember that abstract names aren't nul-terminated so we rely - * on sun_path being filled in with zeroes above. - */ - addr.sun_path[0] = '\0'; /* this is what says "use abstract" */ - strncpy (&addr.sun_path[1], path, _DBUS_MAX_SUN_PATH_LENGTH - 2); - /* _dbus_verbose_bytes (addr.sun_path, sizeof (addr.sun_path)); */ -#else /* HAVE_ABSTRACT_SOCKETS */ { struct stat sb; @@ -853,7 +845,6 @@ plain_sockets_init_server (ServerData *sd) } strncpy (addr.sun_path, path, _DBUS_MAX_SUN_PATH_LENGTH - 1); -#endif /* ! HAVE_ABSTRACT_SOCKETS */ if (bind (server->listen_fd, (struct sockaddr*) &addr, sizeof (addr)) < 0) { @@ -963,17 +954,8 @@ plain_sockets_thread_func (void *data) _DBUS_ZERO (addr); addr.sun_family = AF_UNIX; -#ifdef HAVE_ABSTRACT_SOCKETS - /* remember that abstract names aren't nul-terminated so we rely - * on sun_path being filled in with zeroes above. - */ - addr.sun_path[0] = '\0'; /* this is what says "use abstract" */ - strncpy (&addr.sun_path[1], plain_sockets_address, _DBUS_MAX_SUN_PATH_LENGTH - 2); - /* _dbus_verbose_bytes (addr.sun_path, sizeof (addr.sun_path)); */ -#else /* HAVE_ABSTRACT_SOCKETS */ strncpy (addr.sun_path, plain_sockets_address, _DBUS_MAX_SUN_PATH_LENGTH - 1); -#endif /* ! HAVE_ABSTRACT_SOCKETS */ - + if (connect (fd, (struct sockaddr*) &addr, sizeof (addr)) < 0) { g_printerr ("Failed to connect to socket %s: %s", -- 1.7.10.4