userdb cache expiry

Tim Dijkstra newsuser at famdijkstra.org
Thu Sep 21 07:43:47 PDT 2006


On Thu, 21 Sep 2006 12:53:15 +0200
Havoc:

> If we can cook up a clean patch to keep the same basic code structure 
> but maintain a cache size of 0, that will let us test the theory that 
> it's OK to drop the cache, but still keep the code there if it turns out 
> to be needed.

OK, if this goes after the other one I send, it should be perfectly
safe and minimal. By commenting out the lookup part we disable caching.
To not leak memory, lookups are still stored in the DBusUserDatabase. 

Ripping out caching altogether doesn't seem that much work, there's only
a handfull of functions that access it, and these are (now, since former
patch) contained to dbus-userdb-{util,}.c

grts Tim

Oh, the first hunk is an unrelated fix. It fixes a compiler warning.

Index: dbus/dbus-userdb.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-userdb.c,v
retrieving revision 1.20
diff -u -r1.20 dbus-userdb.c
--- dbus/dbus-userdb.c	10 Sep 2006 21:37:10 -0000	1.20
+++ dbus/dbus-userdb.c	21 Sep 2006 14:07:39 -0000
@@ -79,7 +79,7 @@
 {
   int end;
 
-  if (_dbus_string_parse_int (str, 0, num, &end) &&
+  if (_dbus_string_parse_uint (str, 0, num, &end) &&
       end == _dbus_string_get_length (str))
     return TRUE;
   else
@@ -118,11 +118,12 @@
         uid = n;
     }
 
+#ifdef DBUS_ENABLE_USER_CACHE  
   if (uid != DBUS_UID_UNSET)
     info = _dbus_hash_table_lookup_ulong (db->users, uid);
   else
     info = _dbus_hash_table_lookup_string (db->users_by_name, _dbus_string_get_const_data (username));
-  
+
   if (info)
     {
       _dbus_verbose ("Using cache for UID "DBUS_UID_FORMAT" information\n",
@@ -130,6 +131,9 @@
       return info;
     }
   else
+#else 
+  if (1)
+#endif
     {
       if (uid != DBUS_UID_UNSET)
 	_dbus_verbose ("No cache for UID "DBUS_UID_FORMAT"\n",
Index: dbus/dbus-userdb-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-userdb-util.c,v
retrieving revision 1.7
diff -u -r1.7 dbus-userdb-util.c
--- dbus/dbus-userdb-util.c	7 Jun 2006 19:59:11 -0000	1.7
+++ dbus/dbus-userdb-util.c	21 Sep 2006 14:07:51 -0000
+#ifdef DBUS_ENABLE_USER_CACHE
   if (gid != DBUS_GID_UNSET)
     info = _dbus_hash_table_lookup_ulong (db->groups, gid);
   else
@@ -245,6 +247,9 @@
       return info;
     }
   else
+#else
+  if (0)
+#endif
     {
       if (gid != DBUS_GID_UNSET)
 	_dbus_verbose ("No cache for GID "DBUS_GID_FORMAT"\n",



More information about the dbus mailing list