You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/12/22 02:10:09 UTC

svn commit: r1721290 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Author: stefan2
Date: Tue Dec 22 01:10:09 2015
New Revision: 1721290

URL: http://svn.apache.org/viewvc?rev=1721290&view=rev
Log:
Fix an inefficiency in the membuffer cache introduced by r1717338:
Very large high-prio items would falsly get rejected.

High-priority items may be larger than the L1 max_entry_size but
still get written directly to L2, skipping L1.

* subversion/libsvn_subr/cache-membuffer.c
  (membuffer_cache_set_internal): Check for arithmetic overflow only and
                                  leave the size to check to select_level.

Modified:
    subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Modified: subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache-membuffer.c?rev=1721290&r1=1721289&r2=1721290&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Tue Dec 22 01:10:09 2015
@@ -2219,18 +2219,13 @@ membuffer_cache_set_internal(svn_membuff
   /* first, look for a previous entry for the given key */
   entry_t *entry = find_entry(cache, group_index, to_find, FALSE);
 
-  /* Quick size check to make sure arithmetics will work further down
-   * the road. */
-  if (   cache->max_entry_size >= item_size
-      && cache->max_entry_size - item_size >= to_find->entry_key.key_len)
+  /* Quick check make sure arithmetics will work further down the road. */
+  size = item_size + to_find->entry_key.key_len;
+  if (size < item_size)
     {
-      size = item_size + to_find->entry_key.key_len;
-    }
-  else
-    {
-      /* The combination of serialized ITEM and KEY does not fit, so the
-       * the insertion attempt will fail and simply remove any old entry
-       * if that exists. */
+      /* Arithmetic overflow, so combination of serialized ITEM and KEY
+       * cannot not fit into the cache.  Setting BUFFER to NULL will cause
+       * the removal of any entry if that exists without writing new data. */
       buffer = NULL;
     }