You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/12/01 15:05:47 UTC
svn commit: r1546814 - in /subversion/trunk/subversion/libsvn_subr:
config_file.c config_impl.h config_win.c
Author: rhuijben
Date: Sun Dec 1 14:05:46 2013
New Revision: 1546814
URL: http://svn.apache.org/r1546814
Log:
Make Subversion a bit more friendly to use in very restricted Windows user
scenarios: fix usage of our libraries in environments without a user profile.
This avoids a 20-30 second delay for each invocation in this use case, where
we used to try creating a default config in a directory where we are not
allowed to write.
* subversion/libsvn_subr/config_file.c
(svn_config__sys_config_path): Update caller.
(svn_config_get_user_config_path): Handle no homedir on Windows, like on
other platforms.
* subversion/libsvn_subr/config_impl.h
(svn_config__win_config_path): Update prototype.
* subversion/libsvn_subr/config_win.c
(includes): Move include to start of file.
(svn_config__win_config_path): Update prototype. Verify if we have a real
profile. Properly canonicalize the returned path to our internal style.
(SVN_REG_DEFAULT_NAME_SIZE): Update outdated comment. I think we fixed our
stringbuffer class to work on any platform now.
Modified:
subversion/trunk/subversion/libsvn_subr/config_file.c
subversion/trunk/subversion/libsvn_subr/config_impl.h
subversion/trunk/subversion/libsvn_subr/config_win.c
Modified: subversion/trunk/subversion/libsvn_subr/config_file.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_file.c?rev=1546814&r1=1546813&r2=1546814&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/config_file.c (original)
+++ subversion/trunk/subversion/libsvn_subr/config_file.c Sun Dec 1 14:05:46 2013
@@ -412,7 +412,7 @@ svn_config__sys_config_path(const char *
#ifdef WIN32
{
const char *folder;
- SVN_ERR(svn_config__win_config_path(&folder, TRUE, pool));
+ SVN_ERR(svn_config__win_config_path(&folder, TRUE, pool, pool));
*path_p = svn_dirent_join_many(pool, folder,
SVN_CONFIG__SUBDIRECTORY, fname,
SVN_VA_NULL);
@@ -1370,7 +1370,11 @@ svn_config_get_user_config_path(const ch
#ifdef WIN32
{
const char *folder;
- SVN_ERR(svn_config__win_config_path(&folder, FALSE, pool));
+ SVN_ERR(svn_config__win_config_path(&folder, FALSE, pool, pool));
+
+ if (! folder)
+ return SVN_NO_ERROR;
+
*path = svn_dirent_join_many(pool, folder,
SVN_CONFIG__SUBDIRECTORY, fname, SVN_VA_NULL);
}
Modified: subversion/trunk/subversion/libsvn_subr/config_impl.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_impl.h?rev=1546814&r1=1546813&r2=1546814&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/config_impl.h (original)
+++ subversion/trunk/subversion/libsvn_subr/config_impl.h Sun Dec 1 14:05:46 2013
@@ -96,8 +96,9 @@ svn_error_t *svn_config__parse_stream(sv
#ifdef WIN32
/* Get the common or user-specific AppData folder */
svn_error_t *svn_config__win_config_path(const char **folder,
- int system_path,
- apr_pool_t *pool);
+ svn_boolean_t system_path,
+ apr_pool_t *scratch_pool,
+ apr_pool_t *result_pool);
/* Read sections and options from the Windows Registry. */
svn_error_t *svn_config__parse_registry(svn_config_t *cfg,
Modified: subversion/trunk/subversion/libsvn_subr/config_win.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_win.c?rev=1546814&r1=1546813&r2=1546814&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/config_win.c (original)
+++ subversion/trunk/subversion/libsvn_subr/config_win.c Sun Dec 1 14:05:46 2013
@@ -46,8 +46,12 @@
#include "svn_utf.h"
#include "private/svn_utf_private.h"
+#include "config_impl.h"
+
svn_error_t *
-svn_config__win_config_path(const char **folder, int system_path,
+svn_config__win_config_path(const char **folder,
+ svn_boolean_t system_path,
+ apr_pool_t *scratch_pool,
apr_pool_t *result_pool)
{
/* ### Adding CSIDL_FLAG_CREATE here, because those folders really
@@ -57,6 +61,30 @@ svn_config__win_config_path(const char *
| CSIDL_FLAG_CREATE);
WCHAR folder_ucs2[MAX_PATH];
+ const char *folder_utf8;
+
+ if (! system_path)
+ {
+ HKEY hkey_tmp;
+
+ /* Verify if we actually have a *per user* profile to read from */
+ if (ERROR_SUCCESS == RegOpenCurrentUser(KEY_SET_VALUE, &hkey_tmp))
+ RegCloseKey(hkey_tmp); /* We have a profile */
+ else
+ {
+ /* The user is not properly logged in. (Most likely we are running
+ in a service process). In this case Windows will return a default
+ read only 'roaming profile' directory, which we assume to be
+ writable. We will then spend many seconds trying to create a
+ configuration and then fail, because we are not allowed to write
+ there, but the retry loop in io.c doesn't know that.
+
+ We just answer that there is no user configuration directory. */
+
+ *folder = NULL;
+ return SVN_NO_ERROR;
+ }
+ }
if (S_OK != SHGetFolderPathW(NULL, csidl, NULL, SHGFP_TYPE_CURRENT,
folder_ucs2))
@@ -65,16 +93,17 @@ svn_config__win_config_path(const char *
? "Can't determine the system config path"
: "Can't determine the user's config path"));
- return svn_error_trace(svn_utf__win32_utf16_to_utf8(folder, folder_ucs2,
- NULL, result_pool));
+ SVN_ERR(svn_utf__win32_utf16_to_utf8(&folder_utf8, folder_ucs2,
+ NULL, scratch_pool));
+ *folder = svn_dirent_internal_style(folder_utf8, result_pool);
+
+ return SVN_NO_ERROR;
}
-#include "config_impl.h"
-/* ### These constants are insanely large, but (a) we want to avoid
- reallocating strings if possible, and (b) the realloc logic might
- not actually work -- you never know with Win32 ... */
+/* ### These constants are insanely large, but we want to avoid
+ reallocating strings if possible. */
#define SVN_REG_DEFAULT_NAME_SIZE 2048
#define SVN_REG_DEFAULT_VALUE_SIZE 8192