From 40751c847b18b4861f623fc83fc8742bc463363b Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 11 Oct 2003 06:20:28 +0000 Subject: 2003-10-11 Havoc Pennington * dbus/dbus-message.c (_dbus_message_test): add more test coverage, but #if 0 for now since they uncover a bug not fixed yet; I think in re_align_field_recurse() (re_align_field_recurse): add FIXME about broken assertion * dbus/dbus-sysdeps.c (_dbus_sysdeps_test): add more test coverage * bus/connection.c: share a couple code bits with expirelist.c * bus/expirelist.h, bus/expirelist.c: implement a generic expire-items-after-N-seconds facility, was going to share between expiring connections and replies, decided not to use for expiring connections for now. * bus/connection.c: add tracking of expected replies * COPYING: include AFL 2.0 (still need to change all the file headers) --- bus/Makefile.am | 2 ++ bus/connection.c | 26 ++++++-------------------- bus/test-main.c | 6 ++++++ bus/test.h | 1 + 4 files changed, 15 insertions(+), 20 deletions(-) (limited to 'bus') diff --git a/bus/Makefile.am b/bus/Makefile.am index bc728801..a6c4b17b 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -40,6 +40,8 @@ BUS_SOURCES= \ dispatch.h \ driver.c \ driver.h \ + expirelist.c \ + expirelist.h \ policy.c \ policy.h \ services.c \ diff --git a/bus/connection.c b/bus/connection.c index a824576c..68e4158a 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -26,6 +26,7 @@ #include "services.h" #include "utils.h" #include "signals.h" +#include "expirelist.h" #include #include #include @@ -672,8 +673,9 @@ bus_connections_expire_incomplete (BusConnections *connections) _dbus_assert (d != NULL); - elapsed = ((double) tv_sec - (double) d->connection_tv_sec) * 1000.0 + - ((double) tv_usec - (double) d->connection_tv_usec) / 1000.0; + elapsed = ELAPSED_MILLISECONDS_SINCE (d->connection_tv_sec, + d->connection_tv_usec, + tv_sec, tv_usec); if (elapsed >= (double) auth_timeout) { @@ -693,25 +695,9 @@ bus_connections_expire_incomplete (BusConnections *connections) link = next; } } - - if (next_interval >= 0) - { - _dbus_timeout_set_interval (connections->expire_timeout, - next_interval); - _dbus_timeout_set_enabled (connections->expire_timeout, TRUE); - _dbus_verbose ("Enabled incomplete connections timeout with interval %d, %d incomplete connections\n", - next_interval, connections->n_incomplete); - } - else if (dbus_timeout_get_enabled (connections->expire_timeout)) - { - _dbus_timeout_set_enabled (connections->expire_timeout, FALSE); - - _dbus_verbose ("Disabled incomplete connections timeout, %d incomplete connections\n", - connections->n_incomplete); - } - else - _dbus_verbose ("No need to disable incomplete connections timeout\n"); + bus_expire_timeout_set_interval (connections->expire_timeout, + next_interval); } static dbus_bool_t diff --git a/bus/test-main.c b/bus/test-main.c index 3f280d4e..31a9e158 100644 --- a/bus/test-main.c +++ b/bus/test-main.c @@ -76,6 +76,12 @@ main (int argc, char **argv) if (!_dbus_threads_init_debug ()) die ("initializing debug threads"); #endif + + printf ("%s: Running expire list test\n", argv[0]); + if (!bus_expire_list_test (&test_data_dir)) + die ("expire list"); + + check_memleaks (argv[0]); printf ("%s: Running config file parser test\n", argv[0]); if (!bus_config_parser_test (&test_data_dir)) diff --git a/bus/test.h b/bus/test.h index fc972fe3..585f1c8e 100644 --- a/bus/test.h +++ b/bus/test.h @@ -37,6 +37,7 @@ dbus_bool_t bus_dispatch_sha1_test (const DBusString *test_data_d dbus_bool_t bus_policy_test (const DBusString *test_data_dir); dbus_bool_t bus_config_parser_test (const DBusString *test_data_dir); dbus_bool_t bus_signals_test (const DBusString *test_data_dir); +dbus_bool_t bus_expire_list_test (const DBusString *test_data_dir); dbus_bool_t bus_setup_debug_client (DBusConnection *connection); void bus_test_clients_foreach (BusConnectionForeachFunction function, void *data); -- cgit