You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/10/14 04:30:28 UTC

svn commit: r1531777 - in /subversion/trunk/subversion: include/svn_client.h include/svn_ra.h libsvn_client/ra.c libsvn_ra_svn/client.c tests/libsvn_ra/ra-test.c

Author: brane
Date: Mon Oct 14 02:30:28 2013
New Revision: 1531777

URL: http://svn.apache.org/r1531777
Log:
Add an explicit baton for the tunnel handling callbacks,
and make parameter names more consistent.

* subversion/include/svn_client.h (svn_client_ctx_t): New member tunnel_baton.
* subversion/include/svn_ra.h
  (svn_ra_callbacks2_t): New member tunnel_baton.
   Renamed open_tunnel to open_tunnel_func,
   and close_tunnel to close_tunnel_func.
  (svn_ra_open_tunnel_func_t, svn_ra_close_tunnel_func_t):
   Rename parameter tunnel_baton to tunnel_context.
   Rename parameter open_baton to tunnel_baton,
   to match the callbacks structure.

* subversion/libsvn_client/ra.c (svn_client__open_ra_session_internal):
   Update for renamed callback struct members and init the
   tunnel_baton in the RA callbacks.
* subversion/libsvn_ra_svn/client.c
  (tunnel_data_t, close_tunnel_cleanup, open_session, ra_svn_open):
   Update for renamed callback struct members.
* subversion/tests/libsvn_ra/ra-test.c: Likewise.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/include/svn_ra.h
    subversion/trunk/subversion/libsvn_client/ra.c
    subversion/trunk/subversion/libsvn_ra_svn/client.c
    subversion/trunk/subversion/tests/libsvn_ra/ra-test.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=1531777&r1=1531776&r2=1531777&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Mon Oct 14 02:30:28 2013
@@ -1036,6 +1036,11 @@ typedef struct svn_client_ctx_t
    * @since New in 1.9.
    */
   svn_ra_close_tunnel_func_t close_tunnel_func;
+
+  /** A baton used with open_tunnel_func and close_tunnel_func.
+   * @since New in 1.9.
+   */
+  void *tunnel_baton;
 } svn_client_ctx_t;
 
 /** Initialize a client context.

Modified: subversion/trunk/subversion/include/svn_ra.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_ra.h?rev=1531777&r1=1531776&r2=1531777&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_ra.h (original)
+++ subversion/trunk/subversion/include/svn_ra.h Mon Oct 14 02:30:28 2013
@@ -281,15 +281,15 @@ typedef svn_error_t *(*svn_ra_replay_rev
  * @a request and @a response are the standard input and output,
  * respectively, of the process on the other end of the tunnel.
  *
- * @a tunnel_baton will be passed on to the close-unnel callback.
+ * @a tunnel_context will be passed on to the close-unnel callback.
  *
- * @a open_baton is the baton as originally passed to ra_open.
+ * @a tunnel_baton is the baton as originally passed to ra_open.
  *
  * @since New in 1.9.
  */
 typedef svn_error_t *(*svn_ra_open_tunnel_func_t)(
     apr_file_t **request, apr_file_t **response,
-    void **tunnel_baton, void *open_baton,
+    void **tunnel_context, void *tunnel_baton,
     const char *tunnel_name, const char *user,
     const char *hostname, int port,
     apr_pool_t *pool);
@@ -309,7 +309,7 @@ typedef svn_error_t *(*svn_ra_open_tunne
  * @since New in 1.9.
  */
 typedef svn_error_t *(*svn_ra_close_tunnel_func_t)(
-    void *tunnel_baton, void *open_baton,
+    void *tunnel_context, void *tunnel_baton,
     const char *tunnel_name, const char *user,
     const char *hostname, int port);
 
@@ -588,7 +588,7 @@ typedef struct svn_ra_callbacks2_t
    * and ignored by the other RA modules.
    * @since New in 1.9.
    */
-  svn_ra_open_tunnel_func_t open_tunnel;
+  svn_ra_open_tunnel_func_t open_tunnel_func;
 
   /** Close-tunnel callback
    * If not @c null, this callback will be invoked when the pool that
@@ -597,8 +597,12 @@ typedef struct svn_ra_callbacks2_t
    * ignored by the other RA modules.
    * @since New in 1.9.
    */
-  svn_ra_close_tunnel_func_t close_tunnel;
+  svn_ra_close_tunnel_func_t close_tunnel_func;
 
+  /** A baton used with open_tunnel_func and close_tunnel_func.
+   * @since New in 1.9.
+   */
+  void *tunnel_baton;
 } svn_ra_callbacks2_t;
 
 /** Similar to svn_ra_callbacks2_t, except that the progress

Modified: subversion/trunk/subversion/libsvn_client/ra.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/ra.c?rev=1531777&r1=1531776&r2=1531777&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/ra.c (original)
+++ subversion/trunk/subversion/libsvn_client/ra.c Mon Oct 14 02:30:28 2013
@@ -350,8 +350,9 @@ svn_client__open_ra_session_internal(svn
   cbtable->get_client_string = get_client_string;
   if (base_dir_abspath)
     cbtable->get_wc_contents = get_wc_contents;
-  cbtable->open_tunnel = ctx->open_tunnel_func;
-  cbtable->close_tunnel = ctx->close_tunnel_func;
+  cbtable->open_tunnel_func = ctx->open_tunnel_func;
+  cbtable->close_tunnel_func = ctx->close_tunnel_func;
+  cbtable->tunnel_baton = ctx->tunnel_baton;
 
   cb->commit_items = commit_items;
   cb->ctx = ctx;

Modified: subversion/trunk/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/client.c?rev=1531777&r1=1531776&r2=1531777&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/client.c Mon Oct 14 02:30:28 2013
@@ -564,8 +564,8 @@ static svn_error_t *parse_url(const char
 /* This structure is used as a baton for the pool cleanup function to
    store tunnel parameters used by the close-tunnel callback. */
 struct tunnel_data_t {
+  void *tunnel_context;
   void *tunnel_baton;
-  void *open_baton;
   const char *tunnel_name;
   const char *user;
   const char *hostname;
@@ -578,7 +578,7 @@ static apr_status_t close_tunnel_cleanup
 {
   const struct tunnel_data_t *const td = baton;
   svn_error_t *const err =
-    svn_error_root_cause(td->close_tunnel(td->tunnel_baton, td->open_baton,
+    svn_error_root_cause(td->close_tunnel(td->tunnel_context, td->tunnel_baton,
                                           td->tunnel_name, td->user,
                                           td->hostname, td->port));
   const apr_status_t ret = (err ? err->apr_err : 0);
@@ -625,27 +625,28 @@ static svn_error_t *open_session(svn_ra_
 
   if (tunnel_name)
     {
-      if (!callbacks->open_tunnel)
+      if (!callbacks->open_tunnel_func)
         SVN_ERR(make_tunnel(tunnel_argv, &conn, pool));
       else
         {
-          void *tunnel_baton;
+          void *tunnel_context;
           apr_file_t *request;
           apr_file_t *response;
-          SVN_ERR(callbacks->open_tunnel(&request, &response, &tunnel_baton,
-                                         callbacks_baton, tunnel_name,
-                                         uri->user, uri->hostname, uri->port,
-                                         pool));
-          if (callbacks->close_tunnel)
+          SVN_ERR(callbacks->open_tunnel_func(
+                      &request, &response, &tunnel_context,
+                      callbacks_baton, tunnel_name,
+                      uri->user, uri->hostname, uri->port,
+                      pool));
+          if (callbacks->close_tunnel_func)
             {
               struct tunnel_data_t *const td = apr_palloc(pool, sizeof(*td));
-              td->tunnel_baton = tunnel_baton;
-              td->open_baton = callbacks_baton;
+              td->tunnel_context = tunnel_context;
+              td->tunnel_baton = callbacks->tunnel_baton;
               td->tunnel_name = apr_pstrdup(pool, tunnel_name);
               td->user = apr_pstrdup(pool, uri->user);
               td->hostname = apr_pstrdup(pool, uri->hostname);
               td->port = uri->port;
-              td->close_tunnel = callbacks->close_tunnel;
+              td->close_tunnel = callbacks->close_tunnel_func;
               apr_pool_cleanup_register(pool, td, close_tunnel_cleanup,
                                         apr_pool_cleanup_null);
             }
@@ -798,7 +799,7 @@ static svn_error_t *ra_svn_open(svn_ra_s
 
   parse_tunnel(url, &tunnel, pool);
 
-  if (tunnel && !callbacks->open_tunnel)
+  if (tunnel && !callbacks->open_tunnel_func)
     SVN_ERR(find_tunnel_agent(tunnel, uri.hostinfo, &tunnel_argv, config,
                               pool));
   else

Modified: subversion/trunk/subversion/tests/libsvn_ra/ra-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_ra/ra-test.c?rev=1531777&r1=1531776&r2=1531777&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_ra/ra-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_ra/ra-test.c Mon Oct 14 02:30:28 2013
@@ -98,7 +98,7 @@ static int tunnel_open_count;
 
 static svn_error_t *
 open_tunnel(apr_file_t **request, apr_file_t **response,
-            void **tunnel_baton, void *callbacks_baton,
+            void **tunnel_context, void *tunnel_baton,
             const char *tunnel_name, const char *user,
             const char *hostname, int port,
             apr_pool_t *pool)
@@ -146,13 +146,12 @@ open_tunnel(apr_file_t **request, apr_fi
 
   *request = proc->in;
   *response = proc->out;
-  *tunnel_baton = NULL;
   ++tunnel_open_count;
   return SVN_NO_ERROR;
 }
 
 static svn_error_t *
-close_tunnel(void *tunnel_baton, void *callbacks_baton,
+close_tunnel(void *tunnel_context, void *tunnel_baton,
              const char *tunnel_name, const char *user,
              const char *hostname, int port)
 {
@@ -242,8 +241,8 @@ tunel_callback_test(const svn_test_opts_
 
   url = apr_pstrcat(pool, "svn+test://localhost/", tunnel_repos_name, NULL);
   SVN_ERR(svn_ra_create_callbacks(&cbtable, pool));
-  cbtable->open_tunnel = open_tunnel;
-  cbtable->close_tunnel = close_tunnel;
+  cbtable->open_tunnel_func = open_tunnel;
+  cbtable->close_tunnel_func = close_tunnel;
   SVN_ERR(svn_cmdline_create_auth_baton(&cbtable->auth_baton,
                                         TRUE  /* non_interactive */,
                                         "jrandom", "rayjandom",