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 2014/01/12 18:07:40 UTC

svn commit: r1557560 - in /subversion/trunk/subversion/libsvn_ra_serf: commit.c property.c ra_serf.h

Author: rhuijben
Date: Sun Jan 12 17:07:39 2014
New Revision: 1557560

URL: http://svn.apache.org/r1557560
Log:
Make the pool usage in the property handling more sensible. In the set
property function duplicate all arguments in the result pool instead of
just 50% of them. Update expectations in callers to avoid unneeded work.

* subversion/libsvn_ra_serf/commit.c
  (change_dir_prop,
   change_file_prop): Assume that svn_ra_serf__set_prop takes care of
     duplication.

* subversion/libsvn_ra_serf/property.c
  (propfind_context_t): Remove some unneeded variables.
  (copy_into_ret_props): Remove unneeded intermediate function.
  (propfind_opened): Allocate in state pool instead of global context
    pool.
  (propfind_closed): Stop duplicating values. Directly pass callback to
    svn_ra_serf__walk_all_paths.

  (svn_ra_serf__set_ver_prop): Properly duplicate name and value if needed.
  (svn_ra_serf__deliver_props2): Update baton initialization.
  (deliver_prop): Stop duplicating everything.
  (svn_ra_serf__walk_all_paths): Stop passing unused arguments.

* subversion/libsvn_ra_serf/ra_serf.h
  (svn_ra_serf__path_rev_walker_t): Remove 3 unused length arguments.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/commit.c
    subversion/trunk/subversion/libsvn_ra_serf/property.c
    subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h

Modified: subversion/trunk/subversion/libsvn_ra_serf/commit.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/commit.c?rev=1557560&r1=1557559&r2=1557560&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/commit.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/commit.c Sun Jan 12 17:07:39 2014
@@ -1712,7 +1712,6 @@ change_dir_prop(void *dir_baton,
       proppatch_target = dir->working_url;
     }
 
-  name = apr_pstrdup(dir->pool, name);
   if (strncmp(name, SVN_PROP_PREFIX, sizeof(SVN_PROP_PREFIX) - 1) == 0)
     {
       ns = SVN_DAV_PROP_NS_SVN;
@@ -1725,13 +1724,12 @@ change_dir_prop(void *dir_baton,
 
   if (value)
     {
-      value = svn_string_dup(value, dir->pool);
       svn_ra_serf__set_prop(dir->changed_props, proppatch_target,
                             ns, name, value, dir->pool);
     }
   else
     {
-      value = svn_string_create_empty(dir->pool);
+      value = svn_string_create_empty(pool);
       svn_ra_serf__set_prop(dir->removed_props, proppatch_target,
                             ns, name, value, dir->pool);
     }
@@ -2011,8 +2009,6 @@ change_file_prop(void *file_baton,
   file_context_t *file = file_baton;
   const char *ns;
 
-  name = apr_pstrdup(file->pool, name);
-
   if (strncmp(name, SVN_PROP_PREFIX, sizeof(SVN_PROP_PREFIX) - 1) == 0)
     {
       ns = SVN_DAV_PROP_NS_SVN;
@@ -2025,13 +2021,12 @@ change_file_prop(void *file_baton,
 
   if (value)
     {
-      value = svn_string_dup(value, file->pool);
       svn_ra_serf__set_prop(file->changed_props, file->url,
                             ns, name, value, file->pool);
     }
   else
     {
-      value = svn_string_create_empty(file->pool);
+      value = svn_string_create_empty(pool);
 
       svn_ra_serf__set_prop(file->removed_props, file->url,
                             ns, name, value, file->pool);

Modified: subversion/trunk/subversion/libsvn_ra_serf/property.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/property.c?rev=1557560&r1=1557559&r2=1557560&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/property.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/property.c Sun Jan 12 17:07:39 2014
@@ -59,15 +59,8 @@ typedef enum prop_state_e {
  * This structure represents a pending PROPFIND response.
  */
 typedef struct propfind_context_t {
-  /* pool to issue allocations from */
-  apr_pool_t *pool;
-
   svn_ra_serf__handler_t *handler;
 
-  /* associated serf session */
-  svn_ra_serf__session_t *sess;
-  svn_ra_serf__connection_t *conn;
-
   /* the requested path */
   const char *path;
 
@@ -153,27 +146,6 @@ static apr_int64_t parse_status_code(con
   return 0;
 }
 
-
-/* Conforms to svn_ra_serf__path_rev_walker_t  */
-static svn_error_t *
-copy_into_ret_props(void *baton,
-                    const char *path, apr_ssize_t path_len,
-                    const char *ns, apr_ssize_t ns_len,
-                    const char *name, apr_ssize_t name_len,
-                    const svn_string_t *val,
-                    apr_pool_t *pool)
-{
-  propfind_context_t *ctx = baton;
-
-  SVN_ERR(ctx->prop_func(ctx->prop_func_baton,
-                         path,
-                         ns, name,
-                         val,
-                         pool));
-  return SVN_NO_ERROR;
-}
-
-
 /* Conforms to svn_ra_serf__xml_opened_t  */
 static svn_error_t *
 propfind_opened(svn_ra_serf__xml_estate_t *xes,
@@ -191,7 +163,7 @@ propfind_opened(svn_ra_serf__xml_estate_
     }
   else if (entered_state == PROPSTAT)
     {
-      ctx->ps_props = apr_hash_make(ctx->pool);
+      ctx->ps_props = apr_hash_make(svn_ra_serf__xml_state_pool(xes));
     }
 
   return SVN_NO_ERROR;
@@ -262,7 +234,7 @@ propfind_closed(svn_ra_serf__xml_estate_
 
       if ((altvalue = svn_hash_gets(attrs, "altvalue")) != NULL)
         {
-          val_str = svn_string_create(altvalue, ctx->pool);
+          val_str = svn_string_create(altvalue, scratch_pool);
         }
       else if ((encoding = svn_hash_gets(attrs, "V:encoding")) != NULL)
         {
@@ -273,12 +245,12 @@ propfind_closed(svn_ra_serf__xml_estate_
                                      encoding);
 
           /* Decode into the right pool.  */
-          val_str = svn_base64_decode_string(cdata, ctx->pool);
+          val_str = svn_base64_decode_string(cdata, scratch_pool);
         }
       else
         {
           /* Copy into the right pool.  */
-          val_str = svn_string_dup(cdata, ctx->pool);
+          val_str = cdata;
         }
 
       /* The current path sits on the RESPONSE state. Gather up all the
@@ -301,12 +273,11 @@ propfind_closed(svn_ra_serf__xml_estate_
         path = ctx->path;
 
       ns = svn_hash_gets(attrs, "ns");
-      name = apr_pstrdup(ctx->pool,
-                         svn_hash_gets(attrs, "name"));
+      name = svn_hash_gets(attrs, "name");
 
       svn_ra_serf__set_ver_prop(ctx->ps_props,
                                 path, ctx->rev, ns, name, val_str,
-                                ctx->pool);
+                                apr_hash_pool_get(ctx->ps_props));
     }
   else
     {
@@ -322,11 +293,12 @@ propfind_closed(svn_ra_serf__xml_estate_
       if (! svn_hash_gets(gathered, "ignore-prop"))
         {
           SVN_ERR(svn_ra_serf__walk_all_paths(ctx->ps_props, ctx->rev,
-                                              copy_into_ret_props, ctx,
+                                              ctx->prop_func,
+                                              ctx->prop_func_baton,
                                               scratch_pool));
         }
 
-      ctx->ps_props = NULL;
+      ctx->ps_props = NULL; /* Allocated in PROPSTAT state pool */
     }
 
   return SVN_NO_ERROR;
@@ -436,6 +408,12 @@ svn_ra_serf__set_ver_prop(apr_hash_t *pr
       svn_hash_sets(path_props, ns, ns_props);
     }
 
+  if (val)
+    {
+      name = apr_pstrdup(pool, name);
+      val = svn_string_dup(val, pool);
+    }
+
   svn_hash_sets(ns_props, name, val);
 }
 
@@ -566,14 +544,11 @@ svn_ra_serf__deliver_props2(svn_ra_serf_
 
   new_prop_ctx = apr_pcalloc(pool, sizeof(*new_prop_ctx));
 
-  new_prop_ctx->pool = pool;
   new_prop_ctx->path = path;
   new_prop_ctx->find_props = find_props;
   new_prop_ctx->prop_func = prop_func;
   new_prop_ctx->prop_func_baton = prop_func_baton;
   new_prop_ctx->depth = depth;
-  new_prop_ctx->sess = sess;
-  new_prop_ctx->conn = conn;
   new_prop_ctx->rev = rev;
 
   if (SVN_IS_VALID_REVNUM(rev))
@@ -603,8 +578,8 @@ svn_ra_serf__deliver_props2(svn_ra_serf_
   handler->header_delegate = setup_propfind_headers;
   handler->header_delegate_baton = new_prop_ctx;
 
-  handler->session = new_prop_ctx->sess;
-  handler->conn = new_prop_ctx->conn;
+  handler->session = sess;
+  handler->conn = conn;
 
   new_prop_ctx->handler = handler;
 
@@ -634,9 +609,7 @@ deliver_prop(void *baton,
 
   svn_ra_serf__set_ver_prop(dpb->prop_vals,
                             path, dpb->rev,
-                            apr_pstrdup(dpb->result_pool, ns),
-                            apr_pstrdup(dpb->result_pool, name),
-                            svn_string_dup(value, dpb->result_pool),
+                            ns, name, value,
                             dpb->result_pool);
   return SVN_NO_ERROR;
 }
@@ -835,29 +808,26 @@ svn_ra_serf__walk_all_paths(apr_hash_t *
     {
       void *path_props;
       const void *path_name;
-      apr_ssize_t path_len;
       apr_hash_index_t *ns_hi;
 
-      apr_hash_this(path_hi, &path_name, &path_len, &path_props);
+      apr_hash_this(path_hi, &path_name, NULL, &path_props);
       for (ns_hi = apr_hash_first(pool, path_props); ns_hi;
            ns_hi = apr_hash_next(ns_hi))
         {
           void *ns_val;
           const void *ns_name;
-          apr_ssize_t ns_len;
           apr_hash_index_t *name_hi;
-          apr_hash_this(ns_hi, &ns_name, &ns_len, &ns_val);
+          apr_hash_this(ns_hi, &ns_name, NULL, &ns_val);
           for (name_hi = apr_hash_first(pool, ns_val); name_hi;
                name_hi = apr_hash_next(name_hi))
             {
               void *prop_val;
               const void *prop_name;
-              apr_ssize_t prop_len;
 
-              apr_hash_this(name_hi, &prop_name, &prop_len, &prop_val);
+              apr_hash_this(name_hi, &prop_name, NULL, &prop_val);
               /* use a subpool? */
-              SVN_ERR(walker(baton, path_name, path_len, ns_name, ns_len,
-                             prop_name, prop_len, prop_val, pool));
+              SVN_ERR(walker(baton, path_name, ns_name, prop_name, prop_val,
+                             pool));
             }
         }
     }

Modified: subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h?rev=1557560&r1=1557559&r2=1557560&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sun Jan 12 17:07:39 2014
@@ -1068,9 +1068,9 @@ svn_ra_serf__walk_node_props(apr_hash_t 
 
 typedef svn_error_t *
 (*svn_ra_serf__path_rev_walker_t)(void *baton,
-                                  const char *path, apr_ssize_t path_len,
-                                  const char *ns, apr_ssize_t ns_len,
-                                  const char *name, apr_ssize_t name_len,
+                                  const char *path,
+                                  const char *ns,
+                                  const char *name,
                                   const svn_string_t *val,
                                   apr_pool_t *pool);
 svn_error_t *