From caf220015ba1afd9dfca2a93cfa5208058041610 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 6 Mar 2006 19:06:45 +0000 Subject: * bus/bus.c: (bus_context_reload_config): Flush the user database cache on config reload. * bus/dbus-daemon.1.in: Also note that SIGHUP flushes the user/group information caches * dbus/dbus-hash.c: (_dbus_hash_table_remove_all): * dbus/dbus-hash.h: Add function to remove all entries from a hash table * dbus/dbus-userdb.c: (_dbus_user_database_flush): * dbus/dbus-userdb.h: Add function to flush all user/group information caches. --- dbus/dbus-hash.c | 16 ++++++++++++++++ dbus/dbus-hash.h | 1 + dbus/dbus-userdb.c | 12 ++++++++++++ dbus/dbus-userdb.h | 1 + 4 files changed, 30 insertions(+) (limited to 'dbus') diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c index fa2104b3..8eca2bd8 100644 --- a/dbus/dbus-hash.c +++ b/dbus/dbus-hash.c @@ -422,6 +422,22 @@ _dbus_hash_table_unref (DBusHashTable *table) } } +/** + * Removed all entries from a hash table. + * + * @param table the hash table to remove all entries from. + */ +void +_dbus_hash_table_remove_all (DBusHashTable *table) +{ + DBusHashIter iter; + _dbus_hash_iter_init (table, &iter); + while (_dbus_hash_iter_next (&iter)) + { + _dbus_hash_iter_remove_entry(&iter); + } +} + static DBusHashEntry* alloc_entry (DBusHashTable *table) { diff --git a/dbus/dbus-hash.h b/dbus/dbus-hash.h index 7db06f0c..3eb82d04 100644 --- a/dbus/dbus-hash.h +++ b/dbus/dbus-hash.h @@ -63,6 +63,7 @@ DBusHashTable* _dbus_hash_table_new (DBusHashType type, DBusFreeFunction value_free_function); DBusHashTable* _dbus_hash_table_ref (DBusHashTable *table); void _dbus_hash_table_unref (DBusHashTable *table); +void _dbus_hash_table_remove_all (DBusHashTable *table); void _dbus_hash_iter_init (DBusHashTable *table, DBusHashIter *iter); dbus_bool_t _dbus_hash_iter_next (DBusHashIter *iter); diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 9efc4653..17ce47d3 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -476,6 +476,18 @@ _dbus_user_database_new (void) return NULL; } +/** + * Flush all information out of the user database. + */ +void +_dbus_user_database_flush (DBusUserDatabase *db) +{ + _dbus_hash_table_remove_all(db->users_by_name); + _dbus_hash_table_remove_all(db->groups_by_name); + _dbus_hash_table_remove_all(db->users); + _dbus_hash_table_remove_all(db->groups); +} + #ifdef DBUS_BUILD_TESTS /** * Increments refcount of user database. diff --git a/dbus/dbus-userdb.h b/dbus/dbus-userdb.h index 7e033b41..906c6ab3 100644 --- a/dbus/dbus-userdb.h +++ b/dbus/dbus-userdb.h @@ -51,6 +51,7 @@ struct DBusUserDatabase DBusUserDatabase* _dbus_user_database_new (void); DBusUserDatabase* _dbus_user_database_ref (DBusUserDatabase *db); +void _dbus_user_database_flush (DBusUserDatabase *db); void _dbus_user_database_unref (DBusUserDatabase *db); dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db, dbus_uid_t uid, -- cgit