subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r1335365 - /subversion/trunk/subversion/libsvn_ra_serf/update.c
Date Tue, 08 May 2012 07:34:29 GMT
Author: gstein
Date: Tue May  8 07:34:28 2012
New Revision: 1335365

URL: http://svn.apache.org/viewvc?rev=1335365&view=rev
Log:
Propage the handler into the response processing callbacks.

* subversion/libsvn_ra_serf/update.c:
  (report_fetch_t): add HANDLER field
  (handle_fetch, handle_stream, handle_local_fetch): assert we have
    the handler, and use it.
  (fetch_file, svn_ra_serf__get_file): initialize HANDLER

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

Modified: subversion/trunk/subversion/libsvn_ra_serf/update.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/update.c?rev=1335365&r1=1335364&r2=1335365&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/update.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/update.c Tue May  8 07:34:28 2012
@@ -256,6 +256,9 @@ typedef struct report_info_t
  */
 typedef struct report_fetch_t {
 
+  /* The handler representing this particular fetch.  */
+  svn_ra_serf__handler_t *handler;
+
   /* The session we should use to fetch the file. */
   svn_ra_serf__session_t *sess;
 
@@ -916,7 +919,9 @@ handle_fetch(serf_request_t *request,
   apr_status_t status;
   report_fetch_t *fetch_ctx = handler_baton;
   svn_error_t *err;
-  serf_status_line sl;
+
+  /* ### new field. make sure we didn't miss some initialization.  */
+  SVN_ERR_ASSERT(fetch_ctx->handler != NULL);
 
   if (fetch_ctx->read_headers == FALSE)
     {
@@ -952,16 +957,12 @@ handle_fetch(serf_request_t *request,
 
   /* If the error code wasn't 200, something went wrong. Don't use the returned
      data as its probably an error message. Just bail out instead. */
-  status = serf_bucket_response_status(response, &sl);
-  if (SERF_BUCKET_READ_ERROR(status))
-    {
-      return svn_error_wrap_apr(status, NULL);
-    }
-  if (sl.code != 200)
+  if (fetch_ctx->handler->sline.code != 200)
     {
       err = svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
                               _("GET request failed: %d %s"),
-                              sl.code, sl.reason);
+                              fetch_ctx->handler->sline.code,
+                              fetch_ctx->handler->sline.reason);
       return error_fetch(request, fetch_ctx, err);
     }
 
@@ -1088,26 +1089,22 @@ handle_stream(serf_request_t *request,
               apr_pool_t *pool)
 {
   report_fetch_t *fetch_ctx = handler_baton;
-  serf_status_line sl;
   const char *location;
   svn_error_t *err;
   apr_status_t status;
 
-  status = serf_bucket_response_status(response, &sl);
-  if (SERF_BUCKET_READ_ERROR(status))
-    {
-      return svn_error_wrap_apr(status, NULL);
-    }
+  /* ### new field. make sure we didn't miss some initialization.  */
+  SVN_ERR_ASSERT(fetch_ctx->handler != NULL);
 
   /* Woo-hoo.  Nothing here to see.  */
   location = svn_ra_serf__response_get_location(response, pool);
 
-  err = svn_ra_serf__error_on_status(sl.code,
+  err = svn_ra_serf__error_on_status(fetch_ctx->handler->sline.code,
                                      fetch_ctx->info->name,
                                      location);
   if (err)
     {
-      fetch_ctx->done = TRUE;
+      fetch_ctx->handler->done = TRUE;
 
       err = svn_error_compose_create(
                   err,
@@ -1228,23 +1225,21 @@ handle_local_fetch(serf_request_t *reque
 {
   report_fetch_t *fetch_ctx = handler_baton;
   apr_status_t status;
-  serf_status_line sl;
   svn_error_t *err;
   const char *data;
   apr_size_t len;
 
+  /* ### new field. make sure we didn't miss some initialization.  */
+  SVN_ERR_ASSERT(fetch_ctx->handler != NULL);
+
   /* If the error code wasn't 200, something went wrong. Don't use the returned
      data as its probably an error message. Just bail out instead. */
-  status = serf_bucket_response_status(response, &sl);
-  if (SERF_BUCKET_READ_ERROR(status))
-    {
-      return svn_error_wrap_apr(status, NULL);
-    }
-  if (sl.code != 200)
+  if (fetch_ctx->handler->sline.code != 200)
     {
       err = svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL,
                               _("HEAD request failed: %d %s"),
-                              sl.code, sl.reason);
+                              fetch_ctx->handler->sline.code,
+                              fetch_ctx->handler->sline.reason);
       return error_fetch(request, fetch_ctx, err);
     }
 
@@ -1376,6 +1371,8 @@ fetch_file(report_context_t *ctx, report
           handler->response_handler = handle_local_fetch;
           handler->response_baton = fetch_ctx;
 
+          fetch_ctx->handler = handler;
+
           svn_ra_serf__request_create(handler);
 
           ctx->active_fetches++;
@@ -1408,6 +1405,8 @@ fetch_file(report_context_t *ctx, report
           handler->response_error = cancel_fetch;
           handler->response_error_baton = fetch_ctx;
 
+          fetch_ctx->handler = handler;
+
           svn_ra_serf__request_create(handler);
 
           ctx->active_fetches++;
@@ -2976,6 +2975,8 @@ svn_ra_serf__get_file(svn_ra_session_t *
       handler->response_error = cancel_fetch;
       handler->response_error_baton = stream_ctx;
 
+      stream_ctx->handler = handler;
+
       svn_ra_serf__request_create(handler);
 
       SVN_ERR(svn_ra_serf__context_run_wait(&stream_ctx->done, session, pool));



Mime
View raw message