From: Thiago Macieira Date: Thu, 16 Jul 2009 14:05:16 +0000 (+0200) Subject: Merge branch 'fd-passing' X-Git-Tag: dbus-1.3.0~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37019e9d271390fa8c62c1aae62d30bb9068adaa;p=thirdparty%2Fdbus.git Merge branch 'fd-passing' Conflicts: dbus/dbus-connection.c dbus/dbus-message-util.c dbus/dbus-sysdeps-unix.c --- 37019e9d271390fa8c62c1aae62d30bb9068adaa diff --cc configure.in index 33faec9f2,2a0e64e26..c011b4a7c --- a/configure.in +++ b/configure.in @@@ -349,44 -590,26 +350,26 @@@ if test "x$dbus_cv_va_val_copy" = "xno" fi - #### Atomic integers (checks by Sebastian Wilhelmi for GLib) - AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers]) - have_atomic_inc_cond=0 - if test x"$GCC" = xyes; then - if test "x$enable_ansi" = "xyes"; then - AC_MSG_RESULT([no]) - else - case $host_cpu in - i386) - AC_MSG_RESULT([no]) - ;; - i?86) - case $host_os in - darwin*) - AC_MSG_RESULT([darwin]) - # check at compile-time, so that it is possible to build universal - # (with multiple architectures at once on the compile line) - have_atomic_inc_cond="(defined(__i386__) || defined(__x86_64__))" - ;; - *) - AC_MSG_RESULT([i486]) - have_atomic_inc_cond=1 - ;; - esac - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac - fi + #### Atomic integers + + AC_CACHE_CHECK([whether $CC knows __sync_sub_and_fetch()], + dbus_cv_sync_sub_and_fetch, + [AC_LINK_IFELSE( + AC_LANG_PROGRAM([], [[int a = 4; int b = __sync_sub_and_fetch(&a, 4);]]), + [dbus_cv_sync_sub_and_fetch=yes], + [dbus_cv_sync_sub_and_fetch=no]) + ]) + + if test "x$dbus_cv_sync_sub_and_fetch" = "xyes" ; then + have_sync=1 + else + have_sync=0 fi - AC_DEFINE_UNQUOTED([DBUS_USE_ATOMIC_INT_486_COND], [$have_atomic_inc_cond], - [Always defined; expands to 1 if we should use atomic integer implementation for 486, else 0]) - AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT_COND, [$have_atomic_inc_cond], - [Always defined; expands to 1 if we have an atomic integer implementation, else 0]) + + AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension]) #### Various functions -AC_CHECK_LIB(socket,socket) +AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll) @@@ -456,15 -679,10 +439,17 @@@ AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_ AC_CHECK_HEADERS(errno.h) + AC_CHECK_HEADERS(byteswap.h) + AC_CHECK_HEADERS(unistd.h) +# Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris +# +case $host_os in + solaris*) + CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" ;; +esac + # checking for a posix version of getpwnam_r # if we are cross compiling and can not run the test # assume getpwnam_r is the posix version diff --cc dbus/dbus-connection.c index c933d7d14,e46fbc3d2..a59b1a0cb --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@@ -3194,16 -3231,22 +3273,20 @@@ reply_handler_timeout (void *data * * If -1 is passed for the timeout, a sane default timeout is used. -1 * is typically the best value for the timeout for this reason, unless - * you want a very short or very long timeout. There is no way to - * avoid a timeout entirely, other than passing INT_MAX for the - * timeout to mean "very long timeout." libdbus clamps an INT_MAX - * timeout down to a few hours timeout though. + * you want a very short or very long timeout. If INT_MAX is passed for + * the timeout, no timeout will be set and the call will block forever. * - * @warning if the connection is disconnected, the #DBusPendingCall - * will be set to #NULL, so be careful with this. - * + * @warning if the connection is disconnected or you try to send Unix + * file descriptors on a connection that does not support them, the + * #DBusPendingCall will be set to #NULL, so be careful with this. + * * @param connection the connection * @param message the message to send - * @param pending_return return location for a #DBusPendingCall object, or #NULL if connection is disconnected + * @param pending_return return location for a #DBusPendingCall + * object, or #NULL if connection is disconnected or when you try to + * send Unix file descriptors on a connection that does not support + * them. - * @param timeout_milliseconds timeout in milliseconds or -1 for default + * @param timeout_milliseconds timeout in milliseconds, -1 for default or INT_MAX for no timeout * @returns #FALSE if no memory, #TRUE otherwise. * */ diff --cc dbus/dbus-message-util.c index 84471a501,1b1394360..a56fcc494 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@@ -939,7 -994,9 +994,10 @@@ _dbus_message_test (const char *test_da unsigned char v_BYTE; unsigned char v2_BYTE; dbus_bool_t v_BOOLEAN; + DBusMessageIter iter, array_iter, struct_iter; + #ifdef HAVE_UNIX_FD_PASSING + int v_UNIX_FD; + #endif message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService", "/org/freedesktop/TestPath", @@@ -1272,35 -1363,8 +1364,36 @@@ _dbus_message_loader_unref (loader); check_memleaks (); + _dbus_check_fdleaks(); + /* Check that we can abandon a container */ + message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService", + "/org/freedesktop/TestPath", + "Foo.TestInterface", + "Method"); + + dbus_message_iter_init_append (message, &iter); + + _dbus_assert (dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, + (DBUS_STRUCT_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_STRUCT_END_CHAR_AS_STRING), + &array_iter)); + _dbus_assert (dbus_message_iter_open_container (&array_iter, DBUS_TYPE_STRUCT, + NULL, &struct_iter)); + + s = "peaches"; + _dbus_assert (dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING, + &s)); + + /* uh-oh, error, try and unwind */ + + dbus_message_iter_abandon_container (&array_iter, &struct_iter); + dbus_message_iter_abandon_container (&array_iter, &iter); + + dbus_message_unref (message); + /* Load all the sample messages from the message factory */ { DBusMessageDataIter diter; diff --cc dbus/dbus-spawn.c index c08f92784,fa2e15c14..c3c2fb991 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@@ -18,9 -18,12 +18,12 @@@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ + + #include + #include "dbus-spawn.h" #include "dbus-sysdeps-unix.h" #include "dbus-internals.h" diff --cc dbus/dbus-sysdeps-unix.c index 2ae7909ec,42aa96742..f0f1e7067 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@@ -1060,10 -1386,10 +1386,10 @@@ write_credentials_byte (in msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = &cmsg; - msg.msg_controllen = sizeof (cmsg); + msg.msg_control = (caddr_t) &cmsg; + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); - memset (&cmsg, 0, sizeof (cmsg)); + _DBUS_ZERO(cmsg); - cmsg.hdr.cmsg_len = sizeof (cmsg); + cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred)); cmsg.hdr.cmsg_level = SOL_SOCKET; cmsg.hdr.cmsg_type = SCM_CREDS; #endif @@@ -1177,9 -1503,9 +1503,9 @@@ _dbus_read_credentials_socket (in msg.msg_iovlen = 1; #if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS) - memset (&cmsg, 0, sizeof (cmsg)); + _DBUS_ZERO(cmsg); - msg.msg_control = &cmsg; - msg.msg_controllen = sizeof (cmsg); + msg.msg_control = (caddr_t) &cmsg; + msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); #endif again: