]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2003-10-26 Havoc Pennington <hp@redhat.com>
authorHavoc Pennington <hp@redhat.com>
Sun, 26 Oct 2003 15:36:15 +0000 (15:36 +0000)
committerHavoc Pennington <hp@redhat.com>
Sun, 26 Oct 2003 15:36:15 +0000 (15:36 +0000)
* dbus/dbus-connection.c: fix docs to properly describe the
disconnected message
(_dbus_connection_notify_disconnected): remove this function;
we can't synchronously add the disconnected message, we have to
do it after we've queued any remaining real messages
(_dbus_connection_get_dispatch_status_unlocked): queue the
disconnect message only if the transport has finished queueing all
its real messages and is disconnected.
(dbus_connection_disconnect): update the dispatch status here

ChangeLog
dbus/dbus-connection-internal.h
dbus/dbus-connection.c
dbus/dbus-transport.c

index 782a3f5c35d39d3b42c67506e28a321aa7edbe79..71c5a4d61d436a4560518477d4f2ad9da8a37cb4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2003-10-26  Havoc Pennington  <hp@redhat.com>
+
+       * dbus/dbus-connection.c: fix docs to properly describe the
+       disconnected message
+       (_dbus_connection_notify_disconnected): remove this function; 
+       we can't synchronously add the disconnected message, we have to 
+       do it after we've queued any remaining real messages
+       (_dbus_connection_get_dispatch_status_unlocked): queue the
+       disconnect message only if the transport has finished queueing all
+       its real messages and is disconnected.
+       (dbus_connection_disconnect): update the dispatch status here
+
 2003-10-22  Havoc Pennington  <hp@redhat.com>
 
        * bus/bus.c (bus_context_check_security_policy): fix up assertion
index b19ab63641938ab66fb2e5dbf489f2178e25b43c..e53908b5296e661dd4c483519d5b5c54ddecb3ec 100644 (file)
@@ -77,7 +77,6 @@ DBusConnection*   _dbus_connection_new_for_transport           (DBusTransport
 void              _dbus_connection_do_iteration                (DBusConnection     *connection,
                                                                 unsigned int        flags,
                                                                 int                 timeout_milliseconds);
-void              _dbus_connection_notify_disconnected         (DBusConnection     *connection);
 
 DBusPendingCall*  _dbus_pending_call_new                       (DBusConnection     *connection,
                                                                 int                 timeout_milliseconds,
index 61de8b1f9e7cc9fb86513690ec6355ea3c35099c..7871f922db89217f0c39a67e12f1a29c65462586 100644 (file)
  * handle the details here for you by setting up watch functions.
  *
  * When a connection is disconnected, you are guaranteed to get a
- * message with the name #DBUS_MESSAGE_LOCAL_DISCONNECT.
+ * signal "Disconnected" from the interface
+ * #DBUS_INTERFACE_ORG_FREEDESKTOP_LOCAL, path
+ * #DBUS_PATH_ORG_FREEDESKTOP_LOCAL.
  *
  * You may not drop the last reference to a #DBusConnection
  * until that connection has been disconnected.
  *
  * You may dispatch the unprocessed incoming message queue even if the
- * connection is disconnected. However, #DBUS_MESSAGE_LOCAL_DISCONNECT
- * will always be the last message in the queue (obviously no messages
- * are received after disconnection).
+ * connection is disconnected. However, "Disconnected" will always be
+ * the last message in the queue (obviously no messages are received
+ * after disconnection).
  *
  * #DBusConnection has thread locks and drops them when invoking user
  * callbacks, so in general is transparently threadsafe. However,
@@ -577,25 +579,6 @@ _dbus_connection_toggle_timeout (DBusConnection *connection,
                                        timeout, enabled);
 }
 
-/**
- * Tells the connection that the transport has been disconnected.
- * Results in posting a disconnect message on the incoming message
- * queue.  Only has an effect the first time it's called.
- *
- * @param connection the connection
- */
-void
-_dbus_connection_notify_disconnected (DBusConnection *connection)
-{
-  if (connection->disconnect_message_link)
-    {
-      /* We haven't sent the disconnect message already */
-      _dbus_connection_queue_synthesized_message_link (connection,
-                                                      connection->disconnect_message_link);
-      connection->disconnect_message_link = NULL;
-    }
-}
-
 static dbus_bool_t
 _dbus_connection_attach_pending_call_unlocked (DBusConnection  *connection,
                                                DBusPendingCall *pending)
@@ -1305,18 +1288,27 @@ dbus_connection_unref (DBusConnection *connection)
  * function does not affect the connection's reference count.  It's
  * safe to disconnect a connection more than once; all calls after the
  * first do nothing. It's impossible to "reconnect" a connection, a
- * new connection must be created.
+ * new connection must be created. This function may result in a call
+ * to the DBusDispatchStatusFunction set with
+ * dbus_connection_set_dispatch_status_function(), as the disconnect
+ * message it generates needs to be dispatched.
  *
  * @param connection the connection.
  */
 void
 dbus_connection_disconnect (DBusConnection *connection)
 {
+  DBusDispatchStatus status;
+  
   _dbus_return_if_fail (connection != NULL);
   
   CONNECTION_LOCK (connection);
   _dbus_transport_disconnect (connection->transport);
-  CONNECTION_UNLOCK (connection);
+  
+  status = _dbus_connection_get_dispatch_status_unlocked (connection);
+
+  /* this calls out to user code */
+  _dbus_connection_update_dispatch_status_and_unlock (connection, status);
 }
 
 static dbus_bool_t
@@ -2351,6 +2343,18 @@ _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection)
       
       status = _dbus_transport_get_dispatch_status (connection->transport);
 
+      if (status == DBUS_DISPATCH_COMPLETE &&
+          connection->disconnect_message_link &&
+          !_dbus_transport_get_is_connected (connection->transport))
+        {
+          /* We haven't sent the disconnect message already,
+           * and all real messages have been queued up.
+           */
+          _dbus_connection_queue_synthesized_message_link (connection,
+                                                           connection->disconnect_message_link);
+          connection->disconnect_message_link = NULL;
+        }
+      
       if (status != DBUS_DISPATCH_COMPLETE)
         return status;
       else if (connection->n_incoming > 0)
index 4625cf252c86c3e8ce89679dd8fb697162f7c0b0..b58073f688233e411d5e0859251e56eb163ba6d8 100644 (file)
@@ -415,9 +415,6 @@ _dbus_transport_disconnect (DBusTransport *transport)
   (* transport->vtable->disconnect) (transport);
   
   transport->disconnected = TRUE;
-
-  if (transport->connection)
-    _dbus_connection_notify_disconnected (transport->connection);
 }
 
 /**