mirror of
https://github.com/apache/httpd.git
synced 2025-08-07 04:02:58 +03:00
Revert style changes
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1630971 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -109,7 +109,6 @@ static apr_status_t bucketeer_out_filter(ap_filter_t *f,
|
|||||||
if (APR_BUCKET_IS_METADATA(e)) {
|
if (APR_BUCKET_IS_METADATA(e)) {
|
||||||
/* metadata bucket */
|
/* metadata bucket */
|
||||||
apr_bucket *cpy;
|
apr_bucket *cpy;
|
||||||
|
|
||||||
apr_bucket_copy(e, &cpy);
|
apr_bucket_copy(e, &cpy);
|
||||||
APR_BRIGADE_INSERT_TAIL(ctx->bb, cpy);
|
APR_BRIGADE_INSERT_TAIL(ctx->bb, cpy);
|
||||||
continue;
|
continue;
|
||||||
@@ -125,14 +124,13 @@ static apr_status_t bucketeer_out_filter(ap_filter_t *f,
|
|||||||
data[i] == c->bucketdelimiter ||
|
data[i] == c->bucketdelimiter ||
|
||||||
data[i] == c->passdelimiter) {
|
data[i] == c->passdelimiter) {
|
||||||
apr_bucket *p;
|
apr_bucket *p;
|
||||||
|
|
||||||
if (i - lastpos > 0) {
|
if (i - lastpos > 0) {
|
||||||
p = apr_bucket_pool_create(apr_pmemdup(f->r->pool,
|
p = apr_bucket_pool_create(apr_pmemdup(f->r->pool,
|
||||||
&data[lastpos],
|
&data[lastpos],
|
||||||
i - lastpos),
|
i - lastpos),
|
||||||
i - lastpos,
|
i - lastpos,
|
||||||
f->r->pool,
|
f->r->pool,
|
||||||
f->c->bucket_alloc);
|
f->c->bucket_alloc);
|
||||||
APR_BRIGADE_INSERT_TAIL(ctx->bb, p);
|
APR_BRIGADE_INSERT_TAIL(ctx->bb, p);
|
||||||
}
|
}
|
||||||
lastpos = i + 1;
|
lastpos = i + 1;
|
||||||
@@ -168,7 +166,7 @@ static apr_status_t bucketeer_out_filter(ap_filter_t *f,
|
|||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register_hooks(apr_pool_t *p)
|
static void register_hooks(apr_pool_t * p)
|
||||||
{
|
{
|
||||||
ap_register_output_filter(bucketeerFilterName, bucketeer_out_filter,
|
ap_register_output_filter(bucketeerFilterName, bucketeer_out_filter,
|
||||||
NULL, AP_FTYPE_RESOURCE-1);
|
NULL, AP_FTYPE_RESOURCE-1);
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
* It can produce a *huge* amount of data.
|
* It can produce a *huge* amount of data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "httpd.h"
|
#include "httpd.h"
|
||||||
#include "http_connection.h"
|
#include "http_connection.h"
|
||||||
#include "http_config.h"
|
#include "http_config.h"
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
#include "http_log.h"
|
#include "http_log.h"
|
||||||
#include "apr_strings.h"
|
#include "apr_strings.h"
|
||||||
|
|
||||||
module AP_MODULE_DECLARE_DATA dumpio_module;
|
module AP_MODULE_DECLARE_DATA dumpio_module ;
|
||||||
|
|
||||||
typedef struct dumpio_conf_t {
|
typedef struct dumpio_conf_t {
|
||||||
int enable_input;
|
int enable_input;
|
||||||
@@ -59,9 +60,10 @@ static void dumpit(ap_filter_t *f, apr_bucket *b, dumpio_conf_t *ptr)
|
|||||||
f->frec->name,
|
f->frec->name,
|
||||||
(APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data",
|
(APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data",
|
||||||
b->type->name,
|
b->type->name,
|
||||||
b->length);
|
b->length) ;
|
||||||
|
|
||||||
if (!(APR_BUCKET_IS_METADATA(b))) {
|
if (!(APR_BUCKET_IS_METADATA(b)))
|
||||||
|
{
|
||||||
#if APR_CHARSET_EBCDIC
|
#if APR_CHARSET_EBCDIC
|
||||||
char xlatebuf[dumpio_MAX_STRING_LEN + 1];
|
char xlatebuf[dumpio_MAX_STRING_LEN + 1];
|
||||||
#endif
|
#endif
|
||||||
@@ -69,10 +71,11 @@ static void dumpit(ap_filter_t *f, apr_bucket *b, dumpio_conf_t *ptr)
|
|||||||
apr_size_t nbytes;
|
apr_size_t nbytes;
|
||||||
apr_status_t rv = apr_bucket_read(b, &buf, &nbytes, APR_BLOCK_READ);
|
apr_status_t rv = apr_bucket_read(b, &buf, &nbytes, APR_BLOCK_READ);
|
||||||
|
|
||||||
if (rv == APR_SUCCESS) {
|
if (rv == APR_SUCCESS)
|
||||||
while (nbytes) {
|
{
|
||||||
|
while (nbytes)
|
||||||
|
{
|
||||||
apr_size_t logbytes = nbytes;
|
apr_size_t logbytes = nbytes;
|
||||||
|
|
||||||
if (logbytes > dumpio_MAX_STRING_LEN)
|
if (logbytes > dumpio_MAX_STRING_LEN)
|
||||||
logbytes = dumpio_MAX_STRING_LEN;
|
logbytes = dumpio_MAX_STRING_LEN;
|
||||||
nbytes -= logbytes;
|
nbytes -= logbytes;
|
||||||
@@ -120,10 +123,10 @@ static void dumpit(ap_filter_t *f, apr_bucket *b, dumpio_conf_t *ptr)
|
|||||||
(( mode ) == AP_MODE_INIT) ? "init" : "unknown" \
|
(( mode ) == AP_MODE_INIT) ? "init" : "unknown" \
|
||||||
)
|
)
|
||||||
|
|
||||||
static int dumpio_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
|
static int dumpio_input_filter (ap_filter_t *f, apr_bucket_brigade *bb,
|
||||||
ap_input_mode_t mode, apr_read_type_e block,
|
ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
|
||||||
apr_off_t readbytes)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
apr_bucket *b;
|
apr_bucket *b;
|
||||||
apr_status_t ret;
|
apr_status_t ret;
|
||||||
conn_rec *c = f->c;
|
conn_rec *c = f->c;
|
||||||
@@ -139,33 +142,28 @@ static int dumpio_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
|
|||||||
ret = ap_get_brigade(f->next, bb, mode, block, readbytes);
|
ret = ap_get_brigade(f->next, bb, mode, block, readbytes);
|
||||||
|
|
||||||
if (ret == APR_SUCCESS) {
|
if (ret == APR_SUCCESS) {
|
||||||
for (b = APR_BRIGADE_FIRST(bb);
|
for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) {
|
||||||
b != APR_BRIGADE_SENTINEL(bb);
|
dumpit(f, b, ptr);
|
||||||
b = APR_BUCKET_NEXT(b)) {
|
|
||||||
dumpit(f, b, ptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ap_log_cerror(APLOG_MARK, APLOG_TRACE7, 0, c,
|
ap_log_cerror(APLOG_MARK, APLOG_TRACE7, 0, c,
|
||||||
"mod_dumpio: %s - %d", f->frec->name, ret);
|
"mod_dumpio: %s - %d", f->frec->name, ret) ;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dumpio_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
|
static int dumpio_output_filter (ap_filter_t *f, apr_bucket_brigade *bb)
|
||||||
{
|
{
|
||||||
apr_bucket *b;
|
apr_bucket *b;
|
||||||
conn_rec *c = f->c;
|
conn_rec *c = f->c;
|
||||||
dumpio_conf_t *ptr = f->ctx;
|
dumpio_conf_t *ptr = f->ctx;
|
||||||
|
|
||||||
ap_log_cerror(APLOG_MARK, APLOG_TRACE7, 0, c, "mod_dumpio: %s",
|
ap_log_cerror(APLOG_MARK, APLOG_TRACE7, 0, c, "mod_dumpio: %s", f->frec->name);
|
||||||
f->frec->name);
|
|
||||||
|
|
||||||
for (b = APR_BRIGADE_FIRST(bb);
|
for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) {
|
||||||
b != APR_BRIGADE_SENTINEL(bb);
|
|
||||||
b = APR_BUCKET_NEXT(b)) {
|
|
||||||
/*
|
/*
|
||||||
* If we ever see an EOS, make sure to FLUSH.
|
* If we ever see an EOS, make sure to FLUSH.
|
||||||
*/
|
*/
|
||||||
@@ -176,15 +174,15 @@ static int dumpio_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
|
|||||||
dumpit(f, b, ptr);
|
dumpit(f, b, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ap_pass_brigade(f->next, bb);
|
return ap_pass_brigade(f->next, bb) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dumpio_pre_conn(conn_rec *c, void *csd)
|
static int dumpio_pre_conn(conn_rec *c, void *csd)
|
||||||
{
|
{
|
||||||
dumpio_conf_t *ptr;
|
dumpio_conf_t *ptr;
|
||||||
|
|
||||||
ptr = (dumpio_conf_t *)ap_get_module_config(c->base_server->module_config,
|
ptr = (dumpio_conf_t *) ap_get_module_config(c->base_server->module_config,
|
||||||
&dumpio_module);
|
&dumpio_module);
|
||||||
|
|
||||||
if (ptr->enable_input)
|
if (ptr->enable_input)
|
||||||
ap_add_input_filter("DUMPIO_IN", ptr, NULL, c);
|
ap_add_input_filter("DUMPIO_IN", ptr, NULL, c);
|
||||||
@@ -195,22 +193,21 @@ static int dumpio_pre_conn(conn_rec *c, void *csd)
|
|||||||
|
|
||||||
static void dumpio_register_hooks(apr_pool_t *p)
|
static void dumpio_register_hooks(apr_pool_t *p)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We know that SSL is CONNECTION + 5
|
* We know that SSL is CONNECTION + 5
|
||||||
*/
|
*/
|
||||||
ap_register_output_filter("DUMPIO_OUT", dumpio_output_filter,
|
ap_register_output_filter("DUMPIO_OUT", dumpio_output_filter,
|
||||||
NULL, AP_FTYPE_CONNECTION + 3);
|
NULL, AP_FTYPE_CONNECTION + 3) ;
|
||||||
|
|
||||||
ap_register_input_filter("DUMPIO_IN", dumpio_input_filter,
|
ap_register_input_filter("DUMPIO_IN", dumpio_input_filter,
|
||||||
NULL, AP_FTYPE_CONNECTION + 3);
|
NULL, AP_FTYPE_CONNECTION + 3) ;
|
||||||
|
|
||||||
ap_hook_pre_connection(dumpio_pre_conn, NULL, NULL, APR_HOOK_MIDDLE);
|
ap_hook_pre_connection(dumpio_pre_conn, NULL, NULL, APR_HOOK_MIDDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dumpio_create_sconfig(apr_pool_t *p, server_rec *s)
|
static void *dumpio_create_sconfig(apr_pool_t *p, server_rec *s)
|
||||||
{
|
{
|
||||||
dumpio_conf_t *ptr = apr_pcalloc(p, sizeof *ptr);
|
dumpio_conf_t *ptr = apr_pcalloc(p, sizeof *ptr);
|
||||||
|
|
||||||
ptr->enable_input = 0;
|
ptr->enable_input = 0;
|
||||||
ptr->enable_output = 0;
|
ptr->enable_output = 0;
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@@ -106,16 +106,14 @@ typedef struct firehose_ctx_t
|
|||||||
|
|
||||||
static apr_status_t filter_output_cleanup(void *dummy)
|
static apr_status_t filter_output_cleanup(void *dummy)
|
||||||
{
|
{
|
||||||
ap_filter_t *f = (ap_filter_t *)dummy;
|
ap_filter_t *f = (ap_filter_t *) dummy;
|
||||||
|
|
||||||
ap_remove_output_filter(f);
|
ap_remove_output_filter(f);
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static apr_status_t filter_input_cleanup(void *dummy)
|
static apr_status_t filter_input_cleanup(void *dummy)
|
||||||
{
|
{
|
||||||
ap_filter_t *f = (ap_filter_t *)dummy;
|
ap_filter_t *f = (ap_filter_t *) dummy;
|
||||||
|
|
||||||
ap_remove_input_filter(f);
|
ap_remove_input_filter(f);
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -125,7 +123,7 @@ static apr_status_t filter_input_cleanup(void *dummy)
|
|||||||
*/
|
*/
|
||||||
static apr_status_t pumpit_cleanup(void *dummy)
|
static apr_status_t pumpit_cleanup(void *dummy)
|
||||||
{
|
{
|
||||||
firehose_ctx_t *ctx = (firehose_ctx_t *)dummy;
|
firehose_ctx_t *ctx = (firehose_ctx_t *) dummy;
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
apr_size_t hdr_len;
|
apr_size_t hdr_len;
|
||||||
char header[HEADER_LEN + 1];
|
char header[HEADER_LEN + 1];
|
||||||
@@ -135,8 +133,8 @@ static apr_status_t pumpit_cleanup(void *dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hdr_len = apr_snprintf(header, sizeof(header), HEADER_FMT,
|
hdr_len = apr_snprintf(header, sizeof(header), HEADER_FMT,
|
||||||
(apr_uint64_t)0, (apr_uint64_t)apr_time_now(),
|
(apr_uint64_t) 0, (apr_uint64_t) apr_time_now(), ctx->direction,
|
||||||
ctx->direction, ctx->uuid, ctx->count);
|
ctx->uuid, ctx->count);
|
||||||
ap_xlate_proto_to_ascii(header, hdr_len);
|
ap_xlate_proto_to_ascii(header, hdr_len);
|
||||||
|
|
||||||
rv = apr_file_write_full(ctx->conn->file, header, hdr_len, NULL);
|
rv = apr_file_write_full(ctx->conn->file, header, hdr_len, NULL);
|
||||||
@@ -145,24 +143,22 @@ static apr_status_t pumpit_cleanup(void *dummy)
|
|||||||
/* ignore the error */
|
/* ignore the error */
|
||||||
}
|
}
|
||||||
else if (ctx->r) {
|
else if (ctx->r) {
|
||||||
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, ctx->r,
|
ap_log_rerror(
|
||||||
"mod_firehose: could not write %"
|
APLOG_MARK,
|
||||||
APR_UINT64_T_FMT
|
APLOG_WARNING,
|
||||||
" bytes to '%s' for '%c' connection '%s' and"
|
rv,
|
||||||
" count '%0" APR_UINT64_T_HEX_FMT "', bytes"
|
ctx->r,
|
||||||
" dropped (further errors will be suppressed)",
|
"mod_firehose: could not write %" APR_UINT64_T_FMT " bytes to '%s' for '%c' connection '%s' and count '%0" APR_UINT64_T_HEX_FMT "', bytes dropped (further errors will be suppressed)",
|
||||||
(apr_uint64_t)(hdr_len), ctx->conn->filename,
|
(apr_uint64_t)(hdr_len), ctx->conn->filename, ctx->conn->direction, ctx->uuid, ctx->count);
|
||||||
ctx->conn->direction, ctx->uuid, ctx->count);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ap_log_cerror(APLOG_MARK, APLOG_WARNING, rv, ctx->c,
|
ap_log_cerror(
|
||||||
"mod_firehose: could not write %"
|
APLOG_MARK,
|
||||||
APR_UINT64_T_FMT
|
APLOG_WARNING,
|
||||||
" bytes to '%s' for '%c' connection '%s' and"
|
rv,
|
||||||
" count '%0" APR_UINT64_T_HEX_FMT "', bytes"
|
ctx->c,
|
||||||
" dropped (further errors will be suppressed)",
|
"mod_firehose: could not write %" APR_UINT64_T_FMT " bytes to '%s' for '%c' connection '%s' and count '%0" APR_UINT64_T_HEX_FMT "', bytes dropped (further errors will be suppressed)",
|
||||||
(apr_uint64_t)(hdr_len), ctx->conn->filename,
|
(apr_uint64_t)(hdr_len), ctx->conn->filename, ctx->conn->direction, ctx->uuid, ctx->count);
|
||||||
ctx->conn->direction, ctx->uuid, ctx->count);
|
|
||||||
}
|
}
|
||||||
ctx->conn->suppress = 1;
|
ctx->conn->suppress = 1;
|
||||||
}
|
}
|
||||||
@@ -212,14 +208,13 @@ static apr_status_t pumpit(ap_filter_t *f, apr_bucket *b, firehose_ctx_t *ctx)
|
|||||||
* the chunk.
|
* the chunk.
|
||||||
*/
|
*/
|
||||||
hdr_len = apr_snprintf(header, sizeof(header), HEADER_FMT,
|
hdr_len = apr_snprintf(header, sizeof(header), HEADER_FMT,
|
||||||
(apr_uint64_t)body_len,
|
(apr_uint64_t) body_len, (apr_uint64_t) apr_time_now(),
|
||||||
(apr_uint64_t)apr_time_now(),
|
ctx->direction, ctx->uuid, ctx->count);
|
||||||
ctx->direction, ctx->uuid, ctx->count);
|
|
||||||
ap_xlate_proto_to_ascii(header, hdr_len);
|
ap_xlate_proto_to_ascii(header, hdr_len);
|
||||||
|
|
||||||
vec[0].iov_base = header;
|
vec[0].iov_base = header;
|
||||||
vec[0].iov_len = hdr_len;
|
vec[0].iov_len = hdr_len;
|
||||||
vec[1].iov_base = (void *)(buf + offset);
|
vec[1].iov_base = (void *) (buf + offset);
|
||||||
vec[1].iov_len = body_len;
|
vec[1].iov_len = body_len;
|
||||||
vec[2].iov_base = CRLF;
|
vec[2].iov_base = CRLF;
|
||||||
vec[2].iov_len = 2;
|
vec[2].iov_len = 2;
|
||||||
@@ -230,32 +225,22 @@ static apr_status_t pumpit(ap_filter_t *f, apr_bucket *b, firehose_ctx_t *ctx)
|
|||||||
/* ignore the error */
|
/* ignore the error */
|
||||||
}
|
}
|
||||||
else if (ctx->r) {
|
else if (ctx->r) {
|
||||||
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, ctx->r,
|
ap_log_rerror(
|
||||||
"mod_firehose: could not write %"
|
APLOG_MARK,
|
||||||
APR_UINT64_T_FMT
|
APLOG_WARNING,
|
||||||
" bytes to '%s' for '%c' connection '%s' and"
|
rv,
|
||||||
" count '%0" APR_UINT64_T_HEX_FMT "', bytes"
|
ctx->r,
|
||||||
" dropped (further errors will be suppressed)",
|
"mod_firehose: could not write %" APR_UINT64_T_FMT " bytes to '%s' for '%c' connection '%s' and count '%0" APR_UINT64_T_HEX_FMT "', bytes dropped (further errors will be suppressed)",
|
||||||
(apr_uint64_t)(vec[0].iov_len +
|
(apr_uint64_t)(vec[0].iov_len + vec[1].iov_len + vec[2].iov_len), ctx->conn->filename, ctx->conn->direction, ctx->uuid, ctx->count);
|
||||||
vec[1].iov_len +
|
|
||||||
vec[2].iov_len),
|
|
||||||
ctx->conn->filename,
|
|
||||||
ctx->conn->direction, ctx->uuid,
|
|
||||||
ctx->count);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ap_log_cerror(APLOG_MARK, APLOG_WARNING, rv, ctx->c,
|
ap_log_cerror(
|
||||||
"mod_firehose: could not write %"
|
APLOG_MARK,
|
||||||
APR_UINT64_T_FMT
|
APLOG_WARNING,
|
||||||
" bytes to '%s' for '%c' connection '%s' and"
|
rv,
|
||||||
" count '%0" APR_UINT64_T_HEX_FMT "', bytes"
|
ctx->c,
|
||||||
" dropped (further errors will be suppressed)",
|
"mod_firehose: could not write %" APR_UINT64_T_FMT " bytes to '%s' for '%c' connection '%s' and count '%0" APR_UINT64_T_HEX_FMT "', bytes dropped (further errors will be suppressed)",
|
||||||
(apr_uint64_t)(vec[0].iov_len +
|
(apr_uint64_t)(vec[0].iov_len + vec[1].iov_len + vec[2].iov_len), ctx->conn->filename, ctx->conn->direction, ctx->uuid, ctx->count);
|
||||||
vec[1].iov_len +
|
|
||||||
vec[2].iov_len),
|
|
||||||
ctx->conn->filename,
|
|
||||||
ctx->conn->direction, ctx->uuid,
|
|
||||||
ctx->count);
|
|
||||||
}
|
}
|
||||||
ctx->conn->suppress = 1;
|
ctx->conn->suppress = 1;
|
||||||
rv = APR_SUCCESS;
|
rv = APR_SUCCESS;
|
||||||
@@ -303,9 +288,8 @@ static apr_status_t firehose_input_filter(ap_filter_t *f,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (b = APR_BRIGADE_FIRST(bb);
|
for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b
|
||||||
b != APR_BRIGADE_SENTINEL(bb);
|
= APR_BUCKET_NEXT(b)) {
|
||||||
b = APR_BUCKET_NEXT(b)) {
|
|
||||||
rv = pumpit(f, b, ctx);
|
rv = pumpit(f, b, ctx);
|
||||||
if (APR_SUCCESS != rv) {
|
if (APR_SUCCESS != rv) {
|
||||||
return rv;
|
return rv;
|
||||||
@@ -367,7 +351,7 @@ static int firehose_create_request(request_rec *r)
|
|||||||
f = r->connection->input_filters;
|
f = r->connection->input_filters;
|
||||||
while (f) {
|
while (f) {
|
||||||
if (f->frec->filter_func.in_func == &firehose_input_filter) {
|
if (f->frec->filter_func.in_func == &firehose_input_filter) {
|
||||||
ctx = (firehose_ctx_t *)f->ctx;
|
ctx = (firehose_ctx_t *) f->ctx;
|
||||||
if (ctx->conn->request == FIREHOSE_REQUEST) {
|
if (ctx->conn->request == FIREHOSE_REQUEST) {
|
||||||
pumpit_cleanup(ctx);
|
pumpit_cleanup(ctx);
|
||||||
if (!set) {
|
if (!set) {
|
||||||
@@ -383,7 +367,7 @@ static int firehose_create_request(request_rec *r)
|
|||||||
f = r->connection->output_filters;
|
f = r->connection->output_filters;
|
||||||
while (f) {
|
while (f) {
|
||||||
if (f->frec->filter_func.out_func == &firehose_output_filter) {
|
if (f->frec->filter_func.out_func == &firehose_output_filter) {
|
||||||
ctx = (firehose_ctx_t *)f->ctx;
|
ctx = (firehose_ctx_t *) f->ctx;
|
||||||
if (ctx->conn->request == FIREHOSE_REQUEST) {
|
if (ctx->conn->request == FIREHOSE_REQUEST) {
|
||||||
pumpit_cleanup(ctx);
|
pumpit_cleanup(ctx);
|
||||||
if (!set) {
|
if (!set) {
|
||||||
@@ -431,17 +415,17 @@ static int firehose_pre_conn(conn_rec *c, void *csd)
|
|||||||
firehose_conn_t *conn;
|
firehose_conn_t *conn;
|
||||||
|
|
||||||
conf = ap_get_module_config(c->base_server->module_config,
|
conf = ap_get_module_config(c->base_server->module_config,
|
||||||
&firehose_module);
|
&firehose_module);
|
||||||
|
|
||||||
if (conf->firehoses->nelts) {
|
if (conf->firehoses->nelts) {
|
||||||
apr_uuid_get(&uuid);
|
apr_uuid_get(&uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn = (firehose_conn_t *)conf->firehoses->elts;
|
conn = (firehose_conn_t *) conf->firehoses->elts;
|
||||||
for (i = 0; i < conf->firehoses->nelts; i++) {
|
for (i = 0; i < conf->firehoses->nelts; i++) {
|
||||||
|
|
||||||
if (!conn->file || (conn->proxy == FIREHOSE_NORMAL && !c->sbh) ||
|
if (!conn->file || (conn->proxy == FIREHOSE_NORMAL
|
||||||
(conn->proxy == FIREHOSE_PROXY && c->sbh)) {
|
&& !c->sbh) || (conn->proxy == FIREHOSE_PROXY && c->sbh)) {
|
||||||
conn++;
|
conn++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -457,13 +441,13 @@ static int firehose_pre_conn(conn_rec *c, void *csd)
|
|||||||
ctx->direction = conn->proxy == FIREHOSE_PROXY ? '>' : '<';
|
ctx->direction = conn->proxy == FIREHOSE_PROXY ? '>' : '<';
|
||||||
ctx->f = ap_add_input_filter("FIREHOSE_IN", ctx, NULL, c);
|
ctx->f = ap_add_input_filter("FIREHOSE_IN", ctx, NULL, c);
|
||||||
apr_pool_cleanup_register(c->pool, ctx->f, filter_input_cleanup,
|
apr_pool_cleanup_register(c->pool, ctx->f, filter_input_cleanup,
|
||||||
filter_input_cleanup);
|
filter_input_cleanup);
|
||||||
}
|
}
|
||||||
if (conn->direction == FIREHOSE_OUT) {
|
if (conn->direction == FIREHOSE_OUT) {
|
||||||
ctx->direction = conn->proxy == FIREHOSE_PROXY ? '<' : '>';
|
ctx->direction = conn->proxy == FIREHOSE_PROXY ? '<' : '>';
|
||||||
ctx->f = ap_add_output_filter("FIREHOSE_OUT", ctx, NULL, c);
|
ctx->f = ap_add_output_filter("FIREHOSE_OUT", ctx, NULL, c);
|
||||||
apr_pool_cleanup_register(c->pool, ctx->f, filter_output_cleanup,
|
apr_pool_cleanup_register(c->pool, ctx->f, filter_output_cleanup,
|
||||||
filter_output_cleanup);
|
filter_output_cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn++;
|
conn++;
|
||||||
@@ -473,7 +457,7 @@ static int firehose_pre_conn(conn_rec *c, void *csd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int firehose_open_logs(apr_pool_t *p, apr_pool_t *plog,
|
static int firehose_open_logs(apr_pool_t *p, apr_pool_t *plog,
|
||||||
apr_pool_t *ptemp, server_rec *s)
|
apr_pool_t *ptemp, server_rec *s)
|
||||||
{
|
{
|
||||||
firehose_conf_t *conf;
|
firehose_conf_t *conf;
|
||||||
apr_status_t rv;
|
apr_status_t rv;
|
||||||
@@ -484,26 +468,27 @@ static int firehose_open_logs(apr_pool_t *p, apr_pool_t *plog,
|
|||||||
/* make sure we only open the files on the second pass for config */
|
/* make sure we only open the files on the second pass for config */
|
||||||
apr_pool_userdata_get(&data, "mod_firehose", s->process->pool);
|
apr_pool_userdata_get(&data, "mod_firehose", s->process->pool);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
apr_pool_userdata_set((const void *)1, "mod_firehose",
|
apr_pool_userdata_set((const void *) 1, "mod_firehose",
|
||||||
apr_pool_cleanup_null, s->process->pool);
|
apr_pool_cleanup_null, s->process->pool);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s) {
|
while (s) {
|
||||||
|
|
||||||
conf = ap_get_module_config(s->module_config, &firehose_module);
|
conf = ap_get_module_config(s->module_config,
|
||||||
|
&firehose_module);
|
||||||
|
|
||||||
conn = (firehose_conn_t *)conf->firehoses->elts;
|
conn = (firehose_conn_t *) conf->firehoses->elts;
|
||||||
for (i = 0; i < conf->firehoses->nelts; i++) {
|
for (i = 0; i < conf->firehoses->nelts; i++) {
|
||||||
if (APR_SUCCESS != (rv = apr_file_open(&conn->file, conn->filename,
|
if (APR_SUCCESS != (rv = apr_file_open(&conn->file, conn->filename,
|
||||||
APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_APPEND
|
APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_APPEND
|
||||||
| conn->nonblock, APR_OS_DEFAULT, plog))) {
|
| conn->nonblock, APR_OS_DEFAULT, plog))) {
|
||||||
ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
|
ap_log_error(APLOG_MARK,
|
||||||
"mod_firehose: could not open '%s' for write, "
|
APLOG_WARNING,
|
||||||
"disabling firehose %s%s %s filter",
|
rv, s, "mod_firehose: could not open '%s' for write, disabling firehose %s%s %s filter",
|
||||||
conn->filename, conn->proxy == FIREHOSE_PROXY ? "proxy " : "",
|
conn->filename, conn->proxy == FIREHOSE_PROXY ? "proxy " : "",
|
||||||
conn->request == FIREHOSE_REQUEST ? " request" : "connection",
|
conn->request == FIREHOSE_REQUEST ? " request" : "connection",
|
||||||
conn->direction == FIREHOSE_IN ? "input" : "output");
|
conn->direction == FIREHOSE_IN ? "input" : "output");
|
||||||
}
|
}
|
||||||
conn++;
|
conn++;
|
||||||
}
|
}
|
||||||
@@ -520,15 +505,15 @@ static void firehose_register_hooks(apr_pool_t *p)
|
|||||||
* We know that SSL is CONNECTION + 5
|
* We know that SSL is CONNECTION + 5
|
||||||
*/
|
*/
|
||||||
ap_register_output_filter("FIREHOSE_OUT", firehose_output_filter, NULL,
|
ap_register_output_filter("FIREHOSE_OUT", firehose_output_filter, NULL,
|
||||||
AP_FTYPE_CONNECTION + 3);
|
AP_FTYPE_CONNECTION + 3);
|
||||||
|
|
||||||
ap_register_input_filter("FIREHOSE_IN", firehose_input_filter, NULL,
|
ap_register_input_filter("FIREHOSE_IN", firehose_input_filter, NULL,
|
||||||
AP_FTYPE_CONNECTION + 3);
|
AP_FTYPE_CONNECTION + 3);
|
||||||
|
|
||||||
ap_hook_open_logs(firehose_open_logs, NULL, NULL, APR_HOOK_LAST);
|
ap_hook_open_logs(firehose_open_logs, NULL, NULL, APR_HOOK_LAST);
|
||||||
ap_hook_pre_connection(firehose_pre_conn, NULL, NULL, APR_HOOK_MIDDLE);
|
ap_hook_pre_connection(firehose_pre_conn, NULL, NULL, APR_HOOK_MIDDLE);
|
||||||
ap_hook_create_request(firehose_create_request, NULL, NULL,
|
ap_hook_create_request(firehose_create_request, NULL, NULL,
|
||||||
APR_HOOK_REALLY_LAST + 1);
|
APR_HOOK_REALLY_LAST + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *firehose_create_sconfig(apr_pool_t *p, server_rec *s)
|
static void *firehose_create_sconfig(apr_pool_t *p, server_rec *s)
|
||||||
@@ -541,31 +526,29 @@ static void *firehose_create_sconfig(apr_pool_t *p, server_rec *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void *firehose_merge_sconfig(apr_pool_t *p, void *basev,
|
static void *firehose_merge_sconfig(apr_pool_t *p, void *basev,
|
||||||
void *overridesv)
|
void *overridesv)
|
||||||
{
|
{
|
||||||
firehose_conf_t *cconf = apr_pcalloc(p, sizeof(firehose_conf_t));
|
firehose_conf_t *cconf = apr_pcalloc(p, sizeof(firehose_conf_t));
|
||||||
firehose_conf_t *base = (firehose_conf_t *)basev;
|
firehose_conf_t *base = (firehose_conf_t *) basev;
|
||||||
firehose_conf_t *overrides = (firehose_conf_t *)overridesv;
|
firehose_conf_t *overrides = (firehose_conf_t *) overridesv;
|
||||||
|
|
||||||
cconf->firehoses = apr_array_append(p, overrides->firehoses,
|
cconf->firehoses = apr_array_append(p, overrides->firehoses,
|
||||||
base->firehoses);
|
base->firehoses);
|
||||||
|
|
||||||
return cconf;
|
return cconf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *firehose_enable_connection(cmd_parms *cmd,
|
static const char *firehose_enable_connection(cmd_parms *cmd, const char *arg1,
|
||||||
const char *arg1,
|
const char *arg2, proxy_enum proxy, direction_enum direction,
|
||||||
const char *arg2,
|
request_enum request)
|
||||||
proxy_enum proxy,
|
|
||||||
direction_enum direction,
|
|
||||||
request_enum request)
|
|
||||||
{
|
{
|
||||||
const char *name = arg2 ? arg2 : arg1;
|
const char *name = arg2 ? arg2 : arg1;
|
||||||
|
|
||||||
firehose_conn_t *firehose;
|
firehose_conn_t *firehose;
|
||||||
firehose_conf_t *ptr =
|
firehose_conf_t
|
||||||
(firehose_conf_t *)ap_get_module_config(cmd->server->module_config,
|
*ptr =
|
||||||
&firehose_module);
|
(firehose_conf_t *) ap_get_module_config(cmd->server->module_config,
|
||||||
|
&firehose_module);
|
||||||
|
|
||||||
firehose = apr_array_push(ptr->firehoses);
|
firehose = apr_array_push(ptr->firehoses);
|
||||||
|
|
||||||
@@ -579,8 +562,7 @@ static const char *firehose_enable_connection(cmd_parms *cmd,
|
|||||||
#ifdef APR_FOPEN_NONBLOCK
|
#ifdef APR_FOPEN_NONBLOCK
|
||||||
firehose->nonblock = APR_FOPEN_NONBLOCK;
|
firehose->nonblock = APR_FOPEN_NONBLOCK;
|
||||||
#else
|
#else
|
||||||
return "The parameter 'nonblock' is not supported by APR on this "
|
return "The parameter 'nonblock' is not supported by APR on this platform";
|
||||||
"platform";
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (!strcmp(arg1, "block")) {
|
else if (!strcmp(arg1, "block")) {
|
||||||
@@ -588,8 +570,7 @@ static const char *firehose_enable_connection(cmd_parms *cmd,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return apr_psprintf(cmd->pool,
|
return apr_psprintf(cmd->pool,
|
||||||
"The parameter '%s' should be 'block' or 'nonblock'",
|
"The parameter '%s' should be 'block' or 'nonblock'", arg1);
|
||||||
arg1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -600,85 +581,93 @@ static const char *firehose_enable_connection(cmd_parms *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *firehose_enable_connection_input(cmd_parms *cmd,
|
static const char *firehose_enable_connection_input(cmd_parms *cmd,
|
||||||
void *dummy,
|
void *dummy, const char *arg1, const char *arg2)
|
||||||
const char *arg1,
|
|
||||||
const char *arg2)
|
|
||||||
{
|
{
|
||||||
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY | NOT_IN_LIMIT);
|
|
||||||
|
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY
|
||||||
|
| NOT_IN_LIMIT);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
||||||
FIREHOSE_IN, FIREHOSE_CONNECTION);
|
FIREHOSE_IN, FIREHOSE_CONNECTION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *firehose_enable_connection_output(cmd_parms *cmd,
|
static const char *firehose_enable_connection_output(cmd_parms *cmd,
|
||||||
void *dummy,
|
void *dummy, const char *arg1, const char *arg2)
|
||||||
const char *arg1,
|
|
||||||
const char *arg2)
|
|
||||||
{
|
{
|
||||||
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY | NOT_IN_LIMIT);
|
|
||||||
|
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY
|
||||||
|
| NOT_IN_LIMIT);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
||||||
FIREHOSE_OUT, FIREHOSE_CONNECTION);
|
FIREHOSE_OUT, FIREHOSE_CONNECTION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *firehose_enable_request_input(cmd_parms *cmd, void *dummy,
|
static const char *firehose_enable_request_input(cmd_parms *cmd, void *dummy,
|
||||||
const char *arg1,
|
const char *arg1, const char *arg2)
|
||||||
const char *arg2)
|
|
||||||
{
|
{
|
||||||
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY | NOT_IN_LIMIT);
|
|
||||||
|
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY
|
||||||
|
| NOT_IN_LIMIT);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
||||||
FIREHOSE_IN, FIREHOSE_REQUEST);
|
FIREHOSE_IN, FIREHOSE_REQUEST);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *firehose_enable_request_output(cmd_parms *cmd, void *dummy,
|
static const char *firehose_enable_request_output(cmd_parms *cmd, void *dummy,
|
||||||
const char *arg1,
|
const char *arg1, const char *arg2)
|
||||||
const char *arg2)
|
|
||||||
{
|
{
|
||||||
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY | NOT_IN_LIMIT);
|
|
||||||
|
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY
|
||||||
|
| NOT_IN_LIMIT);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
|
||||||
FIREHOSE_OUT, FIREHOSE_REQUEST);
|
FIREHOSE_OUT, FIREHOSE_REQUEST);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *firehose_enable_proxy_connection_input(cmd_parms *cmd,
|
static const char *firehose_enable_proxy_connection_input(cmd_parms *cmd,
|
||||||
void *dummy,
|
void *dummy, const char *arg1, const char *arg2)
|
||||||
const char *arg1,
|
|
||||||
const char *arg2)
|
|
||||||
{
|
{
|
||||||
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY | NOT_IN_LIMIT);
|
|
||||||
|
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY
|
||||||
|
| NOT_IN_LIMIT);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_PROXY,
|
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_PROXY,
|
||||||
FIREHOSE_IN, FIREHOSE_CONNECTION);
|
FIREHOSE_IN, FIREHOSE_CONNECTION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *firehose_enable_proxy_connection_output(cmd_parms *cmd,
|
static const char *firehose_enable_proxy_connection_output(cmd_parms *cmd,
|
||||||
void *dummy,
|
void *dummy, const char *arg1, const char *arg2)
|
||||||
const char *arg1,
|
|
||||||
const char *arg2)
|
|
||||||
{
|
{
|
||||||
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY | NOT_IN_LIMIT);
|
|
||||||
|
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY
|
||||||
|
| NOT_IN_LIMIT);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_PROXY,
|
return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_PROXY,
|
||||||
FIREHOSE_OUT, FIREHOSE_CONNECTION);
|
FIREHOSE_OUT, FIREHOSE_CONNECTION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const command_rec firehose_cmds[] =
|
static const command_rec firehose_cmds[] =
|
||||||
|
@@ -82,7 +82,7 @@ static apr_status_t brigade_peek(apr_bucket_brigade *bbIn,
|
|||||||
len = pos - str;
|
len = pos - str;
|
||||||
if (len > bufflen - readbytes)
|
if (len > bufflen - readbytes)
|
||||||
len = bufflen - readbytes;
|
len = bufflen - readbytes;
|
||||||
memcpy(buff + readbytes, str, len);
|
memcpy (buff + readbytes, str, len);
|
||||||
readbytes += len;
|
readbytes += len;
|
||||||
buff[readbytes] = '\0';
|
buff[readbytes] = '\0';
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ static int process_echo_connection(conn_rec *c)
|
|||||||
if (((rv = ap_get_brigade(c->input_filters, bb, AP_MODE_GETLINE,
|
if (((rv = ap_get_brigade(c->input_filters, bb, AP_MODE_GETLINE,
|
||||||
APR_BLOCK_READ, 0)) != APR_SUCCESS)) {
|
APR_BLOCK_READ, 0)) != APR_SUCCESS)) {
|
||||||
apr_brigade_cleanup(bb);
|
apr_brigade_cleanup(bb);
|
||||||
if (!APR_STATUS_IS_EOF(rv) && !APR_STATUS_IS_TIMEUP(rv))
|
if (!APR_STATUS_IS_EOF(rv) && ! APR_STATUS_IS_TIMEUP(rv))
|
||||||
ap_log_error(APLOG_MARK, APLOG_INFO, rv, c->base_server, APLOGNO(01611)
|
ap_log_error(APLOG_MARK, APLOG_INFO, rv, c->base_server, APLOGNO(01611)
|
||||||
"ProtocolEcho: Failure reading from %s",
|
"ProtocolEcho: Failure reading from %s",
|
||||||
c->client_ip);
|
c->client_ip);
|
||||||
|
Reference in New Issue
Block a user