Author: rhuijben Date: Sun Nov 29 00:24:31 2015 New Revision: 1717016 URL: http://svn.apache.org/viewvc?rev=1717016&view=rev Log: * buckets/split_buckets.c (serf_split_destroy): Clear some values.
* protocols/http2_protocol.c (http2_write_data): Clear some state. (serf_http2__ensure_writable): Fix edge case to avoid endless loop. * protocols/http2_stream.c (serf_http2__stream_pre_cleanup): Properly clear data_tail. (serf_http2__stream_cleanup): Really stop destroying data_tail. (stream_send_data): Mark stream closed when done. Ensure write again in all cases where we have to write again. Modified: serf/trunk/buckets/split_buckets.c serf/trunk/protocols/http2_protocol.c serf/trunk/protocols/http2_stream.c Modified: serf/trunk/buckets/split_buckets.c URL: http://svn.apache.org/viewvc/serf/trunk/buckets/split_buckets.c?rev=1717016&r1=1717015&r2=1717016&view=diff ============================================================================== --- serf/trunk/buckets/split_buckets.c (original) +++ serf/trunk/buckets/split_buckets.c Sun Nov 29 00:24:31 2015 @@ -374,6 +374,9 @@ static void serf_split_destroy(serf_buck sctx->next->prev = sctx->prev; else ctx->tail = sctx->prev; + + sctx->ctx = NULL; + sctx->prev = sctx->next = NULL; } serf_default_destroy_and_data(bucket); Modified: serf/trunk/protocols/http2_protocol.c URL: http://svn.apache.org/viewvc/serf/trunk/protocols/http2_protocol.c?rev=1717016&r1=1717015&r2=1717016&view=diff ============================================================================== --- serf/trunk/protocols/http2_protocol.c (original) +++ serf/trunk/protocols/http2_protocol.c Sun Nov 29 00:24:31 2015 @@ -1613,7 +1613,7 @@ static apr_status_t http2_write_data(ser { serf_http2_stream_t *stream = h2->cur_writable; - while (TRUE) + while (h2->lr_window > 0) { apr_status_t status; @@ -1637,7 +1637,8 @@ static apr_status_t http2_write_data(ser else h2->last_writable = stream->prev_writable; - stream = stream->next_writable; + stream->prev_writable = stream->next_writable = NULL; + stream = NULL; continue; } @@ -2052,8 +2053,8 @@ void serf_http2__ensure_writable(serf_ht stream->prev_writable = h2->last_writable; h2->last_writable = stream; - if (h2->first_writable) - h2->last_writable->next_writable = stream; + if (stream->prev_writable) + stream->prev_writable->next_writable = stream; else h2->first_writable = stream; } Modified: serf/trunk/protocols/http2_stream.c URL: http://svn.apache.org/viewvc/serf/trunk/protocols/http2_stream.c?rev=1717016&r1=1717015&r2=1717016&view=diff ============================================================================== --- serf/trunk/protocols/http2_stream.c (original) +++ serf/trunk/protocols/http2_stream.c Sun Nov 29 00:24:31 2015 @@ -87,8 +87,10 @@ void serf_http2__stream_pre_cleanup(serf_http2_stream_t *stream) { if (stream->data) { - if (stream->data->data_tail) + if (stream->data->data_tail) { serf_bucket_destroy(stream->data->data_tail); + stream->data->data_tail = NULL; + } } } @@ -99,9 +101,6 @@ serf_http2__stream_cleanup(serf_http2_st if (stream->data->response_agg) serf_bucket_destroy(stream->data->response_agg); - if (stream->data->data_tail) - serf_bucket_destroy(stream->data->data_tail); - serf_bucket_mem_free(stream->alloc, stream->data); stream->data = NULL; } @@ -267,6 +266,10 @@ static apr_status_t stream_send_data(ser if (prefix_len == 0) { /* No window left */ stream->data->data_tail = data; + + /* Write more later */ + serf_http2__ensure_writable(stream); + return APR_SUCCESS; } @@ -284,10 +287,18 @@ static apr_status_t stream_send_data(ser data_write_started, data_write_done, NULL, stream->alloc); end_stream = false; + + serf_http2__ensure_writable(stream); } - else + else { end_stream = true; + if (stream->status == H2S_OPEN) + stream->status = H2S_HALFCLOSED_LOCAL; + else + stream->status = H2S_CLOSED; + } + next = serf__bucket_http2_frame_create(data, HTTP2_FRAME_TYPE_DATA, end_stream ? HTTP2_FLAG_END_STREAM : 0, @@ -298,11 +309,6 @@ static apr_status_t stream_send_data(ser status = serf_http2__enqueue_frame(stream->h2, next, TRUE); - if (!end_stream) { - /* Write more later */ - serf_http2__ensure_writable(stream); - } - return status; }