dbus/dbus dbus-message.c,1.143,1.144

Havoc Pennington hp at freedesktop.org
Thu Nov 25 23:03:07 PST 2004


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv29663/dbus

Modified Files:
	dbus-message.c 
Log Message:
2004-11-26  Havoc Pennington  <hp at redhat.com>

	* dbus/dbus-message.c (dbus_message_cache_or_finalize): fix bug
	where I was trying to cache one too many messages



Index: dbus-message.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- dbus-message.c	26 Nov 2004 06:52:15 -0000	1.143
+++ dbus-message.c	26 Nov 2004 07:03:05 -0000	1.144
@@ -1486,6 +1486,12 @@
       return NULL;
     }
 
+  /* This is not necessarily true unless count > 0, and
+   * message_cache is uninitialized until the shutdown is
+   * registered
+   */
+  _dbus_assert (message_cache_shutdown_registered);
+  
   i = 0;
   while (i < MAX_MESSAGE_CACHE_SIZE)
     {
@@ -1498,6 +1504,7 @@
         }
       ++i;
     }
+  _dbus_assert (message_cache_count >= 0);
   _dbus_assert (i < MAX_MESSAGE_CACHE_SIZE);
   _dbus_assert (message != NULL);
 
@@ -1559,15 +1566,15 @@
       MAX_MESSAGE_SIZE_TO_CACHE)
     goto out;
   
-  if (message_cache_count > MAX_MESSAGE_CACHE_SIZE)
+  if (message_cache_count >= MAX_MESSAGE_CACHE_SIZE)
     goto out;
 
+  /* Find empty slot */
   i = 0;
   while (message_cache[i] != NULL)
-    {
-      ++i;
-      _dbus_assert (i < MAX_MESSAGE_CACHE_SIZE);
-    }
+    ++i;
+
+  _dbus_assert (i < MAX_MESSAGE_CACHE_SIZE);
 
   _dbus_assert (message_cache[i] == NULL);
   message_cache[i] = message;



More information about the dbus-commit mailing list