summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-04-09 20:31:21 +0000
committerHavoc Pennington <hp@redhat.com>2003-04-09 20:31:21 +0000
commit1708094c0e00ab433bb0a51981f8b77d24aee256 (patch)
treee30c5ca0f6011bb3f1a083b8a9b49ee778da0cbd
parent0e1945b3889f8be8e31e39ad2b982c8a192be41d (diff)
2003-04-09 Havoc Pennington <hp@redhat.com>
* dbus/dbus-bus.c (dbus_bus_register): fix up error handling and a memory leak * bus/dispatch.c (check_service_activated): fix bug in test * dbus/dbus-mainloop.c (check_timeout): fix this up * dbus/dbus-internals.c (_dbus_verbose_real): include PID in verbose output so we can sort out output from different processes, e.g. in the activation case.
-rw-r--r--ChangeLog13
-rw-r--r--bus/dispatch.c18
-rw-r--r--bus/driver.c2
-rw-r--r--dbus/dbus-bus.c35
-rw-r--r--dbus/dbus-connection.c16
-rw-r--r--dbus/dbus-internals.c6
-rw-r--r--test/test-service.c2
-rw-r--r--test/test-utils.c6
8 files changed, 75 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index d5624a29..b520f1fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2003-04-09 Havoc Pennington <hp@redhat.com>
+
+ * dbus/dbus-bus.c (dbus_bus_register): fix up error handling and
+ a memory leak
+
+ * bus/dispatch.c (check_service_activated): fix bug in test
+
+ * dbus/dbus-mainloop.c (check_timeout): fix this up
+
+ * dbus/dbus-internals.c (_dbus_verbose_real): include PID in
+ verbose output so we can sort out output from different processes,
+ e.g. in the activation case.
+
2003-04-08 Colin Walters <walters@gnu.org>
* bus/bus.c (struct BusContext) [pidfile]: New member, to store
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 4761a4bd..0b9f9731 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -1111,9 +1111,10 @@ check_service_activated (BusContext *context,
goto recheck_service_created;
}
- else if (require_base_service)
+ else if (require_base_service && !already_saw_base_created)
{
- _dbus_warn ("Did not get a ServiceCreated for a base service\n");
+ _dbus_warn ("Did not get a ServiceCreated for a base service, it was for %s instead\n",
+ service_name);
goto out;
}
@@ -1228,7 +1229,7 @@ check_service_deactivated (BusContext *context,
/* Now we are expecting ServiceDeleted messages for the base
* service and the activated_name. The base service
- * notification is required to come second.
+ * notification is required to come last.
*/
csdd.expected_service_name = activated_name;
csdd.failed = FALSE;
@@ -1251,6 +1252,8 @@ check_service_deactivated (BusContext *context,
_dbus_warn ("Messages were left over after verifying results of service exiting\n");
goto out;
}
+
+ retval = TRUE;
out:
if (message)
@@ -1351,6 +1354,13 @@ check_existent_service_activation (BusContext *context,
{
; /* good, this is expected also */
}
+ else if (dbus_message_name_is (message,
+ DBUS_ERROR_SPAWN_CHILD_EXITED))
+ {
+ ; /* good, this is expected also (child will exit if for example we don't
+ * have memory to register it)
+ */
+ }
else
{
_dbus_warn ("Did not expect error %s\n",
@@ -1401,7 +1411,7 @@ check_existent_service_activation (BusContext *context,
/* and process everything again */
bus_test_run_everything (context);
-
+
if (!check_service_deactivated (context, connection,
EXISTENT_SERVICE_NAME, base_service))
goto out;
diff --git a/bus/driver.c b/bus/driver.c
index 31b848e9..a3fe7c59 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -467,6 +467,8 @@ bus_driver_handle_acquire_service (DBusConnection *connection,
dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
"Cannot acquire a service starting with ':' such as \"%s\"",
name);
+
+ _dbus_verbose ("Attempt to acquire invalid base service name \"%s\"", name);
goto out;
}
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c
index 74703866..e7b4c06e 100644
--- a/dbus/dbus-bus.c
+++ b/dbus/dbus-bus.c
@@ -428,8 +428,11 @@ dbus_bus_register (DBusConnection *connection,
DBusMessage *message, *reply;
char *name;
BusData *bd;
-
+ dbus_bool_t retval;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ retval = FALSE;
bd = ensure_bus_data (connection);
if (bd == NULL)
@@ -461,22 +464,26 @@ dbus_bus_register (DBusConnection *connection,
dbus_message_unref (message);
if (reply == NULL)
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- return FALSE;
- }
+ goto out;
+ else if (dbus_set_error_from_message (error, reply))
+ goto out;
+ else if (!dbus_message_get_args (reply, error,
+ DBUS_TYPE_STRING, &name,
+ 0))
+ goto out;
+
+ bd->base_service = name;
- if (!dbus_message_get_args (reply, error,
- DBUS_TYPE_STRING, &name,
- 0))
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- return FALSE;
- }
+ retval = TRUE;
+
+ out:
+ if (reply)
+ dbus_message_unref (reply);
- bd->base_service = name;
+ if (!retval)
+ _DBUS_ASSERT_ERROR_IS_SET (error);
- return TRUE;
+ return retval;
}
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index d92268ba..60c075fe 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -1461,8 +1461,9 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection,
end_tv_sec += end_tv_usec / _DBUS_USEC_PER_SECOND;
end_tv_usec = end_tv_usec % _DBUS_USEC_PER_SECOND;
- _dbus_verbose ("will block %d milliseconds from %ld sec %ld usec to %ld sec %ld usec\n",
+ _dbus_verbose ("dbus_connection_send_with_reply_and_block(): will block %d milliseconds for reply serial %d from %ld sec %ld usec to %ld sec %ld usec\n",
timeout_milliseconds,
+ client_serial,
start_tv_sec, start_tv_usec,
end_tv_sec, end_tv_usec);
@@ -1489,6 +1490,10 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection,
if (reply != NULL)
{
dbus_mutex_unlock (connection->mutex);
+
+ _dbus_verbose ("dbus_connection_send_with_reply_and_block(): got reply %s\n",
+ dbus_message_get_name (reply));
+
return reply;
}
}
@@ -1504,7 +1509,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection,
{
timeout_milliseconds = (end_tv_sec - tv_sec) * 1000 +
(end_tv_usec - tv_usec) / 1000;
- _dbus_verbose ("%d milliseconds remain\n", timeout_milliseconds);
+ _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds);
_dbus_assert (timeout_milliseconds >= 0);
if (status == DBUS_DISPATCH_NEED_MEMORY)
@@ -1513,6 +1518,8 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection,
* we may already have a reply in the buffer and just can't process
* it.
*/
+ _dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n");
+
if (timeout_milliseconds < 100)
; /* just busy loop */
else if (timeout_milliseconds <= 1000)
@@ -1531,12 +1538,15 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection,
goto recheck_status;
}
+
+ _dbus_verbose ("dbus_connection_send_with_reply_and_block(): Waited %ld milliseconds and got no reply\n",
+ (tv_sec - start_tv_sec) * 1000 + (tv_usec - start_tv_usec) / 1000);
if (dbus_connection_get_is_connected (connection))
dbus_set_error (error, DBUS_ERROR_NO_REPLY, "Message did not receive a reply");
else
dbus_set_error (error, DBUS_ERROR_DISCONNECTED, "Disconnected prior to receiving a reply");
-
+
dbus_mutex_unlock (connection->mutex);
return NULL;
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c
index de98c1fc..6a662e5d 100644
--- a/dbus/dbus-internals.c
+++ b/dbus/dbus-internals.c
@@ -189,7 +189,8 @@ _dbus_verbose_real (const char *format,
va_list args;
static dbus_bool_t verbose = TRUE;
static dbus_bool_t initted = FALSE;
-
+ static unsigned long pid;
+
/* things are written a bit oddly here so that
* in the non-verbose case we just have the one
* conditional and return immediately.
@@ -200,10 +201,13 @@ _dbus_verbose_real (const char *format,
if (!initted)
{
verbose = _dbus_getenv ("DBUS_VERBOSE") != NULL;
+ pid = _dbus_getpid ();
initted = TRUE;
if (!verbose)
return;
}
+
+ fprintf (stderr, "%lu: ", pid);
va_start (args, format);
vfprintf (stderr, format, args);
diff --git a/test/test-service.c b/test/test-service.c
index 56764dea..732e5b13 100644
--- a/test/test-service.c
+++ b/test/test-service.c
@@ -154,7 +154,7 @@ main (int argc,
dbus_shutdown ();
- printf ("*** Test service exiting\n");
+ _dbus_verbose ("*** Test service exiting\n");
return 0;
}
diff --git a/test/test-utils.c b/test/test-utils.c
index 62963f38..c7d4aa59 100644
--- a/test/test-utils.c
+++ b/test/test-utils.c
@@ -34,10 +34,16 @@ connection_watch_callback (DBusWatch *watch,
dbus_bool_t retval;
dbus_connection_ref (cd->connection);
+
+ _dbus_verbose (" Handling watch\n");
retval = dbus_connection_handle_watch (cd->connection, watch, condition);
+ _dbus_verbose (" Watch handled\n");
+
test_connection_dispatch_all_messages (cd->connection);
+
+ _dbus_verbose (" Dispatched all\n");
dbus_connection_unref (cd->connection);