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

svn commit: r1647339 - in /subversion/trunk/subversion: libsvn_subr/cache-membuffer.c tests/libsvn_subr/cache-test.c

Author: ivan
Date: Mon Dec 22 16:02:53 2014
New Revision: 1647339

URL: http://svn.apache.org/r1647339
Log:
Do not ignore error returned from 'partial getter' in membuffer cache when 
compiled to use simple mutex instead of read/write lock.

* subversion/libsvn_subr/cache-membuffer.c
  (unlock_cache): Pass ERR argument to svn_mutex__unlock() call.

* subversion/tests/libsvn_subr/cache-test.c
  (test_membuffer_serializer_error_handling): New test to reproduce the 
   issue.
  (raise_error_deserialize_func, raise_error_partial_getter_func): Helpers 
   for test_membuffer_serializer_error_handling test.
  (test_funcs): Add test_membuffer_serializer_error_handling() test to 
   the list.

Modified:
    subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
    subversion/trunk/subversion/tests/libsvn_subr/cache-test.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=1647339&r1=1647338&r2=1647339&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Mon Dec 22 16:02:53 2014
@@ -715,7 +715,7 @@ unlock_cache(svn_membuffer_t *cache, svn
 #if APR_HAS_THREADS
 #  if USE_SIMPLE_MUTEX
 
-  return svn_mutex__unlock(cache->lock, SVN_NO_ERROR);
+  return svn_mutex__unlock(cache->lock, err);
 
 #  else
 

Modified: subversion/trunk/subversion/tests/libsvn_subr/cache-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/cache-test.c?rev=1647339&r1=1647338&r2=1647339&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/cache-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/cache-test.c Mon Dec 22 16:02:53 2014
@@ -201,6 +201,68 @@ test_membuffer_cache_basic(apr_pool_t *p
   return basic_cache_test(cache, FALSE, pool);
 }
 
+/* Implements svn_cache__deserialize_func_t */
+static svn_error_t *
+raise_error_deserialize_func(void **out,
+                             void *data,
+                             apr_size_t data_len,
+                             apr_pool_t *pool)
+{
+  return svn_error_create(APR_EGENERAL, NULL, NULL);
+}
+
+/* Implements svn_cache__partial_getter_func_t */
+static svn_error_t *
+raise_error_partial_getter_func(void **out,
+                                const void *data,
+                                apr_size_t data_len,
+                                void *baton,
+                                apr_pool_t *result_pool)
+{
+  return svn_error_create(APR_EGENERAL, NULL, NULL);
+}
+
+static svn_error_t *
+test_membuffer_serializer_error_handling(apr_pool_t *pool)
+{
+  svn_cache__t *cache;
+  svn_membuffer_t *membuffer;
+  svn_revnum_t twenty = 20;
+  svn_boolean_t found;
+  void *val;
+
+  SVN_ERR(svn_cache__membuffer_cache_create(&membuffer, 10*1024, 1, 0,
+                                            TRUE, TRUE, pool));
+
+  /* Create a cache with just one entry. */
+  SVN_ERR(svn_cache__create_membuffer_cache(&cache,
+                                            membuffer,
+                                            serialize_revnum,
+                                            raise_error_deserialize_func,
+                                            APR_HASH_KEY_STRING,
+                                            "cache:",
+                                            SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY,
+                                            FALSE,
+                                            pool, pool));
+
+  SVN_ERR(svn_cache__set(cache, "twenty", &twenty, pool));
+
+  /* Test retrieving data from cache using full getter that
+     always raises an error. */
+  SVN_TEST_ASSERT_ERROR(
+    svn_cache__get(&val, &found, cache, "twenty", pool),
+    APR_EGENERAL);
+
+  /* Test retrieving data from cache using partial getter that
+     always raises an error. */
+  SVN_TEST_ASSERT_ERROR(
+    svn_cache__get_partial(&val, &found, cache, "twenty",
+                           raise_error_partial_getter_func,
+                           NULL, pool),
+    APR_EGENERAL);
+
+  return SVN_NO_ERROR;
+}
 
 static svn_error_t *
 test_memcache_long_key(const svn_test_opts_t *opts,
@@ -274,6 +336,8 @@ static struct svn_test_descriptor_t test
                        "memcache svn_cache with very long keys"),
     SVN_TEST_PASS2(test_membuffer_cache_basic,
                    "basic membuffer svn_cache test"),
+    SVN_TEST_PASS2(test_membuffer_serializer_error_handling,
+                   "test for error handling in membuffer svn_cache"),
     SVN_TEST_NULL
   };