You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2016/01/04 15:21:34 UTC

svn commit: r1722881 - /subversion/trunk/subversion/libsvn_subr/io.c

Author: stefan2
Date: Mon Jan  4 14:21:34 2016
New Revision: 1722881

URL: http://svn.apache.org/viewvc?rev=1722881&view=rev
Log:
Fix a minor inefficiency when generating a "random" file name.

* subversion/libsvn_subr/io.c
  (get_default_file_perms): Use more of the entropy that we are given.

Modified:
    subversion/trunk/subversion/libsvn_subr/io.c

Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1722881&r1=1722880&r2=1722881&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Mon Jan  4 14:21:34 2016
@@ -1568,8 +1568,14 @@ get_default_file_perms(apr_fileperms_t *
 
         Using svn_io_open_uniquely_named() here because other tempfile
         creation functions tweak the permission bits of files they create.
+
+        Note that APR pool structures are allocated as the first item
+        in their first memory page (with e.g. 4kB granularity), i.e. the
+        lower bits tend to be identical between pool instances.  That is
+        particularly true for the MMAPed allocator.
       */
       randomish = ((apr_uint32_t)(apr_uintptr_t)scratch_pool
+                   + (apr_uint32_t)((apr_uintptr_t)scratch_pool / 4096)
                    + (apr_uint32_t)apr_time_now());
       fname_base = apr_psprintf(scratch_pool, "svn-%08x", randomish);