dbus/dbus dbus-connection.c,1.87,1.87.2.1

Joe Shaw joe at freedesktop.org
Thu Feb 10 15:22:13 PST 2005


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv20453/dbus

Modified Files:
      Tag: dbus-0-23
	dbus-connection.c 
Log Message:
2005-02-10  Joe Shaw  <joeshaw at novell.com>

	* dbus/dbus-connection.c
	(_dbus_connection_queue_received_message_link,
	_dbus_connection_message_sent): Add the path to
	the verbose output.
	(_dbus_connection_send_preallocated_and_unlock): Added.  Calls
	_dbus_connection_send_preallocated_unlocked(), updated the
	dispatch status, and unlocks.  Fixes a bug where certain
	situations (like a broken pipe) could cause a Disconnect message
	to not be sent, tricking the bus into thinking a service was still
	there when the process had quit.
	(_dbus_connection_send_preallocated): Call
	_dbus_connection_send_preallocated_and_unlock().
	(_dbus_connection_send_and_unlock): Added.  Calls
	_dbus_connection_send_preallocated_and_unlock().
	(dbus_connection_send): Call _dbus_connection_send_and_unlock().
	(dbus_connection_send_with_reply): Update the dispatch status and
	unlock.

	* mono/Service.cs (~Service): Added.  Removes the filter so that
	we don't get unmanaged code calling back into a GCed delegate.
	(RemoveFilter); Added.

Index: dbus-connection.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v
retrieving revision 1.87
retrieving revision 1.87.2.1
diff -u -d -r1.87 -r1.87.2.1
--- dbus-connection.c	11 Jan 2005 19:31:56 -0000	1.87
+++ dbus-connection.c	10 Feb 2005 23:22:11 -0000	1.87.2.1
@@ -358,9 +358,10 @@
 
   _dbus_connection_wakeup_mainloop (connection);
   
-  _dbus_verbose ("Message %p (%d %s %s '%s') added to incoming queue %p, %d incoming\n",
+  _dbus_verbose ("Message %p (%d %s %s %s '%s') added to incoming queue %p, %d incoming\n",
                  message,
                  dbus_message_get_type (message),
+		 dbus_message_get_path (message),
                  dbus_message_get_interface (message) ?
                  dbus_message_get_interface (message) :
                  "no interface",
@@ -473,9 +474,10 @@
   
   connection->n_outgoing -= 1;
 
-  _dbus_verbose ("Message %p (%d %s %s '%s') removed from outgoing queue %p, %d left to send\n",
+  _dbus_verbose ("Message %p (%d %s %s %s '%s') removed from outgoing queue %p, %d left to send\n",
                  message,
                  dbus_message_get_type (message),
+		 dbus_message_get_path (message),
                  dbus_message_get_interface (message) ?
                  dbus_message_get_interface (message) :
                  "no interface",
@@ -1572,9 +1574,10 @@
   }
 #endif
   
-  _dbus_verbose ("Message %p (%d %s %s '%s') added to outgoing queue %p, %d pending to send\n",
+  _dbus_verbose ("Message %p (%d %s %s %s '%s') added to outgoing queue %p, %d pending to send\n",
                  message,
                  dbus_message_get_type (message),
+		 dbus_message_get_path (message),
                  dbus_message_get_interface (message) ?
                  dbus_message_get_interface (message) :
                  "no interface",
@@ -1606,12 +1609,30 @@
   _dbus_connection_do_iteration (connection,
                                  DBUS_ITERATION_DO_WRITING,
                                  -1);
-  
+
   /* If stuff is still queued up, be sure we wake up the main loop */
   if (connection->n_outgoing > 0)
     _dbus_connection_wakeup_mainloop (connection);
 }
 
+static void
+_dbus_connection_send_preallocated_and_unlock (DBusConnection       *connection,
+					       DBusPreallocatedSend *preallocated,
+					       DBusMessage          *message,
+					       dbus_uint32_t        *client_serial)
+{
+  DBusDispatchStatus status;
+
+  _dbus_connection_send_preallocated_unlocked (connection,
+                                               preallocated,
+                                               message, client_serial);
+
+  status = _dbus_connection_get_dispatch_status_unlocked (connection);
+
+  /* this calls out to user code */
+  _dbus_connection_update_dispatch_status_and_unlock (connection, status);
+}
+
 /**
  * Sends a message using preallocated resources. This function cannot fail.
  * It works identically to dbus_connection_send() in other respects.
@@ -1642,10 +1663,9 @@
                          dbus_message_get_member (message) != NULL));
   
   CONNECTION_LOCK (connection);
-  _dbus_connection_send_preallocated_unlocked (connection,
-                                               preallocated,
-                                               message, client_serial);
-  CONNECTION_UNLOCK (connection);  
+  _dbus_connection_send_preallocated_and_unlock (connection,
+						 preallocated,
+						 message, client_serial);
 }
 
 static dbus_bool_t
@@ -1670,6 +1690,27 @@
   return TRUE;
 }
 
+static dbus_bool_t
+_dbus_connection_send_and_unlock (DBusConnection *connection,
+				  DBusMessage    *message,
+				  dbus_uint32_t  *client_serial)
+{
+  DBusPreallocatedSend *preallocated;
+
+  _dbus_assert (connection != NULL);
+  _dbus_assert (message != NULL);
+  
+  preallocated = _dbus_connection_preallocate_send_unlocked (connection);
+  if (preallocated == NULL)
+    return FALSE;
+
+  _dbus_connection_send_preallocated_and_unlock (connection,
+						 preallocated,
+						 message,
+						 client_serial);
+  return TRUE;
+}
+
 /**
  * Adds a message to the outgoing message queue. Does not block to
  * write the message to the network; that happens asynchronously. To
@@ -1698,14 +1739,9 @@
 
   CONNECTION_LOCK (connection);
 
-  if (!_dbus_connection_send_unlocked (connection, message, client_serial))
-    {
-      CONNECTION_UNLOCK (connection);
-      return FALSE;
-    }
-
-  CONNECTION_UNLOCK (connection);
-  return TRUE;
+  return _dbus_connection_send_and_unlock (connection,
+					   message,
+					   client_serial);
 }
 
 static dbus_bool_t
@@ -1784,6 +1820,7 @@
   DBusMessage *reply;
   DBusList *reply_link;
   dbus_int32_t serial = -1;
+  DBusDispatchStatus status;
 
   _dbus_return_val_if_fail (connection != NULL, FALSE);
   _dbus_return_val_if_fail (message != NULL, FALSE);
@@ -1845,8 +1882,11 @@
   else
     dbus_pending_call_unref (pending);
 
-  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);
+
   return TRUE;
 
  error:
@@ -2256,9 +2296,10 @@
       link = _dbus_list_pop_first_link (&connection->incoming_messages);
       connection->n_incoming -= 1;
 
-      _dbus_verbose ("Message %p (%d %s %s '%s') removed from incoming queue %p, %d incoming\n",
+      _dbus_verbose ("Message %p (%d %s %s %s '%s') removed from incoming queue %p, %d incoming\n",
                      link->data,
                      dbus_message_get_type (link->data),
+		     dbus_message_get_path (link->data), 
                      dbus_message_get_interface (link->data) ?
                      dbus_message_get_interface (link->data) :
                      "no interface",



More information about the dbus-commit mailing list