Merge branch 'fd-passing'
authorThiago Macieira <thiago@kde.org>
Thu, 16 Jul 2009 14:05:16 +0000 (16:05 +0200)
committerThiago Macieira <thiago@kde.org>
Thu, 16 Jul 2009 14:05:16 +0000 (16:05 +0200)
Conflicts:
dbus/dbus-connection.c
dbus/dbus-message-util.c
dbus/dbus-sysdeps-unix.c

51 files changed:
1  2 
bus/bus.c
bus/bus.h
bus/config-parser.c
bus/desktop-file.c
bus/dir-watch-inotify.c
bus/dispatch.c
bus/main.c
bus/session.conf.in
bus/test-main.c
bus/test.h
configure.in
dbus/dbus-auth.c
dbus/dbus-auth.h
dbus/dbus-connection.c
dbus/dbus-connection.h
dbus/dbus-internals.h
dbus/dbus-marshal-basic.c
dbus/dbus-marshal-basic.h
dbus/dbus-marshal-byteswap.c
dbus/dbus-marshal-byteswap.h
dbus/dbus-marshal-header.c
dbus/dbus-marshal-header.h
dbus/dbus-marshal-recursive.h
dbus/dbus-marshal-validate.c
dbus/dbus-marshal-validate.h
dbus/dbus-memory.h
dbus/dbus-message-factory.c
dbus/dbus-message-internal.h
dbus/dbus-message-private.h
dbus/dbus-message-util.c
dbus/dbus-message.c
dbus/dbus-message.h
dbus/dbus-protocol.h
dbus/dbus-resources.c
dbus/dbus-resources.h
dbus/dbus-server-debug-pipe.c
dbus/dbus-server-socket.c
dbus/dbus-server-unix.c
dbus/dbus-sha.c
dbus/dbus-signature.c
dbus/dbus-spawn.c
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-unix.h
dbus/dbus-sysdeps-win.c
dbus/dbus-sysdeps.h
dbus/dbus-threads.c
dbus/dbus-transport-protected.h
dbus/dbus-transport-socket.c
dbus/dbus-transport-unix.c
dbus/dbus-transport.c
dbus/dbus-transport.h

diff --cc bus/bus.c
Simple merge
diff --cc bus/bus.h
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc bus/dispatch.c
Simple merge
diff --cc bus/main.c
Simple merge
Simple merge
diff --cc bus/test-main.c
Simple merge
diff --cc bus/test.h
Simple merge
diff --cc 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
Simple merge
Simple merge
@@@ -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.
   *
   */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -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",
    _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;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc dbus/dbus-sha.c
Simple merge
Simple merge
   * 
   * 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 <config.h>
  #include "dbus-spawn.h"
  #include "dbus-sysdeps-unix.h"
  #include "dbus-internals.h"
@@@ -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:
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge