Author: rhuijben
Date: Wed Nov  4 20:13:34 2015
New Revision: 1712628

URL: http://svn.apache.org/viewvc?rev=1712628&view=rev
Log:
Following up on r1712622, consistently assume that the bucket is now owned
by the output stream as soon as writing_started is set.

* connection_request.c
  (clean_resp,
   serf__destroy_request): Don't destroy bucket after writing started. Will be 
destroyed
                           with stream.

* outgoing.c
  (write_to_connection): Check for writing started a bit earlier.

Modified:
    serf/trunk/connection_request.c
    serf/trunk/outgoing.c

Modified: serf/trunk/connection_request.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/connection_request.c?rev=1712628&r1=1712627&r2=1712628&view=diff
==============================================================================
--- serf/trunk/connection_request.c (original)
+++ serf/trunk/connection_request.c Wed Nov  4 20:13:34 2015
@@ -44,7 +44,8 @@ static apr_status_t clean_resp(void *dat
         request->resp_bkt = NULL;
     }
     if (request->req_bkt) {
-        serf_bucket_destroy(request->req_bkt);
+        if (!request->writing_started)
+            serf_bucket_destroy(request->req_bkt);
         request->req_bkt = NULL;
     }
 
@@ -85,7 +86,9 @@ apr_status_t serf__destroy_request(serf_
     }
     if (request->req_bkt) {
         serf_debug__closed_conn(request->req_bkt->allocator);
-        serf_bucket_destroy(request->req_bkt);
+
+        if (!request->writing_started)
+            serf_bucket_destroy(request->req_bkt);
         request->req_bkt = NULL;
     }
 

Modified: serf/trunk/outgoing.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/outgoing.c?rev=1712628&r1=1712627&r2=1712628&view=diff
==============================================================================
--- serf/trunk/outgoing.c (original)
+++ serf/trunk/outgoing.c Wed Nov  4 20:13:34 2015
@@ -863,7 +863,7 @@ static apr_status_t write_to_connection(
             return status;
         }
 
-        if (request) {
+        if (request && !request->writing_started) {
             if (request->req_bkt == NULL) {
                 read_status = serf__setup_request(request);
                 if (read_status) {
@@ -872,13 +872,8 @@ static apr_status_t write_to_connection(
                 }
             }
 
-            if (!request->writing_started) {
-                request->writing_started = 1;
-                serf_bucket_aggregate_append(
-                          ostreamt,
-                          serf_bucket_barrier_create(request->req_bkt,
-                                                     request->allocator));
-            }
+            request->writing_started = 1;
+            serf_bucket_aggregate_append(ostreamt, request->req_bkt);
         }
 
         /* If we got some data, then deliver it. */
@@ -898,7 +893,6 @@ static apr_status_t write_to_connection(
              * - we'll see if there are other requests that need to be sent 
              * ("pipelining").
              */
-            serf_bucket_destroy(request->req_bkt);
             request->req_bkt = NULL;
 
             /* Move the request to the written queue */


Reply via email to