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/03/17 12:33:29 UTC

svn commit: r1578311 - /subversion/trunk/subversion/libsvn_ra_serf/get_lock.c

Author: rhuijben
Date: Mon Mar 17 11:33:29 2014
New Revision: 1578311

URL: http://svn.apache.org/r1578311
Log:
* subversion/libsvn_ra_serf/get_lock.c
  (svn_ra_serf__get_lock): Following up on r1578273, only return a lock
    instance when the node is really locked, as svn_ra_get_lock() documents.
    Introduce sub/scratch pool.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/get_lock.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/get_lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/get_lock.c?rev=1578311&r1=1578310&r2=1578311&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/get_lock.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/get_lock.c Mon Mar 17 11:33:29 2014
@@ -256,29 +256,31 @@ svn_error_t *
 svn_ra_serf__get_lock(svn_ra_session_t *ra_session,
                       svn_lock_t **lock,
                       const char *path,
-                      apr_pool_t *pool)
+                      apr_pool_t *result_pool)
 {
   svn_ra_serf__session_t *session = ra_session->priv;
   svn_ra_serf__handler_t *handler;
   svn_ra_serf__xml_context_t *xmlctx;
+  apr_pool_t *scratch_pool = svn_pool_create(result_pool);
   lock_info_t *lock_ctx;
   const char *req_url;
   svn_error_t *err;
 
-  req_url = svn_path_url_add_component2(session->session_url.path, path, pool);
+  req_url = svn_path_url_add_component2(session->session_url.path, path,
+                                        scratch_pool);
 
-  lock_ctx = apr_pcalloc(pool, sizeof(*lock_ctx));
-
-  lock_ctx->pool = pool;
+  lock_ctx = apr_pcalloc(scratch_pool, sizeof(*lock_ctx));
+  lock_ctx->pool = result_pool;
   lock_ctx->path = req_url;
-  lock_ctx->lock = svn_lock_create(pool);
-  lock_ctx->lock->path = apr_pstrdup(pool, path); /* be sure  */
+  lock_ctx->lock = svn_lock_create(result_pool);
+  lock_ctx->lock->path = apr_pstrdup(result_pool, path);
 
   xmlctx = svn_ra_serf__xml_context_create(locks_ttable,
                                            NULL, locks_closed, NULL,
                                            lock_ctx,
-                                           pool);
-  handler = svn_ra_serf__create_expat_handler(xmlctx, locks_expected_status, pool);
+                                           scratch_pool);
+  handler = svn_ra_serf__create_expat_handler(xmlctx, locks_expected_status,
+                                              scratch_pool);
 
   handler->method = "PROPFIND";
   handler->path = req_url;
@@ -299,7 +301,7 @@ svn_ra_serf__get_lock(svn_ra_session_t *
 
   lock_ctx->handler = handler;
 
-  err = svn_ra_serf__context_run_one(handler, pool);
+  err = svn_ra_serf__context_run_one(handler, scratch_pool);
 
   if ((err && (handler->sline.code == 500 || handler->sline.code == 501))
       || svn_error_find_cause(err, SVN_ERR_UNSUPPORTED_FEATURE))
@@ -311,7 +313,12 @@ svn_ra_serf__get_lock(svn_ra_session_t *
   else if (handler->sline.code != 207)
     return svn_error_trace(svn_ra_serf__unexpected_status(handler));
 
-  *lock = lock_ctx->lock;
+  if (lock_ctx->lock && lock_ctx->lock->token)
+    *lock = lock_ctx->lock;
+  else
+    *lock = NULL;
+
+  svn_pool_destroy(scratch_pool);
 
   return SVN_NO_ERROR;
 }