Author: rhuijben
Date: Tue Apr  5 02:17:52 2011
New Revision: 1088849

URL: http://svn.apache.org/viewvc?rev=1088849&view=rev
Log:
Make sure we never retrieve APR_FINFO_PROT and APR_FINFO_OWNER on Windows by
masking out these flag. This contacts the domain controller for file ownership
while Subversion should never use this and rely on the file attributes
instead. Apr doesn't need a specific flag to retrieve the file attributes.

Create a few defines to document how you can retrieve executable and
read-only flags for all platforms.

* subversion/include/private/svn_io_private.h
  (SVN__APR_FINFO_EXECUTABLE,
   SVN__APR_FINFO_READONLY,
   SVN__APR_FINFO_MASK_OUT): New defines.

* subversion/libsvn_subr/io.c
  (svn_io_file_info_get, svn_io_stat, svn_io_dir_walk2):
    Mask out expensive flags.

* subversion/libsvn_wc/questions.c
  (svn_wc__internal_file_modified_p): Use the platform dependent flags for
    readonly and executable. Initialize some output variable on early exit.

Modified:
    subversion/trunk/subversion/include/private/svn_io_private.h
    subversion/trunk/subversion/libsvn_subr/io.c
    subversion/trunk/subversion/libsvn_wc/questions.c

Modified: subversion/trunk/subversion/include/private/svn_io_private.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_io_private.h?rev=1088849&r1=1088848&r2=1088849&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_io_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_io_private.h Tue Apr  5 
02:17:52 2011
@@ -33,6 +33,17 @@
 extern "C" {
 #endif /* __cplusplus */
 
+/* The flags to pass to apr_stat to check for executable and/or readonly */
+#if defined(WIN32) || defined(__OS2__)
+#define SVN__APR_FINFO_EXECUTABLE (0)
+#define SVN__APR_FINFO_READONLY (0)
+#define SVN__APR_FINFO_MASK_OUT (APR_FINFO_PROT | APR_FINFO_OWNER)
+#else
+#define SVN__APR_FINFO_EXECUTABLE (APR_FINFO_PROT)
+#define SVN__APR_FINFO_READONLY (APR_FINFO_PROT | APR_FINFO_OWNER)
+#define SVN__APR_FINFO_MASK_OUT (0)
+#endif
+
 
 /** Set @a *executable TRUE if @a file_info is executable for the
  * user, FALSE otherwise.

Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1088849&r1=1088848&r2=1088849&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Tue Apr  5 02:17:52 2011
@@ -3084,6 +3084,9 @@ svn_error_t *
 svn_io_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted,
                      apr_file_t *file, apr_pool_t *pool)
 {
+  /* 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'"),
@@ -3289,6 +3292,9 @@ svn_io_stat(apr_finfo_t *finfo, const ch
 
   SVN_ERR(cstring_from_utf8(&fname_apr, fname, pool));
 
+  /* Quoting APR: On NT this request is incredibly expensive, but accurate. */
+  wanted &= ~SVN__APR_FINFO_MASK_OUT;
+
   status = apr_stat(finfo, fname_apr, wanted, pool);
   if (status)
     return svn_error_wrap_apr(status, _("Can't stat '%s'"),
@@ -3579,6 +3585,9 @@ svn_io_dir_walk2(const char *dirname,
 
   wanted |= APR_FINFO_TYPE | APR_FINFO_NAME;
 
+  /* Quoting APR: On NT this request is incredibly expensive, but accurate. */
+  wanted &= ~SVN__APR_FINFO_MASK_OUT;
+
   /* The documentation for apr_dir_read used to state that "." and ".."
      will be returned as the first two files, but it doesn't
      work that way in practice, in particular ext3 on Linux-2.6 doesn't

Modified: subversion/trunk/subversion/libsvn_wc/questions.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/questions.c?rev=1088849&r1=1088848&r2=1088849&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/questions.c (original)
+++ subversion/trunk/subversion/libsvn_wc/questions.c Tue Apr  5 02:17:52 2011
@@ -274,9 +274,9 @@ svn_wc__internal_file_modified_p(svn_boo
     = APR_FINFO_SIZE | APR_FINFO_MTIME | APR_FINFO_TYPE | APR_FINFO_LINK;
 
   if (executable_p)
-    wanted |= APR_FINFO_PROT | APR_FINFO_OWNER;
+    wanted |= SVN__APR_FINFO_EXECUTABLE;
   if (read_only_p)
-    wanted |= APR_FINFO_PROT;
+    wanted |= SVN__APR_FINFO_READONLY;
 
   /* No matter which way you look at it, the file needs to exist. */
   err = svn_io_stat(&finfo, local_abspath, wanted, scratch_pool);
@@ -288,6 +288,11 @@ svn_wc__internal_file_modified_p(svn_boo
          So, it can't be modified. */
       svn_error_clear(err);
       *modified_p = FALSE;
+      if (executable_p)
+        *executable_p = FALSE;
+      if (read_only_p)
+        *read_only_p = FALSE;
+
       return SVN_NO_ERROR;
     }
   else if (err)


Reply via email to