]> git.pld-linux.org Git - packages/dbus.git/commitdiff
- correctly handle Hello messages after the first one
authorMarcin Krzyżanowski <marcin.krzyzanowski@hakore.com>
Wed, 27 Oct 2004 10:29:43 +0000 (10:29 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    dbus-hello.patch -> 1.1

dbus-hello.patch [new file with mode: 0644]

diff --git a/dbus-hello.patch b/dbus-hello.patch
new file mode 100644 (file)
index 0000000..4909b3d
--- /dev/null
@@ -0,0 +1,203 @@
+diff -u -r1.52 -r1.55
+--- bus/driver.c       10 Aug 2004 03:06:59 -0000      1.52
++++ bus/driver.c       17 Sep 2004 09:14:49 -0000      1.55
+@@ -278,6 +278,14 @@
+   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
++  if (bus_connection_is_active (connection))
++    {
++      /* We already handled an Hello message for this connection. */
++      dbus_set_error (error, DBUS_ERROR_FAILED,
++                      "Already handled an Hello message");
++      return FALSE;
++    }
++
+   /* Note that when these limits are exceeded we don't disconnect the
+    * connection; we just sort of leave it hanging there until it times
+    * out or disconnects itself or is dropped due to the max number of
+@@ -447,7 +455,7 @@
+   DBusString service_name;
+   char *name;
+   int service_reply;
+-  int flags;
++  dbus_uint32_t flags;
+   dbus_bool_t retval;
+   BusRegistry *registry;
+@@ -511,6 +519,7 @@
+   DBusMessage *reply;
+   DBusString service_name;
+   BusService *service;
++  dbus_bool_t service_exists;
+   char *name;
+   dbus_bool_t retval;
+   BusRegistry *registry;
+@@ -525,10 +534,18 @@
+     return FALSE;
+   retval = FALSE;
++
++  if (strcmp (name, DBUS_SERVICE_ORG_FREEDESKTOP_DBUS) == 0)
++    {
++      service_exists = TRUE;
++    }
++  else
++    {
++      _dbus_string_init_const (&service_name, name);
++      service = bus_registry_lookup (registry, &service_name);
++      service_exists = service != NULL;
++    }
+   
+-  _dbus_string_init_const (&service_name, name);
+-  service = bus_registry_lookup (registry, &service_name);
+- 
+   reply = dbus_message_new_method_return (message);
+   if (reply == NULL)
+     {
+@@ -537,7 +554,7 @@
+     }
+   if (!dbus_message_append_args (reply,
+-                                 DBUS_TYPE_BOOLEAN, service != NULL,
++                                 DBUS_TYPE_BOOLEAN, service_exists,
+                                  0))
+     {
+       BUS_SET_OOM (error);
+@@ -842,7 +859,6 @@
+   DBusConnection *conn;
+   DBusMessage *reply;
+   unsigned long uid;
+-  const char *base_name;
+   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+@@ -919,7 +935,6 @@
+   DBusConnection *conn;
+   DBusMessage *reply;
+   unsigned long pid;
+-  const char *base_name;
+   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+diff -u -r1.61 -r1.62
+--- bus/dispatch.c     10 Aug 2004 03:06:59 -0000      1.61
++++ bus/dispatch.c     17 Sep 2004 09:14:49 -0000      1.62
+@@ -934,6 +934,96 @@
+  * but the correct thing may include OOM errors.
+  */
+ static dbus_bool_t
++check_double_hello_message (BusContext     *context,
++                            DBusConnection *connection)
++{
++  DBusMessage *message;
++  dbus_uint32_t serial;
++  dbus_bool_t retval;
++  DBusError error;
++
++  retval = FALSE;
++  dbus_error_init (&error);
++  message = NULL;
++
++  _dbus_verbose ("check_double_hello_message for %p\n", connection);
++  
++  message = dbus_message_new_method_call (DBUS_SERVICE_ORG_FREEDESKTOP_DBUS,
++                                          DBUS_PATH_ORG_FREEDESKTOP_DBUS,
++                                          DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
++                                          "Hello");
++
++  if (message == NULL)
++    return TRUE;
++
++  if (!dbus_connection_send (connection, message, &serial))
++    {
++      dbus_message_unref (message);
++      return TRUE;
++    }
++
++  dbus_message_unref (message);
++  message = NULL;
++
++  /* send our message */
++  bus_test_run_clients_loop (TRUE);
++
++  dbus_connection_ref (connection); /* because we may get disconnected */
++  block_connection_until_message_from_bus (context, connection);
++
++  if (!dbus_connection_get_is_connected (connection))
++    {
++      _dbus_verbose ("connection was disconnected\n");
++      
++      dbus_connection_unref (connection);
++      
++      return TRUE;
++    }
++
++  dbus_connection_unref (connection);
++  
++  message = pop_message_waiting_for_memory (connection);
++  if (message == NULL)
++    {
++      _dbus_warn ("Did not receive a reply to %s %d on %p\n",
++                  "Hello", serial, connection);
++      goto out;
++    }
++
++  verbose_message_received (connection, message);
++
++  if (!dbus_message_has_sender (message, DBUS_SERVICE_ORG_FREEDESKTOP_DBUS))
++    {
++      _dbus_warn ("Message has wrong sender %s\n",
++                  dbus_message_get_sender (message) ?
++                  dbus_message_get_sender (message) : "(none)");
++      goto out;
++    }
++  
++  if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR)
++    {
++      warn_unexpected (connection, message, "method return for Hello");
++      goto out;
++    }
++
++  if (!check_no_leftovers (context))
++    goto out;
++  
++  retval = TRUE;
++  
++ out:
++  dbus_error_free (&error);
++  
++  if (message)
++    dbus_message_unref (message);
++  
++  return retval;
++}
++
++/* returns TRUE if the correct thing happens,
++ * but the correct thing may include OOM errors.
++ */
++static dbus_bool_t
+ check_get_connection_unix_user (BusContext     *context,
+                                 DBusConnection *connection)
+ {
+@@ -2243,7 +2333,9 @@
+           ; /* good, this is a valid response */
+         }
+       else if (dbus_message_is_error (message,
+-                                      DBUS_ERROR_SPAWN_CHILD_EXITED))
++                                      DBUS_ERROR_SPAWN_CHILD_EXITED) ||
++               dbus_message_is_error (message,
++                                      DBUS_ERROR_SPAWN_EXEC_FAILED))
+         {
+           ; /* good, this is expected also */
+         }
+@@ -2917,6 +3009,9 @@
+   if (!check_hello_message (context, foo))
+     _dbus_assert_not_reached ("hello message failed");
++  if (!check_double_hello_message (context, foo))
++    _dbus_assert_not_reached ("double hello message failed");
++
+   if (!check_add_match_all (context, foo))
+     _dbus_assert_not_reached ("AddMatch message failed");
+   
This page took 0.176875 seconds and 4 git commands to generate.