diff options
| author | Havoc Pennington <hp@redhat.com> | 2004-11-26 07:03:05 +0000 | 
|---|---|---|
| committer | Havoc Pennington <hp@redhat.com> | 2004-11-26 07:03:05 +0000 | 
| commit | 2d251ec0d3914fbee342814128edd40ea2296a7a (patch) | |
| tree | 7d6fbc067e714eacac56eee590e415a78f49ea95 | |
| parent | 3d1df90a45cffaf5ba80b6a137372affe52d6f72 (diff) | |
2004-11-26  Havoc Pennington  <hp@redhat.com>
	* dbus/dbus-message.c (dbus_message_cache_or_finalize): fix bug
	where I was trying to cache one too many messages
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | dbus/dbus-message.c | 17 | 
2 files changed, 17 insertions, 5 deletions
@@ -1,5 +1,10 @@  2004-11-26  Havoc Pennington  <hp@redhat.com> +	* dbus/dbus-message.c (dbus_message_cache_or_finalize): fix bug +	where I was trying to cache one too many messages + +2004-11-26  Havoc Pennington  <hp@redhat.com> +  	* dbus/dbus-message.c: reimplement message cache as an array which   	makes the cache about twice as fast and saves maybe 1.5% overall diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index db9bc195..a76d3b55 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -1486,6 +1486,12 @@ dbus_message_get_cached (void)        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 @@ dbus_message_get_cached (void)          }        ++i;      } +  _dbus_assert (message_cache_count >= 0);    _dbus_assert (i < MAX_MESSAGE_CACHE_SIZE);    _dbus_assert (message != NULL); @@ -1559,15 +1566,15 @@ dbus_message_cache_or_finalize (DBusMessage *message)        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;  | 
