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 2010/07/20 17:44:53 UTC

svn commit: r965888 - in /subversion/branches/issue-2779-dev/subversion: include/svn_ra.h libsvn_client/ra.c libsvn_ra/ra_loader.c libsvn_ra_local/ra_plugin.c libsvn_ra_serf/serf.c libsvn_ra_svn/client.c

Author: cmpilato
Date: Tue Jul 20 15:44:53 2010
New Revision: 965888

URL: http://svn.apache.org/viewvc?rev=965888&view=rev
Log:
On the 'issue-2779-dev' branch:
Rework the svn_ra_open4() handling of 'corrected_URL' to allow the
lowest levels of the RA implementations to provide the most precise
error messages possible.

* subversion/libsvn_ra_local/ra_plugin.c
  (svn_ra_local__open): Avoid dereferencing a NULL pointer.

* subversion/libsvn_ra_svn/client.c
  (ra_svn_open): Avoid dereferencing a NULL pointer.

* subversion/libsvn_ra_serf/serf.c
  (svn_ra_serf__open): Avoid dereferencing a NULL pointer.

* subversion/libsvn_ra/ra_loader.c
  (svn_ra_open4): Avoid dereferencing a NULL pointer.

* subversion/include/svn_ra.h
  (svn_ra_open4): Update docstring to allow the caller to pass NULL
    for the 'corrected_url' parameter.
  (svn_ra_open3): Update docstring in light of changes to svn_ra_open4().

* subversion/libsvn_client/ra.c
  (svn_client__open_ra_session_internal): Always call svn_ra_open4()
    instead of sometimes calling svn_ra_open3().

Modified:
    subversion/branches/issue-2779-dev/subversion/include/svn_ra.h
    subversion/branches/issue-2779-dev/subversion/libsvn_client/ra.c
    subversion/branches/issue-2779-dev/subversion/libsvn_ra/ra_loader.c
    subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c
    subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c
    subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c

Modified: subversion/branches/issue-2779-dev/subversion/include/svn_ra.h
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/include/svn_ra.h?rev=965888&r1=965887&r2=965888&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/include/svn_ra.h (original)
+++ subversion/branches/issue-2779-dev/subversion/include/svn_ra.h Tue Jul 20 15:44:53 2010
@@ -580,13 +580,19 @@ svn_ra_create_callbacks(svn_ra_callbacks
 typedef struct svn_ra_session_t svn_ra_session_t;
 
 /**
- * Set @a *session_p to an opaque object representing a
- * repository session for the repository at @a repos_URL and @a
- * *session_url to @c NULL; otherwise, set @a *session_p to @c NULL
- * and @a *session_url to a corrected URL (perhaps as prescribed by
- * the server) which the caller might wish to use when re-attempting
- * the use of this interface.  In either case, allocated the returned
- * item in @a pool.
+ * Open a repository access session to the repository at @a repos_URL,
+ * or inform the caller regarding a correct URL by which to access
+ * that repository.
+ *
+ * If @a repos_URL can be used successfully to access the repository,
+ * set @a *session_p to an opaque object representing a repository
+ * session for the repository and (if @a corrected_url is non-NULL)
+ * set @a *corrected_url to NULL.  If there's a better URL that the
+ * caller should try and @a corrected_url is non-NULL, set
+ * @a *session_p to NULL and @a *corrected_url to the corrected URL.  If
+ * there's a better URL that the caller should try, and @a
+ * corrected_url is NULL, return an #SVN_ERR_RA_SESSION_URL_MISMATCH
+ * error.  Allocate all returned items in @a pool.
  *
  * Return @c SVN_ERR_RA_UUID_MISMATCH if @a uuid is non-NULL and not equal
  * to the UUID of the repository at @c repos_URL.
@@ -615,8 +621,8 @@ svn_ra_open4(svn_ra_session_t **session_
              apr_hash_t *config,
              apr_pool_t *pool);
 
-/** Similar to svn_ra_open4(), but return #SVN_ERR_RA_SESSION_URL_MISMATCH
- * rather than the @a corrected_url.
+/** Similar to svn_ra_open4(), but with @a corrected_url always passed
+ * as @c NULL.
  *
  * @since New in 1.5.
  * @deprecated Provided for backward compatibility with the 1.6 API.

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_client/ra.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_client/ra.c?rev=965888&r1=965887&r2=965888&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_client/ra.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_client/ra.c Tue Jul 20 15:44:53 2010
@@ -295,7 +295,6 @@ svn_client__open_ra_session_internal(svn
   svn_ra_callbacks2_t *cbtable = apr_pcalloc(pool, sizeof(*cbtable));
   callback_baton_t *cb = apr_pcalloc(pool, sizeof(*cb));
   const char *uuid = NULL;
-  apr_pool_t *sesspool = svn_pool_create(pool);
   const char *final_url;
 
   if (session_url)
@@ -345,14 +344,14 @@ svn_client__open_ra_session_internal(svn
   if (allow_redirect)
     {
       SVN_ERR(svn_ra_open4(ra_session, &final_url, base_url, uuid,
-                           cbtable, cb, ctx->config, sesspool));
+                           cbtable, cb, ctx->config, pool));
       if (session_url)
         *session_url = final_url;
     }
   else
     {
-      SVN_ERR(svn_ra_open3(ra_session, base_url, uuid, cbtable, cb,
-                           ctx->config, sesspool));
+      SVN_ERR(svn_ra_open4(ra_session, NULL, base_url, uuid,
+                           cbtable, cb, ctx->config, pool));
       if (session_url)
         SVN_ERR(svn_ra_get_session_url(*ra_session, session_url, pool));
     }

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra/ra_loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra/ra_loader.c?rev=965888&r1=965887&r2=965888&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra/ra_loader.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra/ra_loader.c Tue Jul 20 15:44:53 2010
@@ -269,7 +269,7 @@ svn_ra_create_callbacks(svn_ra_callbacks
 }
 
 svn_error_t *svn_ra_open4(svn_ra_session_t **session_p,
-                          const char **corrected_url,
+                          const char **corrected_url_p,
                           const char *repos_URL,
                           const char *uuid,
                           const svn_ra_callbacks2_t *callbacks,
@@ -296,7 +296,8 @@ svn_error_t *svn_ra_open4(svn_ra_session
   svn_boolean_t store_pp = SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP;
   const char *store_pp_plaintext
     = SVN_CONFIG_DEFAULT_OPTION_STORE_SSL_CLIENT_CERT_PP_PLAINTEXT;
-  
+  const char *corrected_url;
+
   /* Initialize the return variable. */
   *session_p = NULL;
 
@@ -488,7 +489,7 @@ svn_error_t *svn_ra_open4(svn_ra_session
   session->pool = sesspool;
 
   /* Ask the library to open the session. */
-  SVN_ERR_W(vtable->open_session(session, corrected_url, repos_URL,
+  SVN_ERR_W(vtable->open_session(session, &corrected_url, repos_URL,
                                  callbacks, callback_baton, config, sesspool),
             apr_psprintf(pool, "Unable to connect to a repository at URL '%s'",
                          repos_URL));
@@ -497,9 +498,9 @@ svn_error_t *svn_ra_open4(svn_ra_session
      correction (a 301 or 302 redirect response during the initial
      OPTIONS request), then kill the session so the caller can decide
      what to do. */
-  if (*corrected_url)
+  if (corrected_url_p && corrected_url)
     {
-      *corrected_url = apr_pstrdup(pool, *corrected_url);
+      *corrected_url_p = apr_pstrdup(pool, corrected_url);
       svn_pool_destroy(sesspool);
       return SVN_NO_ERROR;
     }

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c?rev=965888&r1=965887&r2=965888&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_local/ra_plugin.c Tue Jul 20 15:44:53 2010
@@ -446,7 +446,8 @@ svn_ra_local__open(svn_ra_session_t *ses
   const char *fs_path;
 
   /* We don't support redirections in ra-local. */
-  *corrected_url = NULL;
+  if (corrected_url)
+    *corrected_url = NULL;
 
   /* Allocate and stash the session_sess args we have already. */
   sess = apr_pcalloc(pool, sizeof(*sess));

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c?rev=965888&r1=965887&r2=965888&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_serf/serf.c Tue Jul 20 15:44:53 2010
@@ -344,7 +344,8 @@ svn_ra_serf__open(svn_ra_session_t *sess
   const char *client_string = NULL;
 
   /* We don't support server-prescribed redirections yet. */
-  *corrected_url = NULL;
+  if (corrected_url)
+    *corrected_url = NULL;
 
   serf_sess = apr_pcalloc(pool, sizeof(*serf_sess));
   serf_sess->pool = svn_pool_create(pool);

Modified: subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c?rev=965888&r1=965887&r2=965888&view=diff
==============================================================================
--- subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/branches/issue-2779-dev/subversion/libsvn_ra_svn/client.c Tue Jul 20 15:44:53 2010
@@ -700,7 +700,8 @@ static svn_error_t *ra_svn_open(svn_ra_s
   svn_config_t *cfg, *cfg_client;
 
   /* We don't support server-prescribed redirections in ra-svn. */
-  *corrected_url = NULL;
+  if (corrected_url)
+    *corrected_url = NULL;
 
   SVN_ERR(parse_url(url, &uri, sess_pool));