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.
This commit is contained in:
Havoc Pennington 2003-04-09 20:31:21 +00:00
parent 0e1945b388
commit 1708094c0e
8 changed files with 77 additions and 25 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}
if (!dbus_message_get_args (reply, error,
DBUS_TYPE_STRING, &name,
0))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
return FALSE;
}
bd->base_service = name;
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;
return TRUE;
bd->base_service = name;
retval = TRUE;
out:
if (reply)
dbus_message_unref (reply);
if (!retval)
_DBUS_ASSERT_ERROR_IS_SET (error);
return retval;
}

View file

@ -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;

View file

@ -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);

View file

@ -154,7 +154,7 @@ main (int argc,
dbus_shutdown ();
printf ("*** Test service exiting\n");
_dbus_verbose ("*** Test service exiting\n");
return 0;
}

View file

@ -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);