You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by gs...@apache.org on 2012/05/06 19:00:52 UTC

svn commit: r1334697 - in /subversion/trunk/subversion/libsvn_ra_serf: ra_serf.h util.c

Author: gstein
Date: Sun May  6 17:00:52 2012
New Revision: 1334697

URL: http://svn.apache.org/viewvc?rev=1334697&view=rev
Log:
On a path towards placing HTTP-level items in the right place, add a
DONE flag to the handler, along with a captured error from the server.
This handler-level feature will replace simple_request_context.

We also introduce a new function to create a request (for a handler)
and wait for its completion. This also encapsulates the DONE flag,
unlike context_run_wait().

Note: the new run_one() creates the request unlike run_wait().
Examining all of the run_wait() calls, we see a request immediately
preceeds it. May as well bottle it all up.

* subversion/libsvn_ra_serf/ra_serf.h:
  (svn_ra_serf__server_error_t): move the typedef higher in the file
  (svn_ra_serf__handler_t): add DONE and SERVER_ERROR.
  (svn_ra_serf__context_run_one): new declaration

* subversion/libsvn_ra_serf/util.c:
  (svn_ra_serf__context_run_one): new implementation

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

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=1334697&r1=1334696&r2=1334697&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/ra_serf.h Sun May  6 17:00:52 2012
@@ -386,6 +386,9 @@ typedef svn_error_t *
                                  int status_code,
                                  void *baton);
 
+/* ### we should reorder the types in this file.  */
+typedef struct svn_ra_serf__server_error_t svn_ra_serf__server_error_t;
+
 /*
  * Structure that can be passed to our default handler to guide the
  * execution of the request through its lifecycle.
@@ -400,6 +403,13 @@ typedef struct svn_ra_serf__handler_t {
   /* The content-type of the request body. */
   const char *body_type;
 
+  /* Has the request/response been completed?  */
+  svn_boolean_t done;
+
+  /* If we captured an error from the server, then this will be non-NULL.
+     It will be allocated from HANDLER_POOL.  */
+  svn_ra_serf__server_error_t *server_error;
+
   /* The handler and baton pair for our handler. */
   svn_ra_serf__response_handler_t response_handler;
   void *response_baton;
@@ -452,6 +462,19 @@ typedef struct svn_ra_serf__handler_t {
 
 } svn_ra_serf__handler_t;
 
+
+/* Run one request and process the response.
+
+   Similar to context_run_wait(), but this creates the request for HANDLER
+   and then waits for it to complete.
+
+   WARNING: context_run_wait() does NOT create a request, whereas this
+   function DOES. Avoid a double-create.  */
+svn_error_t *
+svn_ra_serf__context_run_one(svn_ra_serf__handler_t *handler,
+                             apr_pool_t *scratch_pool);
+
+
 /*
  * Helper function to queue a request in the @a handler's connection.
  */
@@ -607,7 +630,7 @@ struct svn_ra_serf__xml_parser_t {
 /*
  * Parses a server-side error message into a local Subversion error.
  */
-typedef struct svn_ra_serf__server_error_t {
+struct svn_ra_serf__server_error_t {
   /* Our local representation of the error. */
   svn_error_t *error;
 
@@ -634,7 +657,7 @@ typedef struct svn_ra_serf__server_error
 
   /* XML parser and namespace used to parse the remote response */
   svn_ra_serf__xml_parser_t parser;
-} svn_ra_serf__server_error_t;
+};
 
 /* A simple request context that can be passed to handle_status_only. */
 typedef struct svn_ra_serf__simple_request_context_t {

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1334697&r1=1334696&r2=1334697&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sun May  6 17:00:52 2012
@@ -732,6 +732,21 @@ svn_ra_serf__context_run_wait(svn_boolea
 }
 
 
+svn_error_t *
+svn_ra_serf__context_run_one(svn_ra_serf__handler_t *handler,
+                             apr_pool_t *scratch_pool)
+{
+  /* Create a serf request based on HANDLER.  */
+  svn_ra_serf__request_create(handler);
+
+  /* Wait until the response logic marks its DONE status.  */
+  return svn_error_trace(svn_ra_serf__context_run_wait(
+                           &handler->done,
+                           handler->session,
+                           scratch_pool));
+}
+
+
 /*
  * Expat callback invoked on a start element tag for an error response.
  */