* bus/bus.c: (bus_context_reload_config): Flush the user database cache on
authorSjoerd Simons <sjoerd@luon.net>
Mon, 6 Mar 2006 19:06:45 +0000 (19:06 +0000)
committerSjoerd Simons <sjoerd@luon.net>
Mon, 6 Mar 2006 19:06:45 +0000 (19:06 +0000)
   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.

ChangeLog
bus/bus.c
bus/dbus-daemon.1.in
dbus/dbus-hash.c
dbus/dbus-hash.h
dbus/dbus-userdb.c
dbus/dbus-userdb.h

index 627e00f..9034541 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-03-06  Sjoerd Simons <sjoerd@luon.net>
+
+       * 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.
+
 2006-03-06  Thiago Macieira  <thiago.macieira@trolltech.com>
 
        * qt/dbusidl2cpp.cpp:
index 48aae8e..8e4f0ea 100644 (file)
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -790,6 +790,9 @@ bus_context_reload_config (BusContext *context,
   DBusString config_file;
   dbus_bool_t ret;
 
+  /* Flush the user database cache */
+  _dbus_user_database_flush(context->user_database);
+
   ret = FALSE;
   _dbus_string_init_const (&config_file, context->config_file);
   parser = bus_config_load (&config_file, TRUE, NULL, error);
index 5144bc1..be2fac0 100644 (file)
@@ -51,9 +51,10 @@ in any way).
 
 .PP
 SIGHUP will cause the D-BUS daemon to PARTIALLY reload its
-configuration file.  Some configuration changes would require kicking
-all apps off the bus; so they will only take effect if you restart the
-daemon. Policy changes should take effect with SIGHUP.
+configuration file and to flush its user/group information caches. Some
+configuration changes would require kicking all apps off the bus; so they will
+only take effect if you restart the daemon. Policy changes should take effect
+with SIGHUP.
 
 .SH OPTIONS
 The following options are supported:
index fa2104b..8eca2bd 100644 (file)
@@ -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)
 {
index 7db06f0..3eb82d0 100644 (file)
@@ -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);
index 9efc465..17ce47d 100644 (file)
@@ -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.
index 7e033b4..906c6ab 100644 (file)
@@ -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,