You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by cm...@apache.org on 2012/06/27 17:13:42 UTC

svn commit: r1354571 [20/37] - in /subversion/branches/master-passphrase: ./ build/ build/ac-macros/ build/generator/ build/generator/templates/ build/win32/ contrib/client-side/emacs/ contrib/server-side/ notes/ notes/api-errata/1.8/ notes/directory-i...

Modified: subversion/branches/master-passphrase/subversion/libsvn_repos/rev_hunt.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_repos/rev_hunt.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_repos/rev_hunt.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_repos/rev_hunt.c Wed Jun 27 15:12:37 2012
@@ -155,7 +155,7 @@ svn_repos_get_committed_info(svn_revnum_
                              apr_pool_t *pool)
 {
   apr_hash_t *revprops;
-  
+
   svn_fs_t *fs = svn_fs_root_fs(root);
 
   /* ### It might be simpler just to declare that revision

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/adler32.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/adler32.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/adler32.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/adler32.c Wed Jun 27 15:12:37 2012
@@ -61,7 +61,9 @@ svn__adler32(apr_uint32_t checksum, cons
        * optimized code. Also, new zlib versions will come with
        * SIMD code for x86 and x64.
        */
-      return adler32(checksum, (const Bytef *)data, len);
+      return (apr_uint32_t)adler32(checksum,
+                                   (const Bytef *)data,
+                                   (uInt)len);
     }
   else
     {

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/auth.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/auth.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/auth.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/auth.c Wed Jun 27 15:12:37 2012
@@ -442,11 +442,12 @@ svn_auth_get_platform_specific_provider(
             {
               svn_version_func_t version_function
                 = version_function_symbol;
-              const svn_version_checklist_t check_list[] =
-                {
-                  { library_label, version_function },
-                  { NULL, NULL }
-                };
+              svn_version_checklist_t check_list[2];
+
+              check_list[0].label = library_label;
+              check_list[0].version_query = version_function;
+              check_list[1].label = NULL;
+              check_list[1].version_query = NULL;
               SVN_ERR(svn_ver_check_list(svn_subr_version(), check_list));
             }
           if (apr_dso_sym(&provider_function_symbol,

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/cache-membuffer.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/cache-membuffer.c Wed Jun 27 15:12:37 2012
@@ -23,6 +23,8 @@
 
 #include <assert.h>
 #include <apr_md5.h>
+#include <apr_thread_rwlock.h>
+
 #include "svn_pools.h"
 #include "svn_checksum.h"
 #include "md5.h"
@@ -436,11 +438,13 @@ struct svn_membuffer_t
    */
   apr_uint64_t total_hits;
 
+#if APR_HAS_THREADS
   /* A lock for intra-process synchronization to the cache, or NULL if
    * the cache's creator doesn't feel the cache needs to be
    * thread-safe.
    */
-  svn_mutex__t *mutex;
+  apr_thread_rwlock_t *lock;
+#endif
 };
 
 /* Align integer VALUE to the next ITEM_ALIGNMENT boundary.
@@ -451,6 +455,76 @@ struct svn_membuffer_t
  */
 #define ALIGN_POINTER(pointer) ((void*)ALIGN_VALUE((apr_size_t)(char*)(pointer)))
 
+/* If locking is supported for CACHE, aquire a read lock for it.
+ */
+static svn_error_t *
+read_lock_cache(svn_membuffer_t *cache)
+{
+#if APR_HAS_THREADS
+  if (cache->lock)
+  {
+    apr_status_t status = apr_thread_rwlock_rdlock(cache->lock);
+    if (status)
+      return svn_error_wrap_apr(status, _("Can't lock cache mutex"));
+  }
+#endif
+  return SVN_NO_ERROR;
+}
+
+/* If locking is supported for CACHE, aquire a write lock for it.
+ */
+static svn_error_t *
+write_lock_cache(svn_membuffer_t *cache)
+{
+#if APR_HAS_THREADS
+  if (cache->lock)
+  {
+    apr_status_t status = apr_thread_rwlock_wrlock(cache->lock);
+    if (status)
+      return svn_error_wrap_apr(status, _("Can't write-lock cache mutex"));
+  }
+#endif
+  return SVN_NO_ERROR;
+}
+
+/* If locking is supported for CACHE, release the current lock
+ * (read or write).
+ */
+static svn_error_t *
+unlock_cache(svn_membuffer_t *cache, svn_error_t *err)
+{
+#if APR_HAS_THREADS
+  if (cache->lock)
+  {
+    apr_status_t status = apr_thread_rwlock_unlock(cache->lock);
+    if (err)
+      return err;
+
+    if (status)
+      return svn_error_wrap_apr(status, _("Can't unlock cache mutex"));
+  }
+#endif
+  return err;
+}
+
+/* If supported, guard the execution of EXPR with a read lock to cache.
+ * Macro has been modelled after SVN_MUTEX__WITH_LOCK.
+ */
+#define WITH_READ_LOCK(cache, expr)         \
+do {                                        \
+  SVN_ERR(read_lock_cache(cache));          \
+  SVN_ERR(unlock_cache(cache, (expr)));     \
+} while (0)
+
+/* If supported, guard the execution of EXPR with a write lock to cache.
+ * Macro has been modelled after SVN_MUTEX__WITH_LOCK.
+ */
+#define WITH_WRITE_LOCK(cache, expr)        \
+do {                                        \
+  SVN_ERR(write_lock_cache(cache));         \
+  SVN_ERR(unlock_cache(cache, (expr)));     \
+} while (0)
+
 /* Resolve a dictionary entry reference, i.e. return the entry
  * for the given IDX.
  */
@@ -584,43 +658,25 @@ insert_entry(svn_membuffer_t *cache, ent
     }
 }
 
-/* Map a KEY of length LEN to the CACHE and group that shall contain the
- * respective item. Return the hash value in TO_FIND. Returns -1 upon error.
+/* Map a KEY of 16 bytes to the CACHE and group that shall contain the
+ * respective item.
  */
 static apr_uint32_t
 get_group_index(svn_membuffer_t **cache,
-                const void *key,
-                apr_size_t len,
-                unsigned char *to_find,
-                apr_pool_t *pool)
+                const apr_uint32_t *key)
 {
-  apr_uint32_t hash = 0;
-  int i;
-
-  /* calculate a hash value for the key */
-  svn_checksum_t *checksum;
-  svn_error_t *err;
-
-  if (key == NULL)
-    return NO_INDEX;
-
-  err = svn_checksum(&checksum, svn_checksum_md5, key, len, pool);
-  if (err != NULL)
-  {
-    svn_error_clear(err);
-    return NO_INDEX;
-  }
-
-  memcpy(to_find, checksum->digest, APR_MD5_DIGESTSIZE);
-
-  /* select the cache segment to use */
-  *cache = &(*cache)[to_find[0] & ((*cache)->segment_count -1)];
+  apr_uint32_t hash;
 
   /* Get the group that *must* contain the entry. Fold the hash value
    * just to be sure (it should not be necessary for perfect hashes).
    */
-  for (i = 0; i < sizeof(to_find) / sizeof(apr_uint32_t); ++i)
-    hash += ((apr_uint32_t*)to_find)[i] ^ ((hash >> 19) || (hash << 13));
+  hash = key[0];
+  hash = key[1] ^ ((hash >> 19) || (hash << 13));
+  hash = key[2] ^ ((hash >> 19) || (hash << 13));
+  hash = key[3] ^ ((hash >> 19) || (hash << 13));
+
+  /* select the cache segment to use */
+  *cache = &(*cache)[key[0] & ((*cache)->segment_count -1)];
 
   return hash % (*cache)->group_count;
 }
@@ -644,9 +700,11 @@ let_entry_age(svn_membuffer_t *cache, en
 static APR_INLINE unsigned char
 is_group_initialized(svn_membuffer_t *cache, apr_uint32_t group_index)
 {
-  unsigned char flags = cache->group_initialized
-                          [group_index / (8 * GROUP_INIT_GRANULARITY)];
-  unsigned char bit_mask = 1 << ((group_index / GROUP_INIT_GRANULARITY) % 8);
+  unsigned char flags
+    = cache->group_initialized[group_index / (8 * GROUP_INIT_GRANULARITY)];
+  unsigned char bit_mask
+    = (unsigned char)(1 << ((group_index / GROUP_INIT_GRANULARITY) % 8));
+
   return flags & bit_mask;
 }
 
@@ -670,7 +728,8 @@ initialize_group(svn_membuffer_t *cache,
         cache->directory[i][j].offset = NO_OFFSET;
 
   /* set the "initialized" bit for these groups */
-  bit_mask = 1 << ((group_index / GROUP_INIT_GRANULARITY) % 8);
+  bit_mask
+    = (unsigned char)(1 << ((group_index / GROUP_INIT_GRANULARITY) % 8));
   cache->group_initialized[group_index / (8 * GROUP_INIT_GRANULARITY)]
     |= bit_mask;
 }
@@ -1012,18 +1071,17 @@ svn_cache__membuffer_cache_create(svn_me
   max_entry_size = data_size / 4 > MAX_ITEM_SIZE
                  ? MAX_ITEM_SIZE
                  : data_size / 4;
-  
+
   /* to keep the entries small, we use 32 bit indices only
    * -> we need to ensure that no more then 4G entries exist.
-   * 
+   *
    * Note, that this limit could only be exceeded in a very
    * theoretical setup with about 1EB of cache.
    */
-  group_count = directory_size / sizeof(entry_group_t);
-  if (group_count >= (APR_UINT32_MAX / GROUP_SIZE))
-    {
-      group_count = (APR_UINT32_MAX / GROUP_SIZE) - 1;
-    }
+  group_count = directory_size / sizeof(entry_group_t)
+                    >= (APR_UINT32_MAX / GROUP_SIZE)
+              ? (APR_UINT32_MAX / GROUP_SIZE) - 1
+              : (apr_uint32_t)(directory_size / sizeof(entry_group_t));
 
   group_init_size = 1 + group_count / (8 * GROUP_INIT_GRANULARITY);
   for (seg = 0; seg < segment_count; ++seg)
@@ -1066,10 +1124,20 @@ svn_cache__membuffer_cache_create(svn_me
           return svn_error_wrap_apr(APR_ENOMEM, _("OOM"));
         }
 
+#if APR_HAS_THREADS
       /* A lock for intra-process synchronization to the cache, or NULL if
        * the cache's creator doesn't feel the cache needs to be
-       * thread-safe. */
-      SVN_ERR(svn_mutex__init(&c[seg].mutex, thread_safe, pool));
+       * thread-safe.
+       */
+      c[seg].lock = NULL;
+      if (thread_safe)
+        {
+          apr_status_t status =
+              apr_thread_rwlock_create(&(c[seg].lock), pool);
+          if (status)
+            return svn_error_wrap_apr(status, _("Can't create cache mutex"));
+        }
+#endif
     }
 
   /* done here
@@ -1154,22 +1222,18 @@ membuffer_cache_set_internal(svn_membuff
 static svn_error_t *
 membuffer_cache_set(svn_membuffer_t *cache,
                     const void *key,
-                    apr_size_t key_len,
                     void *item,
                     svn_cache__serialize_func_t serializer,
                     DEBUG_CACHE_MEMBUFFER_TAG_ARG
                     apr_pool_t *scratch_pool)
 {
   apr_uint32_t group_index;
-  unsigned char to_find[KEY_SIZE];
   void *buffer = NULL;
-  apr_size_t size;
+  apr_size_t size = 0;
 
   /* find the entry group that will hold the key.
    */
-  group_index = get_group_index(&cache, key, key_len, to_find, scratch_pool);
-  if (group_index == NO_INDEX)
-    return SVN_NO_ERROR;
+  group_index = get_group_index(&cache, key);
 
   /* Serialize data data.
    */
@@ -1178,14 +1242,14 @@ membuffer_cache_set(svn_membuffer_t *cac
 
   /* The actual cache data access needs to sync'ed
    */
-  SVN_MUTEX__WITH_LOCK(cache->mutex,
-                       membuffer_cache_set_internal(cache,
-                                                    to_find,
-                                                    group_index,
-                                                    buffer,
-                                                    size,
-                                                    DEBUG_CACHE_MEMBUFFER_TAG
-                                                    scratch_pool));
+  WITH_WRITE_LOCK(cache,
+                  membuffer_cache_set_internal(cache,
+                                               key,
+                                               group_index,
+                                               buffer,
+                                               size,
+                                               DEBUG_CACHE_MEMBUFFER_TAG
+                                               scratch_pool));
   return SVN_NO_ERROR;
 }
 
@@ -1262,36 +1326,26 @@ membuffer_cache_get_internal(svn_membuff
 static svn_error_t *
 membuffer_cache_get(svn_membuffer_t *cache,
                     const void *key,
-                    apr_size_t key_len,
                     void **item,
                     svn_cache__deserialize_func_t deserializer,
                     DEBUG_CACHE_MEMBUFFER_TAG_ARG
                     apr_pool_t *result_pool)
 {
   apr_uint32_t group_index;
-  unsigned char to_find[KEY_SIZE];
   char *buffer;
   apr_size_t size;
 
   /* find the entry group that will hold the key.
    */
-  group_index = get_group_index(&cache, key, key_len, to_find, result_pool);
-  if (group_index == NO_INDEX)
-    {
-      /* Some error occured, return "item not found".
-       */
-      *item = NULL;
-      return SVN_NO_ERROR;
-    }
-
-  SVN_MUTEX__WITH_LOCK(cache->mutex,
-                       membuffer_cache_get_internal(cache,
-                                                    group_index,
-                                                    to_find,
-                                                    &buffer,
-                                                    &size,
-                                                    DEBUG_CACHE_MEMBUFFER_TAG
-                                                    result_pool));
+  group_index = get_group_index(&cache, key);
+  WITH_READ_LOCK(cache,
+                 membuffer_cache_get_internal(cache,
+                                              group_index,
+                                              key,
+                                              &buffer,
+                                              &size,
+                                              DEBUG_CACHE_MEMBUFFER_TAG
+                                              result_pool));
 
   /* re-construct the original data object from its serialized form.
    */
@@ -1369,7 +1423,7 @@ membuffer_cache_get_partial_internal(svn
     }
 }
 
-/* Look for the cache entry identified by KEY and KEY_LEN. FOUND indicates
+/* Look for the cache entry identified by KEY. FOUND indicates
  * whether that entry exists. If not found, *ITEM will be NULL. Otherwise,
  * the DESERIALIZER is called with that entry and the BATON provided
  * and will extract the desired information. The result is set in *ITEM.
@@ -1378,7 +1432,6 @@ membuffer_cache_get_partial_internal(svn
 static svn_error_t *
 membuffer_cache_get_partial(svn_membuffer_t *cache,
                             const void *key,
-                            apr_size_t key_len,
                             void **item,
                             svn_boolean_t *found,
                             svn_cache__partial_getter_func_t deserializer,
@@ -1386,17 +1439,13 @@ membuffer_cache_get_partial(svn_membuffe
                             DEBUG_CACHE_MEMBUFFER_TAG_ARG
                             apr_pool_t *result_pool)
 {
-  apr_uint32_t group_index;
-  unsigned char to_find[KEY_SIZE];
+  apr_uint32_t group_index = get_group_index(&cache, key);
 
-  group_index = get_group_index(&cache, key, key_len, to_find, result_pool);
-
-  if (group_index != NO_INDEX)
-    SVN_MUTEX__WITH_LOCK(cache->mutex,
-                         membuffer_cache_get_partial_internal
-                             (cache, group_index, to_find, item, found,
-                              deserializer, baton, DEBUG_CACHE_MEMBUFFER_TAG
-                              result_pool));
+  WITH_READ_LOCK(cache,
+                 membuffer_cache_get_partial_internal
+                     (cache, group_index, key, item, found,
+                      deserializer, baton, DEBUG_CACHE_MEMBUFFER_TAG
+                      result_pool));
 
   return SVN_NO_ERROR;
 }
@@ -1507,7 +1556,7 @@ membuffer_cache_set_partial_internal(svn
   return SVN_NO_ERROR;
 }
 
-/* Look for the cache entry identified by KEY and KEY_LEN. If no entry
+/* Look for the cache entry identified by KEY. If no entry
  * has been found, the function returns without modifying the cache.
  * Otherwise, FUNC is called with that entry and the BATON provided
  * and may modify the cache entry. Allocations will be done in POOL.
@@ -1515,25 +1564,19 @@ membuffer_cache_set_partial_internal(svn
 static svn_error_t *
 membuffer_cache_set_partial(svn_membuffer_t *cache,
                             const void *key,
-                            apr_size_t key_len,
                             svn_cache__partial_setter_func_t func,
                             void *baton,
                             DEBUG_CACHE_MEMBUFFER_TAG_ARG
                             apr_pool_t *scratch_pool)
 {
-  apr_uint32_t group_index;
-  unsigned char to_find[KEY_SIZE];
-
   /* cache item lookup
    */
-  group_index = get_group_index(&cache, key, key_len, to_find, scratch_pool);
-
-  if (group_index != NO_INDEX)
-    SVN_MUTEX__WITH_LOCK(cache->mutex,
-                         membuffer_cache_set_partial_internal
-                             (cache, group_index, to_find, func, baton,
-                              DEBUG_CACHE_MEMBUFFER_TAG_ARG
-                              scratch_pool));
+  apr_uint32_t group_index = get_group_index(&cache, key);
+  WITH_WRITE_LOCK(cache,
+                  membuffer_cache_set_partial_internal
+                     (cache, group_index, key, func, baton,
+                      DEBUG_CACHE_MEMBUFFER_TAG_ARG
+                      scratch_pool));
 
   /* done here -> unlock the cache
    */
@@ -1576,7 +1619,7 @@ typedef struct svn_membuffer_cache_t
    * This makes (very likely) our keys different from all keys used
    * by other svn_membuffer_cache_t instances.
    */
-  unsigned char prefix [APR_MD5_DIGESTSIZE];
+  apr_uint64_t prefix [APR_MD5_DIGESTSIZE / sizeof(apr_uint64_t)];
 
   /* A copy of the unmodified prefix. It is being used as a user-visible
    * ID for this cache instance.
@@ -1588,6 +1631,10 @@ typedef struct svn_membuffer_cache_t
    */
   apr_ssize_t key_len;
 
+  /* Temporary buffer containing the hash key for the current access
+   */
+  apr_uint64_t combined_key [APR_MD5_DIGESTSIZE / sizeof(apr_uint64_t)];
+
   /* a pool for temporary allocations during get() and set()
    */
   apr_pool_t *pool;
@@ -1615,34 +1662,21 @@ typedef struct svn_membuffer_cache_t
 #define ALLOCATIONS_PER_POOL_CLEAR 10
 
 
-/* Basically concatenate PREFIX and KEY and return the result in FULL_KEY.
- * Allocations will be made in POOL.
+/* Basically calculate a hash value for KEY of length KEY_LEN, combine it
+ * with the CACHE->PREFIX and write the result in CACHE->COMBINED_KEY.
  */
 static void
-combine_key(const void *prefix,
-            apr_size_t prefix_len,
+combine_key(svn_membuffer_cache_t *cache,
             const void *key,
-            apr_ssize_t key_len,
-            void **full_key,
-            apr_size_t *full_key_len,
-            apr_pool_t *pool)
+            apr_ssize_t key_len)
 {
-  if (key == NULL)
-    {
-      *full_key = NULL;
-      *full_key_len = 0;
-    }
-  else
-    {
-      if (key_len == APR_HASH_KEY_STRING)
-        key_len = strlen((const char *) key);
+  if (key_len == APR_HASH_KEY_STRING)
+    key_len = strlen((const char *) key);
 
-      *full_key_len = prefix_len + key_len;
-      *full_key = apr_palloc(pool, *full_key_len);
+  apr_md5((unsigned char*)cache->combined_key, key, key_len);
 
-      memcpy(*full_key, prefix, prefix_len);
-      memcpy((char *)*full_key + prefix_len, key, key_len);
-    }
+  cache->combined_key[0] ^= cache->prefix[0];
+  cache->combined_key[1] ^= cache->prefix[1];
 }
 
 /* Implement svn_cache__vtable_t.get (not thread-safe)
@@ -1656,26 +1690,25 @@ svn_membuffer_cache_get(void **value_p,
 {
   svn_membuffer_cache_t *cache = cache_void;
 
+  DEBUG_CACHE_MEMBUFFER_INIT_TAG
+
+  /* special case */
+  if (key == NULL)
+    {
+      *value_p = NULL;
+      *found = FALSE;
+
+      return SVN_NO_ERROR;
+    }
+
   /* construct the full, i.e. globally unique, key by adding
    * this cache instances' prefix
    */
-  void *full_key;
-  apr_size_t full_key_len;
-
-  DEBUG_CACHE_MEMBUFFER_INIT_TAG
-
-  combine_key(cache->prefix,
-              sizeof(cache->prefix),
-              key,
-              cache->key_len,
-              &full_key,
-              &full_key_len,
-              cache->pool);
+  combine_key(cache, key, cache->key_len);
 
   /* Look the item up. */
   SVN_ERR(membuffer_cache_get(cache->membuffer,
-                              full_key,
-                              full_key_len,
+                              cache->combined_key,
                               value_p,
                               cache->deserializer,
                               DEBUG_CACHE_MEMBUFFER_TAG
@@ -1706,11 +1739,12 @@ svn_membuffer_cache_set(void *cache_void
 {
   svn_membuffer_cache_t *cache = cache_void;
 
-  void *full_key;
-  apr_size_t full_key_len;
-
   DEBUG_CACHE_MEMBUFFER_INIT_TAG
 
+  /* special case */
+  if (key == NULL)
+    return SVN_NO_ERROR;
+
   /* we do some allocations below, so increase the allocation counter
    * by a slightly larger amount. Free allocated memory every now and then.
    */
@@ -1724,20 +1758,13 @@ svn_membuffer_cache_set(void *cache_void
   /* construct the full, i.e. globally unique, key by adding
    * this cache instances' prefix
    */
-  combine_key(cache->prefix,
-              sizeof(cache->prefix),
-              key,
-              cache->key_len,
-              &full_key,
-              &full_key_len,
-              cache->pool);
+  combine_key(cache, key, cache->key_len);
 
   /* (probably) add the item to the cache. But there is no real guarantee
    * that the item will actually be cached afterwards.
    */
   return membuffer_cache_set(cache->membuffer,
-                             full_key,
-                             full_key_len,
+                             cache->combined_key,
                              value,
                              cache->serializer,
                              DEBUG_CACHE_MEMBUFFER_TAG
@@ -1770,28 +1797,25 @@ svn_membuffer_cache_get_partial(void **v
 {
   svn_membuffer_cache_t *cache = cache_void;
 
-  void *full_key;
-  apr_size_t full_key_len;
-
   DEBUG_CACHE_MEMBUFFER_INIT_TAG
 
+  if (key == NULL)
+    {
+      *value_p = NULL;
+      *found = FALSE;
+
+      return SVN_NO_ERROR;
+    }
+
   if (++cache->alloc_counter > ALLOCATIONS_PER_POOL_CLEAR)
     {
       apr_pool_clear(cache->pool);
       cache->alloc_counter = 0;
     }
 
-  combine_key(cache->prefix,
-              sizeof(cache->prefix),
-              key,
-              cache->key_len,
-              &full_key,
-              &full_key_len,
-              cache->pool);
-
+  combine_key(cache, key, cache->key_len);
   SVN_ERR(membuffer_cache_get_partial(cache->membuffer,
-                                      full_key,
-                                      full_key_len,
+                                      cache->combined_key,
                                       value_p,
                                       found,
                                       func,
@@ -1813,27 +1837,18 @@ svn_membuffer_cache_set_partial(void *ca
 {
   svn_membuffer_cache_t *cache = cache_void;
 
-  void *full_key;
-  apr_size_t full_key_len;
-
   DEBUG_CACHE_MEMBUFFER_INIT_TAG
 
-  combine_key(cache->prefix,
-              sizeof(cache->prefix),
-              key,
-              cache->key_len,
-              &full_key,
-              &full_key_len,
-              scratch_pool);
-
-  SVN_ERR(membuffer_cache_set_partial(cache->membuffer,
-                                      full_key,
-                                      full_key_len,
-                                      func,
-                                      baton,
-                                      DEBUG_CACHE_MEMBUFFER_TAG
-                                      scratch_pool));
-
+  if (key != NULL)
+    {
+      combine_key(cache, key, cache->key_len);
+      SVN_ERR(membuffer_cache_set_partial(cache->membuffer,
+                                          cache->combined_key,
+                                          func,
+                                          baton,
+                                          DEBUG_CACHE_MEMBUFFER_TAG
+                                          scratch_pool));
+    }
   return SVN_NO_ERROR;
 }
 
@@ -1896,8 +1911,8 @@ svn_membuffer_cache_get_info(void *cache
   for (i = 0; i < cache->membuffer->segment_count; ++i)
     {
       svn_membuffer_t *segment = cache->membuffer + i;
-      SVN_MUTEX__WITH_LOCK(segment->mutex,
-                           svn_membuffer_get_segment_info(segment, info));
+      WITH_READ_LOCK(segment,
+                     svn_membuffer_get_segment_info(segment, info));
     }
 
   return SVN_NO_ERROR;

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/cache-memcache.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/cache-memcache.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/cache-memcache.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/cache-memcache.c Wed Jun 27 15:12:37 2012
@@ -29,6 +29,7 @@
 
 #include "svn_private_config.h"
 #include "private/svn_cache.h"
+#include "private/svn_dep_compat.h"
 
 #include "cache.h"
 
@@ -527,7 +528,7 @@ svn_cache__make_memcache_from_config(svn
                                     svn_config_t *config,
                                     apr_pool_t *pool)
 {
-  apr_uint16_t server_count;
+  int server_count;
   apr_pool_t *subpool = svn_pool_create(pool);
 
   server_count =
@@ -542,12 +543,15 @@ svn_cache__make_memcache_from_config(svn
       return SVN_NO_ERROR;
     }
 
+  if (server_count > APR_INT16_MAX)
+    return svn_error_create(SVN_ERR_TOO_MANY_MEMCACHED_SERVERS, NULL, NULL);
+
 #ifdef SVN_HAVE_MEMCACHE
   {
     struct ams_baton b;
     svn_memcache_t *memcache = apr_pcalloc(pool, sizeof(*memcache));
     apr_status_t apr_err = apr_memcache_create(pool,
-                                               server_count,
+                                               (apr_uint16_t)server_count,
                                                0, /* flags */
                                                &(memcache->c));
     if (apr_err != APR_SUCCESS)

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/cache.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/cache.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/cache.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/cache.c Wed Jun 27 15:12:37 2012
@@ -212,14 +212,14 @@ svn_cache__format_info(const svn_cache__
   enum { _1MB = 1024 * 1024 };
 
   apr_uint64_t misses = info->gets - info->hits;
-  double hit_rate = (100.0 * info->hits)
-                  / (info->gets ? info->gets : 1);
-  double write_rate = (100.0 * info->sets)
-                    / (misses ? misses : 1);
-  double data_usage_rate = (100.0 * info->used_size)
-                         / (info->data_size ? info->data_size : 1);
-  double data_entry_rate = (100.0 * info->used_entries)
-                         / (info->total_entries ? info->total_entries : 1);
+  double hit_rate = (100.0 * (double)info->hits)
+                  / (double)(info->gets ? info->gets : 1);
+  double write_rate = (100.0 * (double)info->sets)
+                    / (double)(misses ? misses : 1);
+  double data_usage_rate = (100.0 * (double)info->used_size)
+                         / (double)(info->data_size ? info->data_size : 1);
+  double data_entry_rate = (100.0 * (double)info->used_entries)
+                 / (double)(info->total_entries ? info->total_entries : 1);
 
   return svn_string_createf(result_pool,
 

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/checksum.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/checksum.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/checksum.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/checksum.c Wed Jun 27 15:12:37 2012
@@ -34,6 +34,8 @@
 #include "sha1.h"
 #include "md5.h"
 
+#include "private/svn_subr_private.h"
+
 #include "svn_private_config.h"
 
 
@@ -54,36 +56,71 @@ validate_kind(svn_checksum_kind_t kind)
     return svn_error_create(SVN_ERR_BAD_CHECKSUM_KIND, NULL, NULL);
 }
 
+/* Create a svn_checksum_t with everything but the contents of the
+   digest populated. */
+static svn_checksum_t *
+checksum_create_without_digest(svn_checksum_kind_t kind,
+                               apr_size_t digest_size,
+                               apr_pool_t *pool)
+{
+  /* Use apr_palloc() instead of apr_pcalloc() so that the digest
+   * contents are only set once by the caller. */
+  svn_checksum_t *checksum = apr_palloc(pool, sizeof(*checksum) + digest_size);
+  checksum->digest = (unsigned char *)checksum + sizeof(*checksum);
+  checksum->kind = kind;
+  return checksum;
+}
+
+static svn_checksum_t *
+checksum_create(svn_checksum_kind_t kind,
+                apr_size_t digest_size,
+                const unsigned char *digest,
+                apr_pool_t *pool)
+{
+  svn_checksum_t *checksum = checksum_create_without_digest(kind, digest_size,
+                                                            pool);
+  memcpy((unsigned char *)checksum->digest, digest, digest_size);
+  return checksum;
+}
 
 svn_checksum_t *
 svn_checksum_create(svn_checksum_kind_t kind,
                     apr_pool_t *pool)
 {
   svn_checksum_t *checksum;
+  apr_size_t digest_size;
 
   switch (kind)
     {
       case svn_checksum_md5:
+        digest_size = APR_MD5_DIGESTSIZE;
+        break;
       case svn_checksum_sha1:
-        checksum = apr_pcalloc(pool, sizeof(*checksum) + DIGESTSIZE(kind));
-        checksum->digest = (unsigned char *)checksum + sizeof(*checksum);
-        checksum->kind = kind;
-        return checksum;
-
+        digest_size = APR_SHA1_DIGESTSIZE;
+        break;
       default:
         return NULL;
     }
+
+  checksum = checksum_create_without_digest(kind, digest_size, pool);
+  memset((unsigned char *) checksum->digest, 0, digest_size);
+  return checksum;
 }
 
 svn_checksum_t *
-svn_checksum__from_digest(const unsigned char *digest,
-                          svn_checksum_kind_t kind,
-                          apr_pool_t *result_pool)
+svn_checksum__from_digest_md5(const unsigned char *digest,
+                              apr_pool_t *result_pool)
 {
-  svn_checksum_t *checksum = svn_checksum_create(kind, result_pool);
+  return checksum_create(svn_checksum_md5, APR_MD5_DIGESTSIZE, digest,
+                         result_pool);
+}
 
-  memcpy((unsigned char *)checksum->digest, digest, DIGESTSIZE(kind));
-  return checksum;
+svn_checksum_t *
+svn_checksum__from_digest_sha1(const unsigned char *digest,
+                               apr_pool_t *result_pool)
+{
+  return checksum_create(svn_checksum_sha1, APR_SHA1_DIGESTSIZE, digest,
+                         result_pool);
 }
 
 svn_error_t *
@@ -160,6 +197,8 @@ svn_checksum_serialize(const svn_checksu
 {
   const char *ckind_str;
 
+  SVN_ERR_ASSERT_NO_RETURN(checksum->kind == svn_checksum_md5
+                           || checksum->kind == svn_checksum_sha1);
   ckind_str = (checksum->kind == svn_checksum_md5 ? "$md5 $" : "$sha1$");
   return apr_pstrcat(result_pool,
                      ckind_str,
@@ -237,8 +276,8 @@ svn_checksum_parse_hex(svn_checksum_t **
       if (x1 == (char)-1 || x2 == (char)-1)
         return svn_error_create(SVN_ERR_BAD_CHECKSUM_PARSE, NULL, NULL);
 
-      digest[i] = (x1 << 4) | x2;
-      is_nonzero |= (x1 << 4) | x2;
+      digest[i] = (char)((x1 << 4) | x2);
+      is_nonzero |= (char)((x1 << 4) | x2);
     }
 
   if (!is_nonzero)
@@ -255,7 +294,23 @@ svn_checksum_dup(const svn_checksum_t *c
   if (checksum == NULL)
     return NULL;
 
-  return svn_checksum__from_digest(checksum->digest, checksum->kind, pool);
+  /* Without this check on valid checksum kind a NULL svn_checksum_t
+   * pointer is returned which could cause a core dump at an
+   * indeterminate time in the future because callers are not
+   * expecting a NULL pointer.  This commit forces an early abort() so
+   * it's easier to track down where the issue arose. */
+  switch (checksum->kind)
+    {
+      case svn_checksum_md5:
+        return svn_checksum__from_digest_md5(checksum->digest, pool);
+        break;
+      case svn_checksum_sha1:
+        return svn_checksum__from_digest_sha1(checksum->digest, pool);
+        break;
+      default:
+        SVN_ERR_MALFUNCTION_NO_RETURN();
+        break;
+    }
 }
 
 svn_error_t *
@@ -295,24 +350,20 @@ svn_checksum_t *
 svn_checksum_empty_checksum(svn_checksum_kind_t kind,
                             apr_pool_t *pool)
 {
-  const unsigned char *digest;
-
   switch (kind)
     {
       case svn_checksum_md5:
-        digest = svn_md5__empty_string_digest();
-        break;
+        return svn_checksum__from_digest_md5(svn_md5__empty_string_digest(),
+                                             pool);
 
       case svn_checksum_sha1:
-        digest = svn_sha1__empty_string_digest();
-        break;
+        return svn_checksum__from_digest_sha1(svn_sha1__empty_string_digest(),
+                                              pool);
 
       default:
         /* We really shouldn't get here, but if we do... */
-        return NULL;
+        SVN_ERR_MALFUNCTION_NO_RETURN();
     }
-
-  return svn_checksum__from_digest(digest, kind, pool);
 }
 
 struct svn_checksum_ctx_t
@@ -341,7 +392,7 @@ svn_checksum_ctx_create(svn_checksum_kin
         break;
 
       default:
-        return NULL;
+        SVN_ERR_MALFUNCTION_NO_RETURN();
     }
 
   return ctx;
@@ -444,6 +495,6 @@ svn_checksum_is_empty_checksum(svn_check
 
       default:
         /* We really shouldn't get here, but if we do... */
-        return FALSE;
+        SVN_ERR_MALFUNCTION_NO_RETURN();
     }
 }

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/config.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/config.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/config.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/config.c Wed Jun 27 15:12:37 2012
@@ -562,6 +562,7 @@ svn_config_get(svn_config_t *cfg, const 
                const char *section, const char *option,
                const char *default_value)
 {
+  *valuep = default_value;
   if (cfg)
     {
       cfg_section_t *sec;
@@ -571,23 +572,21 @@ svn_config_get(svn_config_t *cfg, const 
           make_string_from_option(valuep, cfg, sec, opt, NULL);
         }
       else
-        {
-          apr_pool_t *tmp_pool = svn_pool_create(cfg->x_pool);
-          const char *x_default;
-          expand_option_value(cfg, sec, default_value, &x_default, tmp_pool);
-          if (x_default)
-            {
-              svn_stringbuf_set(cfg->tmp_value, x_default);
-              *valuep = cfg->tmp_value->data;
-            }
-          else
-            *valuep = default_value;
-          svn_pool_destroy(tmp_pool);
-        }
-    }
-  else
-    {
-      *valuep = default_value;
+        /* before attempting to expand an option, check for the placeholder.
+         * If none is there, there is no point in calling expand_option_value.
+         */
+        if (default_value && strchr(default_value, '%'))
+          {
+            apr_pool_t *tmp_pool = svn_pool_create(cfg->x_pool);
+            const char *x_default;
+            expand_option_value(cfg, sec, default_value, &x_default, tmp_pool);
+            if (x_default)
+              {
+                svn_stringbuf_set(cfg->tmp_value, x_default);
+                *valuep = cfg->tmp_value->data;
+              }
+            svn_pool_destroy(tmp_pool);
+          }
     }
 }
 

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/config_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/config_file.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/config_file.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/config_file.c Wed Jun 27 15:12:37 2012
@@ -60,15 +60,19 @@ typedef struct parse_context_t
   /* The current line in the file */
   int line;
 
-  /* Cached ungotten character  - streams don't support ungetc()
-     [emulate it] */
+  /* Emulate an ungetc */
   int ungotten_char;
-  svn_boolean_t have_ungotten_char;
 
-  /* Temporary strings, allocated from the temp pool */
+  /* Temporary strings */
   svn_stringbuf_t *section;
   svn_stringbuf_t *option;
   svn_stringbuf_t *value;
+
+  /* Parser buffer for getc() to avoid call overhead into several libraries
+     for every character */
+  char parser_buffer[SVN_STREAM_CHUNK_SIZE]; /* Larger than most config files */
+  size_t buffer_pos; /* Current position within parser_buffer */
+  size_t buffer_size; /* parser_buffer contains this many bytes */
 } parse_context_t;
 
 
@@ -82,27 +86,61 @@ typedef struct parse_context_t
 static APR_INLINE svn_error_t *
 parser_getc(parse_context_t *ctx, int *c)
 {
-  if (ctx->have_ungotten_char)
-    {
-      *c = ctx->ungotten_char;
-      ctx->have_ungotten_char = FALSE;
-    }
-  else
+  do
     {
-      char char_buf;
-      apr_size_t readlen = 1;
+      if (ctx->ungotten_char != EOF)
+        {
+          *c = ctx->ungotten_char;
+          ctx->ungotten_char = EOF;
+        }
+      else if (ctx->buffer_pos < ctx->buffer_size)
+        {
+          *c = ctx->parser_buffer[ctx->buffer_pos];
+          ctx->buffer_pos++;
+        }
+      else
+        {
+          ctx->buffer_pos = 0;
+          ctx->buffer_size = sizeof(ctx->parser_buffer);
 
-      SVN_ERR(svn_stream_read(ctx->stream, &char_buf, &readlen));
+          SVN_ERR(svn_stream_read(ctx->stream, ctx->parser_buffer,
+                                  &(ctx->buffer_size)));
 
-      if (readlen == 1)
-        *c = char_buf;
-      else
-        *c = EOF;
+          if (ctx->buffer_pos < ctx->buffer_size)
+            {
+              *c = ctx->parser_buffer[ctx->buffer_pos];
+              ctx->buffer_pos++;
+            }
+          else
+            *c = EOF;
+        }
     }
+  while (*c == '\r');
 
   return SVN_NO_ERROR;
 }
 
+/* Simplified version of parser_getc() to be used inside skipping loops.
+ * It will not check for 'ungotton' chars and may or may not ignore '\r'.
+ *
+ * In a 'while(cond) getc();' loop, the first iteration must call
+ * parser_getc to handle all the special cases.  Later iterations should
+ * use parser_getc_plain for maximum performance.
+ */
+static APR_INLINE svn_error_t *
+parser_getc_plain(parse_context_t *ctx, int *c)
+{
+  if (ctx->buffer_pos < ctx->buffer_size)
+    {
+      *c = ctx->parser_buffer[ctx->buffer_pos];
+      ctx->buffer_pos++;
+
+      return SVN_NO_ERROR;
+    }
+
+  return parser_getc(ctx, c);
+}
+
 /* Emulate ungetc() because streams don't support it.
  *
  * Use CTX to store the ungotten character C.
@@ -111,7 +149,6 @@ static APR_INLINE svn_error_t *
 parser_ungetc(parse_context_t *ctx, int c)
 {
   ctx->ungotten_char = c;
-  ctx->have_ungotten_char = TRUE;
 
   return SVN_NO_ERROR;
 }
@@ -123,14 +160,14 @@ parser_ungetc(parse_context_t *ctx, int 
 static APR_INLINE svn_error_t *
 skip_whitespace(parse_context_t *ctx, int *c, int *pcount)
 {
-  int ch;
+  int ch = 0;
   int count = 0;
 
   SVN_ERR(parser_getc(ctx, &ch));
-  while (ch != EOF && ch != '\n' && svn_ctype_isspace(ch))
+  while (svn_ctype_isspace(ch) && ch != '\n' && ch != EOF)
     {
       ++count;
-      SVN_ERR(parser_getc(ctx, &ch));
+      SVN_ERR(parser_getc_plain(ctx, &ch));
     }
   *pcount = count;
   *c = ch;
@@ -146,8 +183,8 @@ skip_to_eoln(parse_context_t *ctx, int *
   int ch;
 
   SVN_ERR(parser_getc(ctx, &ch));
-  while (ch != EOF && ch != '\n')
-    SVN_ERR(parser_getc(ctx, &ch));
+  while (ch != '\n' && ch != EOF)
+    SVN_ERR(parser_getc_plain(ctx, &ch));
 
   *c = ch;
   return SVN_NO_ERROR;
@@ -241,7 +278,7 @@ parse_value(int *pch, parse_context_t *c
 
 /* Parse a single option */
 static svn_error_t *
-parse_option(int *pch, parse_context_t *ctx, apr_pool_t *pool)
+parse_option(int *pch, parse_context_t *ctx, apr_pool_t *scratch_pool)
 {
   svn_error_t *err = SVN_NO_ERROR;
   int ch;
@@ -260,7 +297,7 @@ parse_option(int *pch, parse_context_t *
       ch = EOF;
       err = svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                               "%s:%d: Option must end with ':' or '='",
-                              svn_dirent_local_style(ctx->file, pool),
+                              svn_dirent_local_style(ctx->file, scratch_pool),
                               ctx->line);
     }
   else
@@ -284,7 +321,8 @@ parse_option(int *pch, parse_context_t *
  * starts a section name.
  */
 static svn_error_t *
-parse_section_name(int *pch, parse_context_t *ctx, apr_pool_t *pool)
+parse_section_name(int *pch, parse_context_t *ctx,
+                   apr_pool_t *scratch_pool)
 {
   svn_error_t *err = SVN_NO_ERROR;
   int ch;
@@ -303,7 +341,7 @@ parse_section_name(int *pch, parse_conte
       ch = EOF;
       err = svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                               "%s:%d: Section header must end with ']'",
-                              svn_dirent_local_style(ctx->file, pool),
+                              svn_dirent_local_style(ctx->file, scratch_pool),
                               ctx->line);
     }
   else
@@ -363,91 +401,101 @@ svn_config__sys_config_path(const char *
 
 svn_error_t *
 svn_config__parse_file(svn_config_t *cfg, const char *file,
-                       svn_boolean_t must_exist, apr_pool_t *pool)
+                       svn_boolean_t must_exist, apr_pool_t *result_pool)
 {
   svn_error_t *err = SVN_NO_ERROR;
-  parse_context_t ctx;
+  parse_context_t *ctx;
   int ch, count;
   svn_stream_t *stream;
+  apr_pool_t *scratch_pool = svn_pool_create(result_pool);
 
-  err = svn_stream_open_readonly(&stream, file, pool, pool);
+  err = svn_stream_open_readonly(&stream, file, scratch_pool, scratch_pool);
 
   if (! must_exist && err && APR_STATUS_IS_ENOENT(err->apr_err))
     {
       svn_error_clear(err);
+      svn_pool_destroy(scratch_pool);
       return SVN_NO_ERROR;
     }
   else
     SVN_ERR(err);
 
-  ctx.cfg = cfg;
-  ctx.file = file;
-  ctx.stream = svn_subst_stream_translated(stream, "\n", TRUE, NULL, FALSE,
-                                           pool);
-  ctx.line = 1;
-  ctx.have_ungotten_char = FALSE;
-  ctx.section = svn_stringbuf_create_empty(pool);
-  ctx.option = svn_stringbuf_create_empty(pool);
-  ctx.value = svn_stringbuf_create_empty(pool);
+  ctx = apr_palloc(scratch_pool, sizeof(*ctx));
+
+  ctx->cfg = cfg;
+  ctx->file = file;
+  ctx->stream = stream;
+  ctx->line = 1;
+  ctx->ungotten_char = EOF;
+  ctx->section = svn_stringbuf_create_empty(scratch_pool);
+  ctx->option = svn_stringbuf_create_empty(scratch_pool);
+  ctx->value = svn_stringbuf_create_empty(scratch_pool);
+  ctx->buffer_pos = 0;
+  ctx->buffer_size = 0;
 
   do
     {
-      SVN_ERR(skip_whitespace(&ctx, &ch, &count));
+      SVN_ERR(skip_whitespace(ctx, &ch, &count));
 
       switch (ch)
         {
         case '[':               /* Start of section header */
           if (count == 0)
-            SVN_ERR(parse_section_name(&ch, &ctx, pool));
+            SVN_ERR(parse_section_name(&ch, ctx, scratch_pool));
           else
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Section header"
                                      " must start in the first column",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           break;
 
         case '#':               /* Comment */
           if (count == 0)
             {
-              SVN_ERR(skip_to_eoln(&ctx, &ch));
-              ++ctx.line;
+              SVN_ERR(skip_to_eoln(ctx, &ch));
+              ++(ctx->line);
             }
           else
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Comment"
                                      " must start in the first column",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           break;
 
         case '\n':              /* Empty line */
-          ++ctx.line;
+          ++(ctx->line);
           break;
 
         case EOF:               /* End of file or read error */
           break;
 
         default:
-          if (svn_stringbuf_isempty(ctx.section))
+          if (svn_stringbuf_isempty(ctx->section))
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Section header expected",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           else if (count != 0)
             return svn_error_createf(SVN_ERR_MALFORMED_FILE, NULL,
                                      "%s:%d: Option expected",
-                                     svn_dirent_local_style(file, pool),
-                                     ctx.line);
+                                     svn_dirent_local_style(file,
+                                                            scratch_pool),
+                                     ctx->line);
           else
-            SVN_ERR(parse_option(&ch, &ctx, pool));
+            SVN_ERR(parse_option(&ch, ctx, scratch_pool));
           break;
         }
     }
   while (ch != EOF);
 
   /* Close the streams (and other cleanup): */
-  return svn_stream_close(ctx.stream);
+  svn_pool_destroy(scratch_pool);
+  return SVN_NO_ERROR;
 }
 
 
@@ -750,9 +798,6 @@ svn_config_ensure(const char *config_dir
                                                                              NL
         "###   http-compression           Whether to compress HTTP requests" NL
         "###   neon-debug-mask            Debug mask for Neon HTTP library"  NL
-#ifdef SVN_NEON_0_26
-        "###   http-auth-types            Auth types to use for HTTP library"NL
-#endif
         "###   ssl-authority-files        List of files, each of a trusted CA"
                                                                              NL
         "###   ssl-trust-default-ca       Trust the system 'default' CAs"    NL
@@ -762,7 +807,7 @@ svn_config_ensure(const char *config_dir
         "###   ssl-pkcs11-provider        Name of PKCS#11 provider to use."  NL
         "###   http-library               Which library to use for http/https"
                                                                              NL
-        "###                              connections (neon or serf)"        NL
+        "###                              connections."                      NL
         "###   store-passwords            Specifies whether passwords used"  NL
         "###                              to authenticate against a"         NL
         "###                              Subversion server may be cached"   NL
@@ -840,6 +885,13 @@ svn_config_ensure(const char *config_dir
         "### HTTP timeouts, if given, are specified in seconds.  A timeout"  NL
         "### of 0, i.e. zero, causes a builtin default to be used."          NL
         "###"                                                                NL
+        "### Most users will not need to explicitly set the http-library"    NL
+        "### option, but valid values for the option include:"               NL
+        "###    'serf': Serf-based module (Subversion 1.5 - present)"        NL
+        "###    'neon': Neon-based module (Subversion 1.0 - 1.7)"            NL
+        "### Availability of these modules may depend on your specific"      NL
+        "### Subversion distribution."                                       NL
+        "###"                                                                NL
         "### The commented-out examples below are intended only to"          NL
         "### demonstrate how to use this file; any resemblance to actual"    NL
         "### servers, living or dead, is entirely coincidental."             NL
@@ -861,9 +913,6 @@ svn_config_ensure(const char *config_dir
         "# http-proxy-username = blah"                                       NL
         "# http-proxy-password = doubleblah"                                 NL
         "# http-timeout = 60"                                                NL
-#ifdef SVN_NEON_0_26
-        "# http-auth-types = basic;digest;negotiate"                         NL
-#endif
         "# neon-debug-mask = 130"                                            NL
 #ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE
         "# store-plaintext-passwords = no"                                   NL
@@ -904,9 +953,6 @@ svn_config_ensure(const char *config_dir
         "# http-proxy-username = defaultusername"                            NL
         "# http-proxy-password = defaultpassword"                            NL
         "# http-compression = no"                                            NL
-#ifdef SVN_NEON_0_26
-        "# http-auth-types = basic;digest;negotiate"                         NL
-#endif
         "# No http-timeout, so just use the builtin default."                NL
         "# No neon-debug-mask, so neon debugging is disabled."               NL
         "# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem"   NL

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.c Wed Jun 27 15:12:37 2012
@@ -209,7 +209,7 @@ svn_crypto__context_create(svn_crypto__c
   CRYPTO_INIT(result_pool);
 
   /* Load the crypto driver.
- 
+
      ### TODO: For the sake of flexibility, should we use
      ### APU_CRYPTO_RECOMMENDED_DRIVER instead of hard coding
      ### "openssl" here?
@@ -334,12 +334,12 @@ svn_crypto__encrypt_password(const svn_s
       memcpy(assembled, prefix, RANDOM_PREFIX_LEN);
       memcpy(assembled + RANDOM_PREFIX_LEN, password, password_len);
       *(assembled + RANDOM_PREFIX_LEN + password_len) = '\0';
-      memcpy(assembled + RANDOM_PREFIX_LEN + password_len + 1, 
+      memcpy(assembled + RANDOM_PREFIX_LEN + password_len + 1,
              padding, pad_len);
-    }      
-    
+    }
+
   /* Get the length that we need to allocate.  */
-  apr_err = apr_crypto_block_encrypt(NULL, &result_len, assembled, 
+  apr_err = apr_crypto_block_encrypt(NULL, &result_len, assembled,
                                      assembled_len, block_ctx);
   if (apr_err != APR_SUCCESS)
     {
@@ -426,7 +426,7 @@ svn_crypto__decrypt_password(const char 
   if (iv_len != iv->len)
     return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
                             _("Provided IV has incorrect length"));
-  
+
   apr_err = apr_crypto_block_decrypt_init(&block_ctx, &block_size,
                                           (unsigned char *)iv->data,
                                           key, scratch_pool);
@@ -648,7 +648,7 @@ svn_crypto__verify_secret(svn_boolean_t 
   if (iv_len != iv->len)
     return svn_error_create(SVN_ERR_INCORRECT_PARAMS, NULL,
                             _("Provided IV has incorrect length"));
-  
+
   apr_err = apr_crypto_block_decrypt_init(&block_ctx, &block_size,
                                           (unsigned char *)iv->data,
                                           key, scratch_pool);

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.h
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.h?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.h (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/crypto.h Wed Jun 27 15:12:37 2012
@@ -26,10 +26,10 @@
 
 /* Test for APR crypto and RNG support */
 #undef SVN_HAVE_CRYPTO
-#include <apr.h> /* for APR_HAS_RANDOM */
-#include <apu.h> /* for APU_HAVE_CRYPTO */
+#include <apr.h>
+#include <apu.h>
 #if APR_HAS_RANDOM
-#if APU_HAVE_CRYPTO
+#if defined(APU_HAVE_CRYPTO) && APU_HAVE_CRYPTO
 #define SVN_HAVE_CRYPTO
 #endif
 #endif

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/dirent_uri.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/dirent_uri.c Wed Jun 27 15:12:37 2012
@@ -104,7 +104,7 @@ canonicalize_to_lower(char c)
   if (c < 'A' || c > 'Z')
     return c;
   else
-    return c - 'A' + 'a';
+    return (char)(c - 'A' + 'a');
 }
 
 /* Locale insensitive toupper() for converting parts of dirents and urls
@@ -115,7 +115,7 @@ canonicalize_to_upper(char c)
   if (c < 'a' || c > 'z')
     return c;
   else
-    return c - 'a' + 'A';
+    return (char)(c - 'a' + 'A');
 }
 
 /* Calculates the length of the dirent absolute or non absolute root in

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/error.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/error.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/error.c Wed Jun 27 15:12:37 2012
@@ -218,6 +218,28 @@ svn_error_quick_wrap(svn_error_t *child,
 
 
 svn_error_t *
+svn_error__trace(const char *file, long line, svn_error_t *err)
+{
+#ifndef SVN_DEBUG
+
+  /* We shouldn't even be here, but whatever. Just return the error as-is.  */
+  return err;
+
+#else
+
+  /* Only do the work when an error occurs.  */
+  if (err)
+    {
+      svn_error__locate(file, line);
+      return svn_error_quick_wrap(err, SVN_ERR__TRACED);
+    }
+  return SVN_NO_ERROR;
+
+#endif
+}
+
+
+svn_error_t *
 svn_error_compose_create(svn_error_t *err1,
                          svn_error_t *err2)
 {

Propchange: subversion/branches/master-passphrase/subversion/libsvn_subr/gpg_agent.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/hash.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/hash.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/hash.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/hash.c Wed Jun 27 15:12:37 2012
@@ -40,6 +40,7 @@
 #include "svn_pools.h"
 
 #include "private/svn_dep_compat.h"
+#include "private/svn_subr_private.h"
 
 #include "svn_private_config.h"
 
@@ -237,7 +238,7 @@ hash_write(apr_hash_t *hash, apr_hash_t 
                                 valstr->len));
       len = valstr->len;
       SVN_ERR(svn_stream_write(stream, valstr->data, &len));
-      SVN_ERR(svn_stream_printf(stream, subpool, "\n"));
+      SVN_ERR(svn_stream_puts(stream, "\n"));
     }
 
   if (oldhash)
@@ -495,7 +496,7 @@ svn_hash_from_cstring_keys(apr_hash_t **
                            apr_pool_t *pool)
 {
   int i;
-  apr_hash_t *hash = apr_hash_make(pool);
+  apr_hash_t *hash = svn_hash__make(pool);
   for (i = 0; i < keys->nelts; i++)
     {
       const char *key =
@@ -560,3 +561,71 @@ svn_hash__get_bool(apr_hash_t *hash, con
   return default_value;
 }
 
+
+
+/*** Optimized hash function ***/
+
+/* Optimized version of apr_hashfunc_default in APR 1.4.5 and earlier.
+ * It assumes that the CPU has 32-bit multiplications with high throughput
+ * of at least 1 operation every 3 cycles. Latency is not an issue. Another
+ * optimization is a mildly unrolled main loop and breaking the dependency
+ * chain within the loop.
+ *
+ * Note that most CPUs including Intel Atom, VIA Nano, ARM feature the
+ * assumed pipelined multiplication circuitry. They can do one MUL every
+ * or every other cycle.
+ *
+ * The performance is ultimately limited by the fact that most CPUs can
+ * do only one LOAD and only one BRANCH operation per cycle. The best we
+ * can do is to process one character per cycle - provided the processor
+ * is wide enough to do 1 LOAD, COMPARE, BRANCH, MUL and ADD per cycle.
+ */
+static unsigned int
+hashfunc_compatible(const char *char_key, apr_ssize_t *klen)
+{
+    unsigned int hash = 0;
+    const unsigned char *key = (const unsigned char *)char_key;
+    const unsigned char *p;
+    apr_ssize_t i;
+
+    if (*klen == APR_HASH_KEY_STRING)
+      {
+        for (p = key; ; p+=4)
+          {
+            unsigned int new_hash = hash * 33 * 33 * 33 * 33;
+            if (!p[0]) break;
+            new_hash += p[0] * 33 * 33 * 33;
+            if (!p[1]) break;
+            new_hash += p[1] * 33 * 33;
+            if (!p[2]) break;
+            new_hash += p[2] * 33;
+            if (!p[3]) break;
+            hash = new_hash + p[3];
+          }
+        for (; *p; p++)
+            hash = hash * 33 + *p;
+
+        *klen = p - key;
+      }
+    else
+      {
+        for (p = key, i = *klen; i >= 4; i-=4, p+=4)
+          {
+            hash = hash * 33 * 33 * 33 * 33
+                 + p[0] * 33 * 33 * 33
+                 + p[1] * 33 * 33
+                 + p[2] * 33
+                 + p[3];
+          }
+        for (; i; i--, p++)
+            hash = hash * 33 + *p;
+      }
+
+    return hash;
+}
+
+apr_hash_t *
+svn_hash__make(apr_pool_t *pool)
+{
+  return apr_hash_make_custom(pool, hashfunc_compatible);
+}

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/internal_statements.sql
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/internal_statements.sql?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/internal_statements.sql (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/internal_statements.sql Wed Jun 27 15:12:37 2012
@@ -21,5 +21,27 @@
  * ====================================================================
  */
 
--- STMT_DUMMY_SELECT_FOR_BACKUP
-SELECT * FROM SQLITE_MASTER;
+-- STMT_INTERNAL_SAVEPOINT_SVN
+SAVEPOINT svn
+
+-- STMT_INTERNAL_RELEASE_SAVEPOINT_SVN
+RELEASE SAVEPOINT svn
+
+-- STMT_INTERNAL_ROLLBACK_TO_SAVEPOINT_SVN
+ROLLBACK TO SAVEPOINT svn
+
+-- STMT_INTERNAL_BEGIN_TRANSACTION
+BEGIN TRANSACTION
+
+-- STMT_INTERNAL_BEGIN_IMMEDIATE_TRANSACTION
+BEGIN IMMEDIATE TRANSACTION
+
+-- STMT_INTERNAL_COMMIT_TRANSACTION
+COMMIT TRANSACTION
+
+-- STMT_INTERNAL_ROLLBACK_TRANSACTION
+ROLLBACK TRANSACTION
+
+/* Dummmy statement to determine the number of internal statements */
+-- STMT_INTERNAL_LAST
+;

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/io.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/io.c Wed Jun 27 15:12:37 2012
@@ -168,6 +168,41 @@ cstring_from_utf8(const char **path_apr,
 #endif
 }
 
+/* Helper function that allows to convert an APR-level PATH to something
+ * that we can pass the svn_error_wrap_apr. Since we use it in context
+ * of error reporting, having *some* path info may be more useful than
+ * having none.  Therefore, we use a best effort approach here.
+ *
+ * This is different from svn_io_file_name_get in that it uses a different
+ * signature style and will never fail.
+ */
+static const char *
+try_utf8_from_internal_style(const char *path, apr_pool_t *pool)
+{
+  svn_error_t *error;
+  const char *path_utf8;
+
+  /* Special case. */
+  if (path == NULL)
+    return "(NULL)";
+  
+  /* (try to) convert PATH to UTF-8. If that fails, continue with the plain
+   * PATH because it is the best we have. It may actually be UTF-8 already.
+   */
+  error = cstring_to_utf8(&path_utf8, path, pool);
+  if (error)
+    {
+      /* fallback to best representation we have */
+
+      svn_error_clear(error);
+      path_utf8 = path;
+    }
+
+  /* Toggle (back-)slashes etc. as necessary.
+   */
+  return svn_dirent_local_style(path_utf8, pool);
+}
+
 
 /* Set *NAME_P to the UTF-8 representation of directory entry NAME.
  * NAME is in the internal encoding used by APR; PARENT is in
@@ -193,6 +228,10 @@ entry_name_to_utf8(const char **name_p,
                    const char *parent,
                    apr_pool_t *pool)
 {
+#if defined(WIN32) || defined(DARWIN)
+  *name_p = apr_pstrdup(pool, name);
+  return SVN_NO_ERROR;
+#else
   svn_error_t *err = svn_path_cstring_to_utf8(name_p, name, pool);
   if (err && err->apr_err == APR_EINVAL)
     {
@@ -202,6 +241,7 @@ entry_name_to_utf8(const char **name_p,
                                svn_dirent_local_style(parent, pool));
     }
   return err;
+#endif
 }
 
 
@@ -851,10 +891,10 @@ file_perms_set(const char *fname, apr_fi
 
 /* Set permissions PERMS on the FILE. This is a cheaper variant of the
  * file_perms_set wrapper() function because no locale-dependent string
- * conversion is required.
+ * conversion is required. POOL will be used for allocations.
  */
 static svn_error_t *
-file_perms_set2(apr_file_t* file, apr_fileperms_t perms)
+file_perms_set2(apr_file_t* file, apr_fileperms_t perms, apr_pool_t *pool)
 {
   const char *fname_apr;
   apr_status_t status;
@@ -866,7 +906,7 @@ file_perms_set2(apr_file_t* file, apr_fi
   status = apr_file_perms_set(fname_apr, perms);
   if (status)
     return svn_error_wrap_apr(status, _("Can't set permissions on '%s'"),
-                              fname_apr);
+                              try_utf8_from_internal_style(fname_apr, pool));
   else
     return SVN_NO_ERROR;
 }
@@ -1351,28 +1391,32 @@ get_default_file_perms(apr_fileperms_t *
     {
       apr_finfo_t finfo;
       apr_file_t *fd;
+      const char *fname_base, *fname;
+      apr_uint32_t randomish;
+      svn_error_t *err;
 
       /* Get the perms for a newly created file to find out what bits
         should be set.
 
-        Normally del_on_close can be problematic because APR might
-        delete the file if we spawned any child processes. In this
-        case, the lifetime of this file handle is about 3 lines of
-        code, so we can safely use del_on_close here.
-
-        Not so fast! If some other thread forks off a child, then the
-        APR cleanups run, and the file will disappear. So use
-        del_on_pool_cleanup instead.
+        Explictly delete the file because we want this file to be as
+        short-lived as possible since its presence means other
+        processes may have to try multiple names.
 
         Using svn_io_open_uniquely_named() here because other tempfile
         creation functions tweak the permission bits of files they create.
       */
-      SVN_ERR(svn_io_open_uniquely_named(&fd, NULL, NULL, "default-perms", NULL,
-                                         svn_io_file_del_on_pool_cleanup,
-                                         scratch_pool, scratch_pool));
-      SVN_ERR(svn_io_file_info_get(&finfo, APR_FINFO_PROT, fd, scratch_pool));
-      SVN_ERR(svn_io_file_close(fd, scratch_pool));
+      randomish = ((apr_uint32_t)(apr_uintptr_t)scratch_pool
+                   + (apr_uint32_t)apr_time_now());
+      fname_base = apr_psprintf(scratch_pool, "svn-%08x", randomish);
 
+      SVN_ERR(svn_io_open_uniquely_named(&fd, &fname, NULL, fname_base,
+                                         NULL, svn_io_file_del_none,
+                                         scratch_pool, scratch_pool));
+      err = svn_io_file_info_get(&finfo, APR_FINFO_PROT, fd, scratch_pool);
+      err = svn_error_compose_create(err, svn_io_file_close(fd, scratch_pool));
+      err = svn_error_compose_create(err, svn_io_remove_file2(fname, TRUE,
+                                                              scratch_pool));
+      SVN_ERR(err);
       *perms = finfo.protection;
       default_perms = finfo.protection;
     }
@@ -1866,29 +1910,25 @@ file_clear_locks(void *arg)
 #endif
 
 svn_error_t *
-svn_io_file_lock2(const char *lock_file,
-                  svn_boolean_t exclusive,
-                  svn_boolean_t nonblocking,
-                  apr_pool_t *pool)
+svn_io_lock_open_file(apr_file_t *lockfile_handle,
+                      svn_boolean_t exclusive,
+                      svn_boolean_t nonblocking,
+                      apr_pool_t *pool)
 {
   int locktype = APR_FLOCK_SHARED;
-  apr_file_t *lockfile_handle;
-  apr_int32_t flags;
   apr_status_t apr_err;
+  const char *fname;
 
   if (exclusive)
     locktype = APR_FLOCK_EXCLUSIVE;
-
-  flags = APR_READ;
-  if (locktype == APR_FLOCK_EXCLUSIVE)
-    flags |= APR_WRITE;
-
   if (nonblocking)
     locktype |= APR_FLOCK_NONBLOCK;
 
-  SVN_ERR(svn_io_file_open(&lockfile_handle, lock_file, flags,
-                           APR_OS_DEFAULT,
-                           pool));
+  /* We need this only in case of an error but this is cheap to get -
+   * so we do it here for clarity. */
+  apr_err = apr_file_name_get(&fname, lockfile_handle);
+  if (apr_err)
+    return svn_error_wrap_apr(apr_err, _("Can't get file name"));
 
   /* Get lock on the filehandle. */
   apr_err = apr_file_lock(lockfile_handle, locktype);
@@ -1915,11 +1955,11 @@ svn_io_file_lock2(const char *lock_file,
         case APR_FLOCK_SHARED:
           return svn_error_wrap_apr(apr_err,
                                     _("Can't get shared lock on file '%s'"),
-                                    svn_dirent_local_style(lock_file, pool));
+                                    try_utf8_from_internal_style(fname, pool));
         case APR_FLOCK_EXCLUSIVE:
           return svn_error_wrap_apr(apr_err,
                                     _("Can't get exclusive lock on file '%s'"),
-                                    svn_dirent_local_style(lock_file, pool));
+                                    try_utf8_from_internal_style(fname, pool));
         default:
           SVN_ERR_MALFUNCTION();
         }
@@ -1936,6 +1976,62 @@ svn_io_file_lock2(const char *lock_file,
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_io_unlock_open_file(apr_file_t *lockfile_handle,
+                        apr_pool_t *pool)
+{
+  const char *fname;
+  apr_status_t apr_err;
+
+  /* We need this only in case of an error but this is cheap to get -
+   * so we do it here for clarity. */
+  apr_err = apr_file_name_get(&fname, lockfile_handle);
+  if (apr_err)
+    return svn_error_wrap_apr(apr_err, _("Can't get file name"));
+
+  /* The actual unlock attempt. */
+  apr_err = apr_file_unlock(lockfile_handle);
+  if (apr_err)
+    return svn_error_wrap_apr(apr_err, _("Can't unlock file '%s'"),
+                              try_utf8_from_internal_style(fname, pool));
+  
+/* On Windows and OS/2 file locks are automatically released when
+   the file handle closes */
+#if !defined(WIN32) && !defined(__OS2__)
+  apr_pool_cleanup_kill(pool, lockfile_handle, file_clear_locks);
+#endif
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_io_file_lock2(const char *lock_file,
+                  svn_boolean_t exclusive,
+                  svn_boolean_t nonblocking,
+                  apr_pool_t *pool)
+{
+  int locktype = APR_FLOCK_SHARED;
+  apr_file_t *lockfile_handle;
+  apr_int32_t flags;
+
+  if (exclusive)
+    locktype = APR_FLOCK_EXCLUSIVE;
+
+  flags = APR_READ;
+  if (locktype == APR_FLOCK_EXCLUSIVE)
+    flags |= APR_WRITE;
+
+  if (nonblocking)
+    locktype |= APR_FLOCK_NONBLOCK;
+
+  SVN_ERR(svn_io_file_open(&lockfile_handle, lock_file, flags,
+                           APR_OS_DEFAULT,
+                           pool));
+
+  /* Get lock on the filehandle. */
+  return svn_io_lock_open_file(lockfile_handle, exclusive, nonblocking, pool);
+}
+
 
 
 /* Data consistency/coherency operations. */
@@ -2034,7 +2130,7 @@ stringbuf_from_aprfile(svn_stringbuf_t *
         {
           apr_finfo_t finfo;
           if (! (status = apr_stat(&finfo, filename, APR_FINFO_MIN, pool)))
-            res_initial_len = finfo.size;
+            res_initial_len = (apr_size_t)finfo.size;
         }
     }
 
@@ -3080,7 +3176,7 @@ do_io_file_wrapper_cleanup(apr_file_t *f
 
   if (name)
     return svn_error_wrap_apr(status, _(msg),
-                              svn_dirent_local_style(name, pool));
+                              try_utf8_from_internal_style(name, pool));
   else
     return svn_error_wrap_apr(status, "%s", _(msg_no_name));
 }
@@ -3089,33 +3185,30 @@ do_io_file_wrapper_cleanup(apr_file_t *f
 svn_error_t *
 svn_io_file_close(apr_file_t *file, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_close(file),
-     N_("Can't close file '%s'"),
-     N_("Can't close stream"),
-      pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_close(file),
+                                    N_("Can't close file '%s'"),
+                                    N_("Can't close stream"),
+                                    pool);
 }
 
 
 svn_error_t *
 svn_io_file_getc(char *ch, apr_file_t *file, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_getc(ch, file),
-     N_("Can't read file '%s'"),
-     N_("Can't read stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_getc(ch, file),
+                                    N_("Can't read file '%s'"),
+                                    N_("Can't read stream"),
+                                    pool);
 }
 
 
 svn_error_t *
 svn_io_file_putc(char ch, apr_file_t *file, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_putc(ch, file),
-     N_("Can't write file '%s'"),
-     N_("Can't write stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_putc(ch, file),
+                                    N_("Can't write file '%s'"),
+                                    N_("Can't write stream"),
+                                    pool);
 }
 
 
@@ -3126,11 +3219,11 @@ svn_io_file_info_get(apr_finfo_t *finfo,
   /* Quoting APR: On NT this request is incredibly expensive, but accurate. */
   wanted &= ~SVN__APR_FINFO_MASK_OUT;
 
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_info_get(finfo, wanted, file),
-     N_("Can't get attribute information from file '%s'"),
-     N_("Can't get attribute information from stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(
+             file, apr_file_info_get(finfo, wanted, file),
+             N_("Can't get attribute information from file '%s'"),
+             N_("Can't get attribute information from stream"),
+             pool);
 }
 
 
@@ -3138,11 +3231,10 @@ svn_error_t *
 svn_io_file_read(apr_file_t *file, void *buf,
                  apr_size_t *nbytes, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_read(file, buf, nbytes),
-     N_("Can't read file '%s'"),
-     N_("Can't read stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_read(file, buf, nbytes),
+                                    N_("Can't read file '%s'"),
+                                    N_("Can't read stream"),
+                                    pool);
 }
 
 
@@ -3164,11 +3256,10 @@ svn_io_file_read_full2(apr_file_t *file,
         *hit_eof = FALSE;
     }
 
-  return do_io_file_wrapper_cleanup
-    (file, status,
-     N_("Can't read file '%s'"),
-     N_("Can't read stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, status,
+                                    N_("Can't read file '%s'"),
+                                    N_("Can't read stream"),
+                                    pool);
 }
 
 
@@ -3176,11 +3267,11 @@ svn_error_t *
 svn_io_file_seek(apr_file_t *file, apr_seek_where_t where,
                  apr_off_t *offset, apr_pool_t *pool)
 {
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_seek(file, where, offset),
-     N_("Can't set position pointer in file '%s'"),
-     N_("Can't set position pointer in stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(
+             file, apr_file_seek(file, where, offset),
+             N_("Can't set position pointer in file '%s'"),
+             N_("Can't set position pointer in stream"),
+             pool);
 }
 
 
@@ -3283,17 +3374,15 @@ svn_io_file_trunc(apr_file_t *file, apr_
   /* This is a work-around. APR would flush the write buffer
      _after_ truncating the file causing now invalid buffered
      data to be written behind OFFSET. */
-  SVN_ERR(do_io_file_wrapper_cleanup
-    (file, apr_file_flush(file),
-     N_("Can't flush file '%s'"),
-     N_("Can't flush stream"),
-     pool));
+  SVN_ERR(do_io_file_wrapper_cleanup(file, apr_file_flush(file),
+                                     N_("Can't flush file '%s'"),
+                                     N_("Can't flush stream"),
+                                     pool));
 
-  return do_io_file_wrapper_cleanup
-    (file, apr_file_trunc(file, offset),
-     N_("Can't truncate file '%s'"),
-     N_("Can't truncate stream"),
-     pool);
+  return do_io_file_wrapper_cleanup(file, apr_file_trunc(file, offset),
+                                    N_("Can't truncate file '%s'"),
+                                    N_("Can't truncate stream"),
+                                    pool);
 }
 
 
@@ -3935,8 +4024,8 @@ contents_identical_p(svn_boolean_t *iden
   apr_size_t bytes_read1, bytes_read2;
   char *buf1 = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
   char *buf2 = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
-  apr_file_t *file1_h = NULL;
-  apr_file_t *file2_h = NULL;
+  apr_file_t *file1_h;
+  apr_file_t *file2_h;
   svn_boolean_t eof1 = FALSE;
   svn_boolean_t eof2 = FALSE;
 
@@ -3999,16 +4088,16 @@ svn_io_files_contents_same_p(svn_boolean
 
   if (q)
     {
-      *same = 0;
+      *same = FALSE;
       return SVN_NO_ERROR;
     }
 
   SVN_ERR(contents_identical_p(&q, file1, file2, pool));
 
   if (q)
-    *same = 1;
+    *same = TRUE;
   else
-    *same = 0;
+    *same = FALSE;
 
   return SVN_NO_ERROR;
 }
@@ -4245,7 +4334,7 @@ svn_io_open_unique_file3(apr_file_t **fi
   if (!using_system_temp_dir)
     {
       SVN_ERR(merge_default_file_perms(tempfile, &perms, scratch_pool));
-      SVN_ERR(file_perms_set2(tempfile, perms));
+      SVN_ERR(file_perms_set2(tempfile, perms, scratch_pool));
     }
 #endif
 

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/lock.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/lock.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/lock.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/lock.c Wed Jun 27 15:12:37 2012
@@ -54,8 +54,7 @@ svn_lock_dup(const svn_lock_t *lock, apr
   new_l->path = apr_pstrdup(pool, new_l->path);
   new_l->token = apr_pstrdup(pool, new_l->token);
   new_l->owner = apr_pstrdup(pool, new_l->owner);
-  if (new_l->comment)
-    new_l->comment = apr_pstrdup(pool, new_l->comment);
+  new_l->comment = apr_pstrdup(pool, new_l->comment);
 
   return new_l;
 }

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/mergeinfo.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/mergeinfo.c Wed Jun 27 15:12:37 2012
@@ -615,7 +615,7 @@ static svn_error_t *
 parse_revision_line(const char **input, const char *end, svn_mergeinfo_t hash,
                     apr_pool_t *scratch_pool)
 {
-  const char *pathname;
+  const char *pathname = "";
   apr_array_header_t *existing_rangelist;
   apr_array_header_t *rangelist = apr_array_make(scratch_pool, 1,
                                                  sizeof(svn_merge_range_t *));

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/opt.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/opt.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/opt.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/opt.c Wed Jun 27 15:12:37 2012
@@ -1041,6 +1041,20 @@ svn_opt__arg_canonicalize_url(const char
   /* Auto-escape some ASCII characters. */
   target = svn_path_uri_autoescape(target, pool);
 
+#if '/' != SVN_PATH_LOCAL_SEPARATOR
+  /* Allow using file:///C:\users\me/repos on Windows, like we did in 1.6 */
+  if (strchr(target, SVN_PATH_LOCAL_SEPARATOR))
+    {
+      char *p = apr_pstrdup(pool, target);
+      target = p;
+
+      /* Convert all local-style separators to the canonical ones. */
+      for (; *p != '\0'; ++p)
+        if (*p == SVN_PATH_LOCAL_SEPARATOR)
+          *p = '/';
+    }
+#endif
+
   /* Verify that no backpaths are present in the URL. */
   if (svn_path_is_backpath_present(target))
     return svn_error_createf(SVN_ERR_BAD_URL, 0,

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/path.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/path.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/path.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/path.c Wed Jun 27 15:12:37 2012
@@ -399,8 +399,8 @@ svn_path_compare_paths(const char *path1
   apr_size_t min_len = ((path1_len < path2_len) ? path1_len : path2_len);
   apr_size_t i = 0;
 
-  assert(is_canonical(path1, strlen(path1)));
-  assert(is_canonical(path2, strlen(path2)));
+  assert(is_canonical(path1, path1_len));
+  assert(is_canonical(path2, path2_len));
 
   /* Skip past common prefix. */
   while (i < min_len && path1[i] == path2[i])
@@ -1102,15 +1102,19 @@ svn_path_cstring_from_utf8(const char **
                            const char *path_utf8,
                            apr_pool_t *pool)
 {
+#if !defined(WIN32) && !defined(DARWIN)
   svn_boolean_t path_is_utf8;
   SVN_ERR(get_path_encoding(&path_is_utf8, pool));
   if (path_is_utf8)
+#endif
     {
       *path_apr = apr_pstrdup(pool, path_utf8);
       return SVN_NO_ERROR;
     }
+#if !defined(WIN32) && !defined(DARWIN)
   else
     return svn_utf_cstring_from_utf8(path_apr, path_utf8, pool);
+#endif
 }
 
 
@@ -1119,15 +1123,19 @@ svn_path_cstring_to_utf8(const char **pa
                          const char *path_apr,
                          apr_pool_t *pool)
 {
+#if !defined(WIN32) && !defined(DARWIN)
   svn_boolean_t path_is_utf8;
   SVN_ERR(get_path_encoding(&path_is_utf8, pool));
   if (path_is_utf8)
+#endif
     {
       *path_utf8 = apr_pstrdup(pool, path_apr);
       return SVN_NO_ERROR;
     }
+#if !defined(WIN32) && !defined(DARWIN)
   else
     return svn_utf_cstring_to_utf8(path_utf8, path_apr, pool);
+#endif
 }
 
 
@@ -1160,8 +1168,8 @@ illegal_path_escape(const char *path, ap
         svn_stringbuf_appendbytes(retstr, path + copied,
                                   i - copied);
 
-      /* Make sure buffer is big enough for '\' 'N' 'N' 'N' null */
-      svn_stringbuf_ensure(retstr, retstr->len + 5);
+      /* Make sure buffer is big enough for '\' 'N' 'N' 'N' (and NUL) */
+      svn_stringbuf_ensure(retstr, retstr->len + 4);
       /*### The backslash separator doesn't work too great with Windows,
          but it's what we'll use for consistency with invalid utf8
          formatting (until someone has a better idea) */

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/pool.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/pool.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/pool.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/pool.c Wed Jun 27 15:12:37 2012
@@ -28,6 +28,7 @@
 
 #include <apr_general.h>
 #include <apr_pools.h>
+#include <apr_thread_mutex.h>
 
 #include "svn_pools.h"
 
@@ -52,6 +53,7 @@ abort_on_pool_failure(int retcode)
      And we don't have any of it... */
   printf("Out of memory - terminating application.\n");
   abort();
+  return 0; /* not reached */
 }
 
 
@@ -97,3 +99,44 @@ svn_pool_create_ex(apr_pool_t *pool, apr
 }
 
 #endif /* APR_POOL_DEBUG */
+
+apr_allocator_t *
+svn_pool_create_allocator(svn_boolean_t thread_safe)
+{
+  apr_allocator_t *allocator;
+  apr_pool_t *pool;
+
+  /* create the allocator and limit it's internal free list to keep
+   * memory usage in check */
+
+  if (apr_allocator_create(&allocator))
+    abort_on_pool_failure(EXIT_FAILURE);
+
+  apr_allocator_max_free_set(allocator, SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
+
+  /* create the root pool */
+
+  pool = svn_pool_create_ex(NULL, allocator);
+  apr_allocator_owner_set(allocator, pool);
+
+#if APR_POOL_DEBUG
+  apr_pool_tag (pool, "svn root pool");
+#endif
+
+  /* By default, allocators are *not* thread-safe. We must provide a mutex
+   * if we want thread-safety for that mutex. */
+
+#if APR_HAS_THREADS
+  if (thread_safe)
+    {
+      apr_thread_mutex_t *mutex;
+      apr_thread_mutex_create (&mutex, APR_THREAD_MUTEX_DEFAULT, pool);
+      apr_allocator_mutex_set (allocator, mutex);
+    }
+#endif
+
+  /* better safe than sorry */
+  SVN_ERR_ASSERT_NO_RETURN(allocator != NULL);
+
+  return allocator;
+}

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/properties.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/properties.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/properties.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/properties.c Wed Jun 27 15:12:37 2012
@@ -122,7 +122,7 @@ svn_categorize_props(const apr_array_hea
       enum svn_prop_kind kind;
 
       prop = &APR_ARRAY_IDX(proplist, i, svn_prop_t);
-      kind = svn_property_kind(NULL, prop->name);
+      kind = svn_property_kind2(prop->name);
       newprop = NULL;
 
       if (kind == svn_prop_regular_kind)
@@ -305,7 +305,7 @@ svn_prop_hash_dup(apr_hash_t *hash,
       void *prop;
 
       apr_hash_this(hi, &key, &klen, &prop);
-      apr_hash_set(new_hash, apr_pstrdup(pool, key), klen,
+      apr_hash_set(new_hash, apr_pstrmemdup(pool, key, klen), klen,
                    svn_string_dup(prop, pool));
     }
   return new_hash;

Modified: subversion/branches/master-passphrase/subversion/libsvn_subr/quoprint.c
URL: http://svn.apache.org/viewvc/subversion/branches/master-passphrase/subversion/libsvn_subr/quoprint.c?rev=1354571&r1=1354570&r2=1354571&view=diff
==============================================================================
--- subversion/branches/master-passphrase/subversion/libsvn_subr/quoprint.c (original)
+++ subversion/branches/master-passphrase/subversion/libsvn_subr/quoprint.c Wed Jun 27 15:12:37 2012
@@ -233,7 +233,7 @@ decode_bytes(svn_stringbuf_t *str, const
           find2 = strchr(hextab, inbuf[2]);
           if (find1 != NULL && find2 != NULL)
             {
-              c = ((find1 - hextab) << 4) | (find2 - hextab);
+              c = (char)(((find1 - hextab) << 4) | (find2 - hextab));
               svn_stringbuf_appendbyte(str, c);
             }
           *inbuflen = 0;