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/28 22:36:34 UTC
svn commit: r1553932 - in /subversion/trunk/subversion/libsvn_ra_serf:
inherited_props.c lock.c ra_serf.h update.c util.c
Author: rhuijben
Date: Sat Dec 28 21:36:33 2013
New Revision: 1553932
URL: http://svn.apache.org/r1553932
Log:
Extract a bit of duplicated code in libsvn_ra_serf to a helper function.
* subversion/libsvn_ra_serf/inherited_props.c
(get_iprops_via_more_requests): Use svn_ra_serf__context_run.
* subversion/libsvn_ra_serf/lock.c
(run_locks): Use svn_ra_serf__context_run.
* subversion/libsvn_ra_serf/ra_serf.h
(svn_ra_serf__context_run): New function.
* subversion/libsvn_ra_serf/update.c
(finish_report): Use svn_ra_serf__context_run.
* subversion/libsvn_ra_serf/util.c
(svn_ra_serf__context_run): New function, extracted from...
(svn_ra_serf__context_run_wait): ... this function.
Modified:
subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
subversion/trunk/subversion/libsvn_ra_serf/lock.c
subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h
subversion/trunk/subversion/libsvn_ra_serf/update.c
subversion/trunk/subversion/libsvn_ra_serf/util.c
Modified: subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c?rev=1553932&r1=1553931&r2=1553932&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c Sat Dec 28 21:36:33 2013
@@ -308,64 +308,9 @@ get_iprops_via_more_requests(svn_ra_sess
while (TRUE)
{
- apr_status_t status;
- svn_error_t *err;
-
svn_pool_clear(iterpool);
- if (session->cancel_func)
- SVN_ERR(session->cancel_func(session->cancel_baton));
-
- status = serf_context_run(session->context,
- SVN_RA_SERF__CONTEXT_RUN_DURATION,
- iterpool);
-
- err = session->pending_error;
- session->pending_error = SVN_NO_ERROR;
-
- /* If the context duration timeout is up, we'll subtract that
- duration from the total time alloted for such things. If
- there's no time left, we fail with a message indicating that
- the connection timed out. */
- if (APR_STATUS_IS_TIMEUP(status))
- {
- status = 0;
-
- if (session->timeout)
- {
- if (waittime_left > SVN_RA_SERF__CONTEXT_RUN_DURATION)
- {
- waittime_left -= SVN_RA_SERF__CONTEXT_RUN_DURATION;
- }
- else
- {
- return
- svn_error_compose_create(
- err,
- svn_error_create(SVN_ERR_RA_DAV_CONN_TIMEOUT, NULL,
- _("Connection timed out")));
- }
- }
- }
- else
- {
- waittime_left = session->timeout;
- }
-
- SVN_ERR(err);
- if (status)
- {
- /* ### This omits SVN_WARNING, and possibly relies on the fact that
- ### MAX(SERF_ERROR_*) < SVN_ERR_BAD_CATEGORY_START? */
- if (status >= SVN_ERR_BAD_CATEGORY_START && status < SVN_ERR_LAST)
- {
- /* apr can't translate subversion errors to text */
- SVN_ERR_W(svn_error_create(status, NULL, NULL),
- _("Error running context"));
- }
-
- return svn_ra_serf__wrap_err(status, _("Error running context"));
- }
+ SVN_ERR(svn_ra_serf__context_run(session, &waittime_left, iterpool));
for (i = 0; i < rq_info->nelts; i++)
{
Modified: subversion/trunk/subversion/libsvn_ra_serf/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/lock.c?rev=1553932&r1=1553931&r2=1553932&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/lock.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/lock.c Sat Dec 28 21:36:33 2013
@@ -215,65 +215,11 @@ run_locks(svn_ra_serf__session_t *sess,
iterpool = svn_pool_create(scratch_pool);
while (lock_ctxs->nelts)
{
- apr_status_t status;
- svn_error_t *err;
int i;
svn_pool_clear(iterpool);
- if (sess->cancel_func)
- SVN_ERR((*sess->cancel_func)(sess->cancel_baton));
-
- status = serf_context_run(sess->context,
- SVN_RA_SERF__CONTEXT_RUN_DURATION,
- iterpool);
-
- err = sess->pending_error;
- sess->pending_error = SVN_NO_ERROR;
-
- /* If the context duration timeout is up, we'll subtract that
- duration from the total time alloted for such things. If
- there's no time left, we fail with a message indicating that
- the connection timed out. */
- if (APR_STATUS_IS_TIMEUP(status))
- {
- status = 0;
-
- if (sess->timeout)
- {
- if (waittime_left > SVN_RA_SERF__CONTEXT_RUN_DURATION)
- {
- waittime_left -= SVN_RA_SERF__CONTEXT_RUN_DURATION;
- }
- else
- {
- return
- svn_error_compose_create(
- err,
- svn_error_create(SVN_ERR_RA_DAV_CONN_TIMEOUT, NULL,
- _("Connection timed out")));
- }
- }
- }
- else
- {
- waittime_left = sess->timeout;
- }
-
- SVN_ERR(err);
- if (status)
- {
- /* ### This omits SVN_WARNING, and possibly relies on the fact that
- ### MAX(SERF_ERROR_*) < SVN_ERR_BAD_CATEGORY_START? */
- if (status >= SVN_ERR_BAD_CATEGORY_START && status < SVN_ERR_LAST)
- {
- /* apr can't translate subversion errors to text */
- SVN_ERR_W(svn_error_create(status, NULL, NULL),
- _("Error running context"));
- }
-
- return svn_ra_serf__wrap_err(status, _("Error running context"));
- }
+ SVN_ERR(svn_ra_serf__context_run(sess, &waittime_left, iterpool));
for (i = 0; i < lock_ctxs->nelts; i++)
{
@@ -283,6 +229,7 @@ run_locks(svn_ra_serf__session_t *sess,
{
svn_error_t *server_err = NULL;
svn_error_t *cb_err = NULL;
+ svn_error_t *err;
if (ctx->handler->server_error)
server_err = ctx->handler->server_error->error;
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=1553932&r1=1553931&r2=1553932&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sat Dec 28 21:36:33 2013
@@ -381,6 +381,16 @@ svn_ra_serf__context_run_wait(svn_boolea
svn_ra_serf__session_t *sess,
apr_pool_t *scratch_pool);
+/* Run the context once. Manage waittime_left to handle timing out when
+ nothing happens over the session->timout.
+ */
+svn_error_t *
+svn_ra_serf__context_run(svn_ra_serf__session_t *sess,
+ apr_interval_time_t *waittime_left,
+ apr_pool_t *scratch_pool);
+
+
+
/* Callback for response handlers */
typedef svn_error_t *
(*svn_ra_serf__response_handler_t)(serf_request_t *request,
Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1553932&r1=1553931&r2=1553932&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Sat Dec 28 21:36:33 2013
@@ -2908,10 +2908,8 @@ finish_report(void *report_baton,
|| report->num_active_fetches
|| report->num_active_propfinds)
{
- apr_pool_t *iterpool_inner;
svn_ra_serf__list_t *done_list;
int i;
- apr_status_t status;
/* Note: this throws out the old ITERPOOL_INNER. */
svn_pool_clear(iterpool);
@@ -2919,62 +2917,11 @@ finish_report(void *report_baton,
if (sess->cancel_func)
SVN_ERR(sess->cancel_func(sess->cancel_baton));
- /* We need to be careful between the outer and inner ITERPOOLs,
- and what items are allocated within. */
- iterpool_inner = svn_pool_create(iterpool);
-
- status = serf_context_run(sess->context,
- SVN_RA_SERF__CONTEXT_RUN_DURATION,
- iterpool_inner);
-
- err = sess->pending_error;
- sess->pending_error = SVN_NO_ERROR;
-
- if (!err && handler->done && handler->server_error)
- {
- err = handler->server_error->error;
- }
-
- /* If the context duration timeout is up, we'll subtract that
- duration from the total time alloted for such things. If
- there's no time left, we fail with a message indicating that
- the connection timed out. */
- if (APR_STATUS_IS_TIMEUP(status))
- {
- /* If there is a pending error, handle it.
- Unlikely case, as this should have made serf_context run return
- an error but we shouldn't ignore true errors */
- SVN_ERR(err);
- status = 0;
-
- if (sess->timeout)
- {
- if (waittime_left > SVN_RA_SERF__CONTEXT_RUN_DURATION)
- {
- waittime_left -= SVN_RA_SERF__CONTEXT_RUN_DURATION;
- }
- else
- {
- return svn_error_create(SVN_ERR_RA_DAV_CONN_TIMEOUT, NULL,
- _("Connection timed out"));
- }
- }
- }
- else
- {
- waittime_left = sess->timeout;
- }
-
- SVN_ERR(err);
+ SVN_ERR(svn_ra_serf__context_run(sess, &waittime_left, iterpool));
if (handler->sline.code && handler->sline.code != 200)
return svn_error_trace(svn_ra_serf__unexpected_status(handler));
- if (status)
- {
- return svn_ra_serf__wrap_err(status, _("Error retrieving REPORT"));
- }
-
/* Open extra connections if we have enough requests to send. */
if (sess->num_conns < sess->max_connections)
SVN_ERR(open_connection_if_needed(sess, report->num_active_fetches +
@@ -2986,7 +2933,7 @@ finish_report(void *report_baton,
{
svn_ra_serf__list_t *next_done = done_list->next;
- svn_pool_clear(iterpool_inner);
+ svn_pool_clear(iterpool);
report->num_active_propfinds--;
@@ -3041,11 +2988,11 @@ finish_report(void *report_baton,
*/
if (info->cached_contents)
{
- SVN_ERR(handle_local_content(info, iterpool_inner));
+ SVN_ERR(handle_local_content(info, iterpool));
}
else
{
- SVN_ERR(handle_propchange_only(info, iterpool_inner));
+ SVN_ERR(handle_propchange_only(info, iterpool));
}
}
}
@@ -3154,7 +3101,7 @@ finish_report(void *report_baton,
if (!parser_ctx->paused && parser_ctx->pending != NULL)
SVN_ERR(svn_ra_serf__process_pending(parser_ctx,
&report->report_received,
- iterpool_inner));
+ iterpool));
/* Debugging purposes only! */
for (i = 0; i < sess->num_conns; i++)
@@ -3163,6 +3110,8 @@ finish_report(void *report_baton,
}
}
+ svn_pool_clear(iterpool);
+
/* If we got a complete report, close the edit. Otherwise, abort it. */
if (report->report_completed)
{
Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1553932&r1=1553931&r2=1553932&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sat Dec 28 21:36:33 2013
@@ -884,6 +884,72 @@ setup_serf_req(serf_request_t *request,
}
svn_error_t *
+svn_ra_serf__context_run(svn_ra_serf__session_t *sess,
+ apr_interval_time_t *waittime_left,
+ apr_pool_t *scratch_pool)
+{
+ apr_status_t status;
+ svn_error_t *err;
+ assert(sess->pending_error == SVN_NO_ERROR);
+
+ if (sess->cancel_func)
+ SVN_ERR(sess->cancel_func(sess->cancel_baton));
+
+ status = serf_context_run(sess->context,
+ SVN_RA_SERF__CONTEXT_RUN_DURATION,
+ scratch_pool);
+
+ err = sess->pending_error;
+ sess->pending_error = SVN_NO_ERROR;
+
+ /* If the context duration timeout is up, we'll subtract that
+ duration from the total time alloted for such things. If
+ there's no time left, we fail with a message indicating that
+ the connection timed out. */
+ if (APR_STATUS_IS_TIMEUP(status))
+ {
+ status = 0;
+
+ if (sess->timeout)
+ {
+ if (*waittime_left > SVN_RA_SERF__CONTEXT_RUN_DURATION)
+ {
+ *waittime_left -= SVN_RA_SERF__CONTEXT_RUN_DURATION;
+ }
+ else
+ {
+ return
+ svn_error_compose_create(
+ err,
+ svn_error_create(SVN_ERR_RA_DAV_CONN_TIMEOUT, NULL,
+ _("Connection timed out")));
+ }
+ }
+ }
+ else
+ {
+ *waittime_left = sess->timeout;
+ }
+
+ SVN_ERR(err);
+ if (status)
+ {
+ /* ### This omits SVN_WARNING, and possibly relies on the fact that
+ ### MAX(SERF_ERROR_*) < SVN_ERR_BAD_CATEGORY_START? */
+ if (status >= SVN_ERR_BAD_CATEGORY_START && status < SVN_ERR_LAST)
+ {
+ /* apr can't translate subversion errors to text */
+ SVN_ERR_W(svn_error_create(status, NULL, NULL),
+ _("Error running context"));
+ }
+
+ return svn_ra_serf__wrap_err(status, _("Error running context"));
+ }
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
svn_ra_serf__context_run_wait(svn_boolean_t *done,
svn_ra_serf__session_t *sess,
apr_pool_t *scratch_pool)
@@ -896,65 +962,11 @@ svn_ra_serf__context_run_wait(svn_boolea
iterpool = svn_pool_create(scratch_pool);
while (!*done)
{
- apr_status_t status;
- svn_error_t *err;
int i;
svn_pool_clear(iterpool);
- if (sess->cancel_func)
- SVN_ERR((*sess->cancel_func)(sess->cancel_baton));
-
- status = serf_context_run(sess->context,
- SVN_RA_SERF__CONTEXT_RUN_DURATION,
- iterpool);
-
- err = sess->pending_error;
- sess->pending_error = SVN_NO_ERROR;
-
- /* If the context duration timeout is up, we'll subtract that
- duration from the total time alloted for such things. If
- there's no time left, we fail with a message indicating that
- the connection timed out. */
- if (APR_STATUS_IS_TIMEUP(status))
- {
- status = 0;
-
- if (sess->timeout)
- {
- if (waittime_left > SVN_RA_SERF__CONTEXT_RUN_DURATION)
- {
- waittime_left -= SVN_RA_SERF__CONTEXT_RUN_DURATION;
- }
- else
- {
- return
- svn_error_compose_create(
- err,
- svn_error_create(SVN_ERR_RA_DAV_CONN_TIMEOUT, NULL,
- _("Connection timed out")));
- }
- }
- }
- else
- {
- waittime_left = sess->timeout;
- }
-
- SVN_ERR(err);
- if (status)
- {
- /* ### This omits SVN_WARNING, and possibly relies on the fact that
- ### MAX(SERF_ERROR_*) < SVN_ERR_BAD_CATEGORY_START? */
- if (status >= SVN_ERR_BAD_CATEGORY_START && status < SVN_ERR_LAST)
- {
- /* apr can't translate subversion errors to text */
- SVN_ERR_W(svn_error_create(status, NULL, NULL),
- _("Error running context"));
- }
-
- return svn_ra_serf__wrap_err(status, _("Error running context"));
- }
+ SVN_ERR(svn_ra_serf__context_run(sess, &waittime_left, iterpool));
/* Debugging purposes only! */
for (i = 0; i < sess->num_conns; i++)