busy loop ...

Michael Meeks michael@ximian.com
Fri, 05 Mar 2004 17:02:46 +0000

Hi there,

	I saw this during debugging, and came back to it; down to my ignorance
of what a NULL services does (perhaps);

	anyhow - creating a message:

	message = dbus_message_new_method_call
		(NULL, "/org/freedesktop/TestSuite",
		 "/org_freedesktop_TestSuite", "Echo");

	and appending the string "Hello World", followed by:

	reply = dbus_connection_send_with_reply_and_block
		(cnx, message, -1, error);

	[ with the test-service running ]

	Results in a busy loop belting around inside the dbus-connectionc.c
(_dbus_connection_block_for_reply) 'recheck_status' goto loop. Further
investigation shows that this is because the remote end has disconnected
the connection; and so we immediately drop through to
_dbus_transport_do_iteration which immediately returns etc.

Index: dbus/dbus-connection.c
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v
retrieving revision 1.75
diff -u -p -u -r1.75 dbus-connection.c
--- dbus/dbus-connection.c    2 Dec 2003 10:44:21 -0000       1.75
+++ bus/dbus-connection.c    5 Mar 2004 17:05:51 -0000
@@ -1915,7 +1918,9 @@ _dbus_connection_block_for_reply (DBusCo
   _dbus_get_current_time (&tv_sec, &tv_usec);
-  if (tv_sec < start_tv_sec)
+  if (!dbus_connection_get_is_connected (connection))
+    return NULL;
+  else if (tv_sec < start_tv_sec)
     _dbus_verbose ("dbus_connection_send_with_reply_and_block(): clock
set backward\n");
   else if (connection->disconnect_message_link == NULL)
     _dbus_verbose ("dbus_connection_send_with_reply_and_block():

	Seems to fix it nicely; strangely the problem doesn't show with several
other similar invocations though; may I commit ?



 michael@ximian.com  <><, Pseudo Engineer, itinerant idiot