summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2011-12-21 20:40:22 +0100
committerRalf Habacker <ralf.habacker@freenet.de>2011-12-21 20:40:22 +0100
commitef8d0d75d538db543ab0ff68809656f3972e3848 (patch)
tree25905fcf957f1b9eec71adc0cf5d393d17eb2699
parent33c43947cd123694dc80335995a76643526d7620 (diff)
parent25d6d2d42975e5d88c89be7afdcb94c7b4bcb78f (diff)
downloaddbus-ef8d0d75d538db543ab0ff68809656f3972e3848.tar.gz
Merge branch 'dbus-1.4' of ssh://git.freedesktop.org/git/dbus/dbus into dbus-1.4
-rw-r--r--cmake/CMakeLists.txt19
-rw-r--r--cmake/modules/MacrosAutotools.cmake40
-rw-r--r--configure.ac3
-rw-r--r--dbus/dbus-sysdeps-unix.c3
-rw-r--r--dbus/dbus-sysdeps-win.c35
-rw-r--r--test/Makefile.am1
-rw-r--r--test/corrupt.c60
7 files changed, 120 insertions, 41 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index af68cc48..8890604d 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -1,18 +1,5 @@
project(dbus)
-#########################################################################
-# detect version
-#########################################################################
-file (READ ../configure.ac configure_ac)
-string (REGEX REPLACE ".*dbus_major_version], .([0-9]+).*" "\\1" DBUS_MAJOR_VERSION ${configure_ac})
-string (REGEX REPLACE ".*dbus_minor_version], .([0-9]+).*" "\\1" DBUS_MINOR_VERSION ${configure_ac})
-string (REGEX REPLACE ".*dbus_micro_version], .([0-9]+).*" "\\1" DBUS_MICRO_VERSION ${configure_ac})
-# used by file version info
-set (DBUS_PATCH_VERSION "0")
-set (DBUS_VERSION ${DBUS_MAJOR_VERSION}.${DBUS_MINOR_VERSION}.${DBUS_MICRO_VERSION})
-
-set (DBUS_VERSION_STRING "${DBUS_VERSION}")
-
# we need to be up to date
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
if(COMMAND cmake_policy)
@@ -22,6 +9,12 @@ endif(COMMAND cmake_policy)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
+# detect version
+include(MacrosAutotools)
+autoversion(../configure.ac dbus)
+# used by file version info
+set (DBUS_PATCH_VERSION "0")
+
include(Macros)
TIMESTAMP(DBUS_BUILD_TIMESTAMP)
diff --git a/cmake/modules/MacrosAutotools.cmake b/cmake/modules/MacrosAutotools.cmake
new file mode 100644
index 00000000..ff30eaf9
--- /dev/null
+++ b/cmake/modules/MacrosAutotools.cmake
@@ -0,0 +1,40 @@
+#
+# @Author Ralf Habacker
+#
+# extracts version information from autoconf config file
+# and set related cmake variables
+#
+# returns
+# ${prefix}_VERSION
+# ${prefix}_VERSION_STRING
+# ${prefix}_MAJOR_VERSION
+# ${prefix}_MINOR_VERSION
+# ${prefix}_MICRO_VERSION
+#
+macro(autoversion config prefix)
+ file (READ ${config} _configure_ac)
+ string(TOUPPER ${prefix} prefix_upper)
+ string (REGEX REPLACE ".*${prefix}_major_version], .([0-9]+).*" "\\1" ${prefix_upper}_MAJOR_VERSION ${_configure_ac})
+ string (REGEX REPLACE ".*${prefix}_minor_version], .([0-9]+).*" "\\1" ${prefix_upper}_MINOR_VERSION ${_configure_ac})
+ string (REGEX REPLACE ".*${prefix}_micro_version], .([0-9]+).*" "\\1" ${prefix_upper}_MICRO_VERSION ${_configure_ac})
+ set (${prefix_upper}_VERSION ${${prefix_upper}_MAJOR_VERSION}.${${prefix_upper}_MINOR_VERSION}.${${prefix_upper}_MICRO_VERSION})
+ set (${prefix_upper}_VERSION_STRING "${${prefix_upper}_VERSION}")
+
+endmacro()
+
+#
+# parses config.h template and create cmake equivalent
+# not implemented yet
+#
+macro(autoconfig template output)
+ file(READ ${template} contents)
+ # Convert file contents into a CMake list (where each element in the list
+ # is one line of the file)
+ STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
+ STRING(REGEX REPLACE "\n" ";" contents "${contents}")
+ foreach(line contents)
+ message(STATUS ${line})
+ # find #undef lines
+ # append to config.h #define <variable-name> <variable-content>
+ endforeach()
+endmacro()
diff --git a/configure.ac b/configure.ac
index 903a513b..ee3412f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -149,6 +149,7 @@ AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filen
AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (default: /Library/LaunchAgents)]))
AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon]))
+AC_ARG_WITH(dbus_session_bus_default_address, AS_HELP_STRING([--with-dbus-session-bus-default-address=[nonce-tcp:/autolaunch:/tcp:host:port]],[Transport Type to be used (default: nonce-tcp:)]),with_dbus_session_bus_default_address=$withval,with_dbus_session_bus_default_address=nonce-tcp:)
AC_ARG_ENABLE([embedded-tests],
AS_HELP_STRING([--enable-embedded-tests],
@@ -1571,7 +1572,7 @@ AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where p
AC_SUBST(DBUS_SESSION_SOCKET_DIR)
if test x$dbus_win = xyes; then
- DBUS_SESSION_BUS_DEFAULT_ADDRESS="nonce-tcp:"
+ DBUS_SESSION_BUS_DEFAULT_ADDRESS="$with_dbus_session_bus_default_address"
elif test x$have_launchd = xyes; then
DBUS_SESSION_BUS_DEFAULT_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET"
else
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 3067be59..9fc5f57b 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1324,13 +1324,14 @@ _dbus_listen_tcp_socket (const char *host,
hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
redo_lookup_with_port:
+ ai = NULL;
if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai)
{
dbus_set_error (error,
_dbus_error_from_errno (errno),
"Failed to lookup host/port: \"%s:%s\": %s (%d)",
host ? host : "*", port, gai_strerror(res), res);
- return -1;
+ goto failed;
}
tmp = ai;
diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c
index b492b09c..0694de93 100644
--- a/dbus/dbus-sysdeps-win.c
+++ b/dbus/dbus-sysdeps-win.c
@@ -2852,11 +2852,40 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address,
if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
{
- printf ("please add the path to %s to your PATH environment variable\n", daemon_name);
- printf ("or start the daemon manually\n\n");
- goto out;
+ // Look in directory containing dbus shared library
+ HMODULE hmod;
+ char dbus_module_path[MAX_PATH];
+ DWORD rc;
+
+ _dbus_verbose( "did not found dbus daemon executable on default search path, "
+ "trying path where dbus shared library is located");
+
+ hmod = _dbus_win_get_dll_hmodule();
+ rc = GetModuleFileNameA(hmod, dbus_module_path, sizeof(dbus_module_path));
+ if (rc <= 0)
+ {
+ dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not retrieve dbus shared library file name");
+ retval = FALSE;
+ goto out;
+ }
+ else
+ {
+ char *ext_idx = strrchr(dbus_module_path, '\\');
+ if (ext_idx)
+ *ext_idx = '\0';
+ if (!SearchPathA(dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
+ {
+ dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not find dbus-daemon executable");
+ retval = FALSE;
+ printf ("please add the path to %s to your PATH environment variable\n", daemon_name);
+ printf ("or start the daemon manually\n\n");
+ goto out;
+ }
+ _dbus_verbose( "found dbus daemon executable at %s",dbus_module_path);
+ }
}
+
// Create process
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
diff --git a/test/Makefile.am b/test/Makefile.am
index d69e7835..2eca473e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -113,6 +113,7 @@ installable_tests = \
installcheck_tests =
installcheck_environment = \
DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \
+ DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir)
TESTS_ENVIRONMENT = \
diff --git a/test/corrupt.c b/test/corrupt.c
index ef9951af..02495901 100644
--- a/test/corrupt.c
+++ b/test/corrupt.c
@@ -160,6 +160,38 @@ test_message (Fixture *f,
dbus_message_unref (outgoing);
}
+static void
+send_n_bytes (GSocket *socket,
+ const gchar *blob,
+ gssize blob_len)
+{
+ gssize len, total_sent;
+ GError *gerror = NULL;
+
+ total_sent = 0;
+
+ while (total_sent < blob_len)
+ {
+ len = g_socket_send (socket,
+ blob + total_sent,
+ blob_len - total_sent,
+ NULL, &gerror);
+
+ /* this is NULL-safe: a NULL error does not match */
+ if (g_error_matches (gerror, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
+ {
+ /* we could wait for G_IO_OUT, but life's too short; just sleep */
+ g_clear_error (&gerror);
+ g_usleep (G_USEC_PER_SEC / 10);
+ continue;
+ }
+
+ g_assert_no_error (gerror);
+ g_assert (len >= 0);
+ total_sent += len;
+ }
+}
+
/* Enough bytes for it to be obvious that this connection is broken */
#define CORRUPT_LEN 1024
@@ -174,7 +206,6 @@ test_corrupt (Fixture *f,
GSocket *socket;
GError *gerror = NULL;
int fd;
- gssize len, total_sent;
DBusMessage *incoming;
test_message (f, addr);
@@ -191,17 +222,7 @@ test_corrupt (Fixture *f,
g_assert_no_error (gerror);
g_assert (socket != NULL);
- total_sent = 0;
-
- while (total_sent < CORRUPT_LEN)
- {
- len = g_socket_send_with_blocking (socket,
- not_a_dbus_message + total_sent, CORRUPT_LEN - total_sent,
- TRUE, NULL, &gerror);
- g_assert_no_error (gerror);
- g_assert (len >= 0);
- total_sent += len;
- }
+ send_n_bytes (socket, not_a_dbus_message, CORRUPT_LEN);
/* Now spin on the client connection: the server just sent it complete
* rubbish, so it should disconnect */
@@ -225,6 +246,7 @@ test_corrupt (Fixture *f,
"/org/freedesktop/DBus/Local");
dbus_message_unref (incoming);
+ g_object_unref (socket);
}
static void
@@ -237,7 +259,7 @@ test_byte_order (Fixture *f,
char *blob;
const gchar *arg = not_a_dbus_message;
const gchar * const *args = &arg;
- int blob_len, len, total_sent;
+ int blob_len;
DBusMessage *message;
dbus_bool_t mem;
@@ -277,16 +299,7 @@ test_byte_order (Fixture *f,
g_assert_no_error (gerror);
g_assert (socket != NULL);
- total_sent = 0;
-
- while (total_sent < blob_len)
- {
- len = g_socket_send_with_blocking (socket, blob + total_sent,
- blob_len - total_sent, TRUE, NULL, &gerror);
- g_assert_no_error (gerror);
- g_assert (len >= 0);
- total_sent += len;
- }
+ send_n_bytes (socket, blob, blob_len);
dbus_free (blob);
@@ -312,6 +325,7 @@ test_byte_order (Fixture *f,
"/org/freedesktop/DBus/Local");
dbus_message_unref (message);
+ g_object_unref (socket);
}
static void