Author: rhuijben
Date: Sat Jul 13 22:22:51 2013
New Revision: 1502901

URL: http://svn.apache.org/r1502901
Log:
Following up on r1502811, make ra_serf capable of reusing ra sessions after
a log callback returns a SVN_ERR_CEASE_INVOCATION error, by properly resetting
the connection in serf.

In the location where I apply this change, we would have to read the remaining
part of the request to make the ra-session reusable, while we already know that
there are no more outstanding requests on the connection.

* subversion/libsvn_ra_serf/util.c
  (svn_ra_serf__context_run_one): If the context loop returns a
    SVN_ERR_CEASE_INVOCATION error, reset the connection.

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

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1502901&r1=1502900&r2=1502901&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sat Jul 13 22:22:51 2013
@@ -747,8 +747,6 @@ svn_ra_serf__context_run_wait(svn_boolea
          the connection timed out.  */
       if (APR_STATUS_IS_TIMEUP(status))
         {
-          svn_error_clear(err);
-          err = SVN_NO_ERROR;
           status = 0;
 
           if (sess->timeout)
@@ -759,8 +757,11 @@ svn_ra_serf__context_run_wait(svn_boolea
                 }
               else
                 {
-                  return svn_error_create(SVN_ERR_RA_DAV_CONN_TIMEOUT, NULL,
-                                          _("Connection timed out"));
+                  return
+                      svn_error_compose_create(
+                            err,
+                            svn_error_create(SVN_ERR_RA_DAV_CONN_TIMEOUT, NULL,
+                                             _("Connection timed out")));
                 }
             }
         }
@@ -808,6 +809,23 @@ svn_ra_serf__context_run_one(svn_ra_serf
   /* Wait until the response logic marks its DONE status.  */
   err = svn_ra_serf__context_run_wait(&handler->done, handler->session,
                                       scratch_pool);
+
+  /* A callback invocation has been canceled. In this simple case of
+     context_run_one, we can keep the ra-session operational by resetting
+     the connection.
+
+     If we don't do this, the next context run will notice that the connection
+     is still in the error state and will just return SVN_ERR_CEASE_INVOCATION
+     (=the last error for the connection) again  */
+  if (err && err->apr_err == SVN_ERR_CEASE_INVOCATION)
+    {
+      apr_status_t status = serf_connection_reset(handler->conn->conn);
+
+      if (status)
+        err = svn_error_compose_create(err,
+                                       svn_ra_serf__wrap_err(status, NULL));
+    }
+
   if (handler->server_error)
     {
       err = svn_error_compose_create(err, handler->server_error->error);


Reply via email to