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 2012/10/13 18:02:02 UTC

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

Author: stefan2
Date: Sat Oct 13 16:02:01 2012
New Revision: 1397871

URL: http://svn.apache.org/viewvc?rev=1397871&view=rev
Log:
Fix the SVN_DEBUG_CACHE_MEMBUFFER support.
Obviously, no-one activated that code for a while ... ;)

* subversion/libsvn_subr/cache-membuffer.c
  (entry_key_t): move declaration further up
  (store_key_part): update to our new key type
  (DEBUG_CACHE_MEMBUFFER_TAG,
   DEBUG_CACHE_MEMBUFFER_INIT_TAG): make 'tag' always be a pointer
  (membuffer_cache_set_internal): ensure you have the entry before
   accessing it
  (membuffer_cache_get_internal): fix buffer reference
  (membuffer_cache_set_partial_internal): always update the tag info
  (membuffer_cache_set_partial): fix tag macro usage

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=1397871&r1=1397870&r2=1397871&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Sat Oct 13 16:02:01 2012
@@ -150,6 +150,12 @@
  */
 #define MAX_ITEM_SIZE ((apr_uint32_t)(0 - ITEM_ALIGNMENT))
 
+/* A 16 byte key type. We use that to identify cache entries.
+ * The notation as just two integer values will cause many compilers
+ * to create better code.
+ */
+typedef apr_uint64_t entry_key_t[2];
+
 /* Debugging / corruption detection support.
  * If you define this macro, the getter functions will performed expensive
  * checks on the item data, requested keys and entry types. If there is
@@ -210,7 +216,7 @@ static void get_prefix_tail(const char *
 /* Initialize all members of TAG except for the content hash.
  */
 static svn_error_t *store_key_part(entry_tag_t *tag,
-                                   unsigned char *prefix_hash,
+                                   entry_key_t prefix_hash,
                                    char *prefix_tail,
                                    const void *key,
                                    apr_size_t key_len,
@@ -275,11 +281,12 @@ static svn_error_t* assert_equal_tags(co
 
 #define DEBUG_CACHE_MEMBUFFER_TAG_ARG entry_tag_t *tag,
 
-#define DEBUG_CACHE_MEMBUFFER_TAG &tag,
+#define DEBUG_CACHE_MEMBUFFER_TAG tag,
 
 #define DEBUG_CACHE_MEMBUFFER_INIT_TAG                         \
-  entry_tag_t tag;                                             \
-  SVN_ERR(store_key_part(&tag,                                 \
+  entry_tag_t _tag;                                            \
+  entry_tag_t *tag = &_tag;                                    \
+  SVN_ERR(store_key_part(tag,                                  \
                          cache->prefix,                        \
                          cache->prefix_tail,                   \
                          key,                                  \
@@ -298,12 +305,6 @@ static svn_error_t* assert_equal_tags(co
 
 #endif /* SVN_DEBUG_CACHE_MEMBUFFER */
 
-/* A 16 byte key type. We use that to identify cache entries.
- * The notation as just two integer values will cause many compilers
- * to create better code.
- */
-typedef apr_uint64_t entry_key_t[2];
-
 /* A single dictionary entry. Since all entries will be allocated once
  * during cache creation, those entries might be either used or unused.
  * An entry is used if and only if it is contained in the doubly-linked
@@ -1378,6 +1379,14 @@ membuffer_cache_set_internal(svn_membuff
       && cache->max_entry_size >= size
       && ensure_data_insertable(cache, size))
     {
+      /* Remove old data for this key, if that exists.
+       * Get an unused entry for the key and and initialize it with
+       * the serialized item's (future) position within data buffer.
+       */
+      entry = find_entry(cache, group_index, to_find, TRUE);
+      entry->size = size;
+      entry->offset = cache->current_data;
+
 #ifdef SVN_DEBUG_CACHE_MEMBUFFER
 
       /* Remember original content, type and key (hashes)
@@ -1387,16 +1396,8 @@ membuffer_cache_set_internal(svn_membuff
 
 #endif
 
-      /* Remove old data for this key, if that exists.
-       * Get an unused entry for the key and and initialize it with
-       * the serialized item's (future) position within data buffer.
-       */
-      entry = find_entry(cache, group_index, to_find, TRUE);
-      entry->size = size;
-      entry->offset = cache->current_data;
-
       /* Link the entry properly.
-        */
+       */
       insert_entry(cache, entry);
 
       /* Copy the serialized item data into the cache.
@@ -1509,7 +1510,7 @@ membuffer_cache_get_internal(svn_membuff
 
   /* Compare original content, type and key (hashes)
    */
-  SVN_ERR(store_content_part(tag, buffer, entry->size, result_pool));
+  SVN_ERR(store_content_part(tag, *buffer, entry->size, result_pool));
   SVN_ERR(assert_equal_tags(&entry->tag, tag));
 
 #endif
@@ -1746,17 +1747,17 @@ membuffer_cache_set_partial_internal(svn
                   /* Link the entry properly.
                    */
                   insert_entry(cache, entry);
+                }
+            }
 
 #ifdef SVN_DEBUG_CACHE_MEMBUFFER
 
-                  /* Remember original content, type and key (hashes)
-                   */
-                  SVN_ERR(store_content_part(tag, data, size, scratch_pool));
-                  memcpy(&entry->tag, tag, sizeof(*tag));
+          /* Remember original content, type and key (hashes)
+           */
+          SVN_ERR(store_content_part(tag, data, size, scratch_pool));
+          memcpy(&entry->tag, tag, sizeof(*tag));
 
 #endif
-                }
-            }
         }
     }
 
@@ -1782,7 +1783,7 @@ membuffer_cache_set_partial(svn_membuffe
   WITH_WRITE_LOCK(cache,
                   membuffer_cache_set_partial_internal
                      (cache, group_index, key, func, baton,
-                      DEBUG_CACHE_MEMBUFFER_TAG_ARG
+                      DEBUG_CACHE_MEMBUFFER_TAG
                       scratch_pool));
 
   /* done here -> unlock the cache