You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2016/03/16 16:16:01 UTC
svn commit: r1735239 [2/2] - in /httpd/httpd/branches/2.4.x: ./
modules/http2/
Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.c?rev=1735239&r1=1735238&r2=1735239&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.c Wed Mar 16 15:16:00 2016
@@ -42,9 +42,6 @@ h2_task_output *h2_task_output_create(h2
output->task = task;
output->state = H2_TASK_OUT_INIT;
output->from_h1 = h2_from_h1_create(task->stream_id, c->pool);
- if (!output->from_h1) {
- return NULL;
- }
}
return output;
}
@@ -66,47 +63,43 @@ static apr_table_t *get_trailers(h2_task
return NULL;
}
-static apr_status_t open_if_needed(h2_task_output *output, ap_filter_t *f,
- apr_bucket_brigade *bb, const char *caller)
+static apr_status_t open_response(h2_task_output *output, ap_filter_t *f,
+ apr_bucket_brigade *bb, const char *caller)
{
- if (output->state == H2_TASK_OUT_INIT) {
- h2_response *response;
- output->state = H2_TASK_OUT_STARTED;
- response = h2_from_h1_get_response(output->from_h1);
- if (!response) {
- if (f) {
- /* This happens currently when ap_die(status, r) is invoked
- * by a read request filter. */
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, output->c, APLOGNO(03204)
- "h2_task_output(%s): write without response by %s "
- "for %s %s %s",
- output->task->id, caller,
- output->task->request->method,
- output->task->request->authority,
- output->task->request->path);
- output->c->aborted = 1;
- }
- if (output->task->io) {
- apr_thread_cond_broadcast(output->task->io);
- }
- return APR_ECONNABORTED;
- }
-
- if (h2_task_logio_add_bytes_out) {
- /* counter headers as if we'd do a HTTP/1.1 serialization */
- output->written = h2_util_table_bytes(response->headers, 3)+1;
- h2_task_logio_add_bytes_out(output->c, output->written);
- }
- get_trailers(output);
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, output->c, APLOGNO(03348)
- "h2_task(%s): open response to %s %s %s",
- output->task->id, output->task->request->method,
- output->task->request->authority,
- output->task->request->path);
- return h2_mplx_out_open(output->task->mplx, output->task->stream_id,
- response, f, bb, output->task->io);
- }
- return APR_SUCCESS;
+ h2_response *response;
+ response = h2_from_h1_get_response(output->from_h1);
+ if (!response) {
+ if (f) {
+ /* This happens currently when ap_die(status, r) is invoked
+ * by a read request filter. */
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, output->c, APLOGNO(03204)
+ "h2_task_output(%s): write without response by %s "
+ "for %s %s %s",
+ output->task->id, caller,
+ output->task->request->method,
+ output->task->request->authority,
+ output->task->request->path);
+ output->c->aborted = 1;
+ }
+ if (output->task->io) {
+ apr_thread_cond_broadcast(output->task->io);
+ }
+ return APR_ECONNABORTED;
+ }
+
+ if (h2_task_logio_add_bytes_out) {
+ /* count headers as if we'd do a HTTP/1.1 serialization */
+ output->written = h2_util_table_bytes(response->headers, 3)+1;
+ h2_task_logio_add_bytes_out(output->c, output->written);
+ }
+ get_trailers(output);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, output->c, APLOGNO(03348)
+ "h2_task(%s): open response to %s %s %s",
+ output->task->id, output->task->request->method,
+ output->task->request->authority,
+ output->task->request->path);
+ return h2_mplx_out_open(output->task->mplx, output->task->stream_id,
+ response, f, bb, output->task->io);
}
static apr_status_t write_brigade_raw(h2_task_output *output,
@@ -145,7 +138,7 @@ static apr_status_t write_brigade_raw(h2
apr_status_t h2_task_output_write(h2_task_output *output,
ap_filter_t* f, apr_bucket_brigade* bb)
{
- apr_status_t status;
+ apr_status_t status = APR_SUCCESS;
if (APR_BRIGADE_EMPTY(bb)) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, output->c,
@@ -155,15 +148,17 @@ apr_status_t h2_task_output_write(h2_tas
if (output->task->frozen) {
h2_util_bb_log(output->c, output->task->stream_id, APLOG_TRACE2,
- "frozen task output write", bb);
- return ap_save_brigade(f, &output->frozen_bb, &bb, output->c->pool);
+ "frozen task output write, ignored", bb);
+ return APR_SUCCESS;
}
- status = open_if_needed(output, f, bb, "write");
+ if (output->state == H2_TASK_OUT_INIT) {
+ status = open_response(output, f, bb, "write");
+ output->state = H2_TASK_OUT_STARTED;
+ }
/* Attempt to write saved brigade first */
- if (status == APR_SUCCESS && output->bb
- && !APR_BRIGADE_EMPTY(output->bb)) {
+ if (status == APR_SUCCESS && output->bb && !APR_BRIGADE_EMPTY(output->bb)) {
status = write_brigade_raw(output, f, output->bb);
}
@@ -188,20 +183,3 @@ apr_status_t h2_task_output_write(h2_tas
return status;
}
-void h2_task_output_close(h2_task_output *output)
-{
- if (output->task->frozen) {
- return;
- }
- open_if_needed(output, NULL, NULL, "close");
- if (output->state != H2_TASK_OUT_DONE) {
- if (output->frozen_bb && !APR_BRIGADE_EMPTY(output->frozen_bb)) {
- h2_mplx_out_write(output->task->mplx, output->task->stream_id,
- NULL, 1, output->frozen_bb, NULL, NULL);
- }
- output->state = H2_TASK_OUT_DONE;
- h2_mplx_out_close(output->task->mplx, output->task->stream_id,
- get_trailers(output));
- }
-}
-
Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.h?rev=1735239&r1=1735238&r2=1735239&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.h (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_task_output.h Wed Mar 16 15:16:00 2016
@@ -44,7 +44,6 @@ struct h2_task_output {
apr_off_t written;
apr_bucket_brigade *bb;
- apr_bucket_brigade *frozen_bb;
};
h2_task_output *h2_task_output_create(struct h2_task *task, conn_rec *c);
@@ -53,8 +52,6 @@ apr_status_t h2_task_output_write(h2_tas
ap_filter_t* filter,
apr_bucket_brigade* brigade);
-void h2_task_output_close(h2_task_output *output);
-
apr_status_t h2_task_output_freeze(h2_task_output *output);
apr_status_t h2_task_output_thaw(h2_task_output *output);
Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_util.c?rev=1735239&r1=1735238&r2=1735239&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_util.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_util.c Wed Mar 16 15:16:00 2016
@@ -14,7 +14,6 @@
*/
#include <assert.h>
-
#include <apr_strings.h>
#include <httpd.h>
@@ -537,6 +536,7 @@ apr_status_t h2_util_move(apr_bucket_bri
else {
const char *data;
apr_size_t len;
+
status = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
if (status == APR_SUCCESS && len > 0) {
status = apr_brigade_write(to, NULL, NULL, data, len);
@@ -635,20 +635,6 @@ apr_status_t h2_util_copy(apr_bucket_bri
return status;
}
-int h2_util_has_flush_or_eos(apr_bucket_brigade *bb)
-{
- apr_bucket *b;
- for (b = APR_BRIGADE_FIRST(bb);
- b != APR_BRIGADE_SENTINEL(bb);
- b = APR_BUCKET_NEXT(b))
- {
- if (APR_BUCKET_IS_EOS(b) || APR_BUCKET_IS_FLUSH(b)) {
- return 1;
- }
- }
- return 0;
-}
-
int h2_util_has_eos(apr_bucket_brigade *bb, apr_off_t len)
{
apr_bucket *b, *end;
@@ -949,6 +935,27 @@ apr_status_t h2_transfer_brigade(apr_buc
return APR_SUCCESS;
}
+apr_off_t h2_brigade_mem_size(apr_bucket_brigade *bb)
+{
+ apr_bucket *b;
+ apr_off_t total = 0;
+
+ for (b = APR_BRIGADE_FIRST(bb);
+ b != APR_BRIGADE_SENTINEL(bb);
+ b = APR_BUCKET_NEXT(b))
+ {
+ total += sizeof(*b);
+ if (b->length > 0) {
+ if (APR_BUCKET_IS_HEAP(b)
+ || APR_BUCKET_IS_POOL(b)) {
+ total += b->length;
+ }
+ }
+ }
+ return total;
+}
+
+
/*******************************************************************************
* h2_ngheader
******************************************************************************/
Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_util.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_util.h?rev=1735239&r1=1735238&r2=1735239&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_util.h (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_util.h Wed Mar 16 15:16:00 2016
@@ -196,7 +196,6 @@ apr_status_t h2_util_copy(apr_bucket_bri
* @param bb the brigade to check on
* @return != 0 iff brigade holds FLUSH or EOS bucket (or both)
*/
-int h2_util_has_flush_or_eos(apr_bucket_brigade *bb);
int h2_util_has_eos(apr_bucket_brigade *bb, apr_off_t len);
int h2_util_bb_has_data(apr_bucket_brigade *bb);
int h2_util_bb_has_data_or_eos(apr_bucket_brigade *bb);
@@ -257,4 +256,13 @@ apr_status_t h2_transfer_brigade(apr_buc
apr_off_t *plen,
int *peos);
+/**
+ * Get an approximnation of the memory footprint of the given
+ * brigade. This varies from apr_brigade_length as
+ * - no buckets are ever read
+ * - only buckets known to allocate memory (HEAP+POOL) are counted
+ * - the bucket struct itself is counted
+ */
+apr_off_t h2_brigade_mem_size(apr_bucket_brigade *bb);
+
#endif /* defined(__mod_h2__h2_util__) */
Modified: httpd/httpd/branches/2.4.x/modules/http2/h2_version.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/h2_version.h?rev=1735239&r1=1735238&r2=1735239&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/h2_version.h (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/h2_version.h Wed Mar 16 15:16:00 2016
@@ -26,7 +26,7 @@
* @macro
* Version number of the http2 module as c string
*/
-#define MOD_HTTP2_VERSION "1.4.1"
+#define MOD_HTTP2_VERSION "1.4.2"
/**
* @macro
@@ -34,7 +34,7 @@
* release. This is a 24 bit number with 8 bits for major number, 8 bits
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
*/
-#define MOD_HTTP2_VERSION_NUM 0x010401
+#define MOD_HTTP2_VERSION_NUM 0x010402
#endif /* mod_h2_h2_version_h */
Modified: httpd/httpd/branches/2.4.x/modules/http2/mod_http2.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/mod_http2.c?rev=1735239&r1=1735238&r2=1735239&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/mod_http2.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/mod_http2.c Wed Mar 16 15:16:00 2016
@@ -130,7 +130,7 @@ static int http2_is_h2(conn_rec *);
static apr_status_t http2_req_engine_push(const char *ngn_type,
request_rec *r,
- h2_req_engine_init *einit)
+ http2_req_engine_init *einit)
{
return h2_mplx_req_engine_push(ngn_type, r, einit);
}
Modified: httpd/httpd/branches/2.4.x/modules/http2/mod_http2.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http2/mod_http2.h?rev=1735239&r1=1735238&r2=1735239&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http2/mod_http2.h (original)
+++ httpd/httpd/branches/2.4.x/modules/http2/mod_http2.h Wed Mar 16 15:16:00 2016
@@ -36,6 +36,8 @@ struct apr_thread_cond_t;
typedef struct h2_req_engine h2_req_engine;
+typedef void http2_output_consumed(void *ctx, conn_rec *c, apr_off_t consumed);
+
/**
* Initialize a h2_req_engine. The structure will be passed in but
* only the name and master are set. The function should initialize
@@ -43,12 +45,14 @@ typedef struct h2_req_engine h2_req_engi
* @param engine the allocated, partially filled structure
* @param r the first request to process, or NULL
*/
-typedef apr_status_t h2_req_engine_init(h2_req_engine *engine,
- const char *id,
- const char *type,
- apr_pool_t *pool,
- apr_uint32_t req_buffer_size,
- request_rec *r);
+typedef apr_status_t http2_req_engine_init(h2_req_engine *engine,
+ const char *id,
+ const char *type,
+ apr_pool_t *pool,
+ apr_uint32_t req_buffer_size,
+ request_rec *r,
+ http2_output_consumed **pconsumed,
+ void **pbaton);
/**
* Push a request to an engine with the specified name for further processing.
@@ -66,7 +70,7 @@ typedef apr_status_t h2_req_engine_init(
APR_DECLARE_OPTIONAL_FN(apr_status_t,
http2_req_engine_push, (const char *engine_type,
request_rec *r,
- h2_req_engine_init *einit));
+ http2_req_engine_init *einit));
/**
* Get a new request for processing in this engine.