Return-Path:
X-Original-To: apmail-httpd-cvs-archive@www.apache.org
Delivered-To: apmail-httpd-cvs-archive@www.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id 9725F9E4F
for ;
Sun, 18 Dec 2011 17:06:10 +0000 (UTC)
Received: (qmail 2291 invoked by uid 500); 18 Dec 2011 17:06:10 -0000
Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org
Received: (qmail 2226 invoked by uid 500); 18 Dec 2011 17:06:09 -0000
Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm
Precedence: bulk
Reply-To: dev@httpd.apache.org
list-help:
list-unsubscribe:
List-Post:
List-Id:
Delivered-To: mailing list cvs@httpd.apache.org
Received: (qmail 2219 invoked by uid 99); 18 Dec 2011 17:06:09 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Dec 2011 17:06:09 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Dec 2011 17:06:05 +0000
Received: from eris.apache.org (localhost [127.0.0.1])
by eris.apache.org (Postfix) with ESMTP id B95C82388860;
Sun, 18 Dec 2011 17:05:43 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r1220456 - in /httpd/httpd/trunk:
docs/manual/mod/mod_firehose.xml modules/debugging/mod_firehose.c
Date: Sun, 18 Dec 2011 17:05:43 -0000
To: cvs@httpd.apache.org
From: minfrin@apache.org
X-Mailer: svnmailer-1.0.8-patched
Message-Id: <20111218170543.B95C82388860@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Author: minfrin
Date: Sun Dec 18 17:05:43 2011
New Revision: 1220456
URL: http://svn.apache.org/viewvc?rev=1220456&view=rev
Log:
mod_firehose: Support portable non blocking support, and make non blocking
support optional.
Modified:
httpd/httpd/trunk/docs/manual/mod/mod_firehose.xml
httpd/httpd/trunk/modules/debugging/mod_firehose.c
Modified: httpd/httpd/trunk/docs/manual/mod/mod_firehose.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_firehose.xml?rev=1220456&r1=1220455&r2=1220456&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_firehose.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_firehose.xml Sun Dec 18 17:05:43 2011
@@ -72,10 +72,12 @@
silently stand down and not record anything, and the server will
keep running as normal.
- All file writes are non blocking, and buffer overflows will cause
- debugging data to be lost. The module makes the call that the
- reliable running of the server takes precedence over the recording
- of firehose data.
+ By default, all attempts to write will block the server. If the
+ webserver has been built against APR v2.0 or later, and an optional
+ "nonblock" parameter is specified all file writes will be non
+ blocking, and buffer overflows will cause debugging data to be lost.
+ In this case it is possible to prioritise the running of the server
+ over the recording of firehose data.
@@ -144,7 +146,7 @@
FirehoseConnectionInput
Capture traffic coming into the server on each connection
-FirehoseConnectionInput filename
+FirehoseConnectionInput [ block | nonblock ] filename
none
server config
FirehoseConnectionInput is only available in Apache 2.5.0 and
@@ -166,7 +168,7 @@ later.
FirehoseConnectionOutput
Capture traffic going out of the server on each connection
-FirehoseConnectionOutput filename
+FirehoseConnectionOutput [ block | nonblock ] filename
none
server config
FirehoseConnectionOutput is only available in Apache 2.5.0 and
@@ -188,7 +190,7 @@ later.
FirehoseRequestInput
Capture traffic coming into the server on each request
-FirehoseRequestInput filename
+FirehoseRequestInput [ block | nonblock ] filename
none
server config
FirehoseRequestInput is only available in Apache 2.5.0 and
@@ -209,7 +211,7 @@ later.
FirehoseRequestOutput
Capture traffic going out of the server on each request
-FirehoseRequestOutput filename
+FirehoseRequestOutput [ block | nonblock ] filename
none
server config
FirehoseRequestOutput is only available in Apache 2.5.0 and
@@ -230,7 +232,7 @@ later.
FirehoseProxyConnectionInput
Capture traffic coming into the back of mod_proxy
-FirehoseProxyConnectionInput filename
+FirehoseProxyConnectionInput [ block | nonblock ] filename
none
server config
FirehoseProxyConnectionInput is only available in Apache 2.5.0 and
@@ -250,7 +252,7 @@ later.
FirehoseProxyConnectionOutput
Capture traffic sent out from the back of mod_proxy
-FirehoseProxyConnectionOutput filename
+FirehoseProxyConnectionOutput [ block | nonblock ] filename
none
server config
FirehoseProxyConnectionOutput is only available in Apache 2.5.0 and
Modified: httpd/httpd/trunk/modules/debugging/mod_firehose.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/debugging/mod_firehose.c?rev=1220456&r1=1220455&r2=1220456&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/debugging/mod_firehose.c (original)
+++ httpd/httpd/trunk/modules/debugging/mod_firehose.c Sun Dec 18 17:05:43 2011
@@ -78,6 +78,7 @@ typedef struct firehose_conn_t
direction_enum direction;
request_enum request;
int suppress;
+ apr_int32_t nonblock;
} firehose_conn_t;
typedef struct firehose_conf_t
@@ -483,14 +484,9 @@ static int firehose_open_logs(apr_pool_t
conn = (firehose_conn_t *) conf->firehoses->elts;
for (i = 0; i < conf->firehoses->nelts; i++) {
- /* TODO: make this non blocking behaviour optional, as APR doesn't yet
- * support non blocking opening of files.
- * TODO: make this properly portable.
- */
- apr_os_file_t file = open(conn->filename, O_WRONLY
- | O_CREAT | O_APPEND | O_NONBLOCK, 0777);
- if (file < 0) {
- rv = APR_FROM_OS_ERROR(apr_get_os_error());
+ if (APR_SUCCESS != (rv = apr_file_open(&conn->file, conn->filename,
+ APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_APPEND
+ | conn->nonblock, APR_OS_DEFAULT, plog))) {
ap_log_error(APLOG_MARK,
APLOG_WARNING,
rv, s, "mod_firehose: could not open '%s' for write, disabling firehose %s%s %s filter",
@@ -498,21 +494,6 @@ static int firehose_open_logs(apr_pool_t
conn->request == FIREHOSE_REQUEST ? " request" : "connection",
conn->direction == FIREHOSE_IN ? "input" : "output");
}
- else if (APR_SUCCESS != (rv = apr_os_file_put(
- &conn->file, &file, APR_FOPEN_WRITE
- | APR_FOPEN_CREATE | APR_FOPEN_APPEND, plog))) {
- close(file);
- ap_log_error(APLOG_MARK,
- APLOG_WARNING,
- rv, s, "mod_firehose: could not open '%s' for write, disabling firehose %s%s %s filter",
- conn->filename, conn->proxy == FIREHOSE_PROXY ? "proxy " : "",
- conn->request == FIREHOSE_REQUEST ? " request" : "connection",
- conn->direction == FIREHOSE_IN ? "input" : "output");
- }
- else {
- apr_pool_cleanup_register(plog, conn->file,
- logs_cleanup, logs_cleanup);
- }
conn++;
}
@@ -561,9 +542,11 @@ static void *firehose_merge_sconfig(apr_
return cconf;
}
-static void firehose_enable_connection(cmd_parms *cmd, const char *name,
- proxy_enum proxy, direction_enum direction, request_enum request)
+static const char *firehose_enable_connection(cmd_parms *cmd, const char *arg1,
+ const char *arg2, proxy_enum proxy, direction_enum direction,
+ request_enum request)
{
+ const char *name = arg2 ? arg2 : arg1;
firehose_conn_t *firehose;
firehose_conf_t
@@ -578,10 +561,31 @@ static void firehose_enable_connection(c
firehose->direction = direction;
firehose->request = request;
+ if (arg2) {
+ if (!strcmp(arg1, "nonblock")) {
+#ifdef APR_FOPEN_NONBLOCK
+ firehose->nonblock = APR_FOPEN_NONBLOCK;
+#else
+ return "The parameter 'nonblock' is not supported by APR on this platform";
+#endif
+ }
+ else if (!strcmp(arg1, "block")) {
+ firehose->nonblock = 0;
+ }
+ else {
+ return apr_psprintf(cmd->pool,
+ "The parameter '%s' should be 'block' or 'nonblock'", arg1);
+ }
+ }
+ else {
+ firehose->nonblock = 0;
+ }
+
+ return NULL;
}
static const char *firehose_enable_connection_input(cmd_parms *cmd,
- void *dummy, const char *name)
+ void *dummy, const char *arg1, const char *arg2)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
@@ -590,14 +594,13 @@ static const char *firehose_enable_conne
return err;
}
- firehose_enable_connection(cmd, name, FIREHOSE_NORMAL, FIREHOSE_IN,
- FIREHOSE_CONNECTION);
+ return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
+ FIREHOSE_IN, FIREHOSE_CONNECTION);
- return NULL;
}
static const char *firehose_enable_connection_output(cmd_parms *cmd,
- void *dummy, const char *name)
+ void *dummy, const char *arg1, const char *arg2)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
@@ -606,14 +609,13 @@ static const char *firehose_enable_conne
return err;
}
- firehose_enable_connection(cmd, name, FIREHOSE_NORMAL, FIREHOSE_OUT,
- FIREHOSE_CONNECTION);
+ return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
+ FIREHOSE_OUT, FIREHOSE_CONNECTION);
- return NULL;
}
static const char *firehose_enable_request_input(cmd_parms *cmd, void *dummy,
- const char *name)
+ const char *arg1, const char *arg2)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
@@ -622,14 +624,13 @@ static const char *firehose_enable_reque
return err;
}
- firehose_enable_connection(cmd, name, FIREHOSE_NORMAL, FIREHOSE_IN,
- FIREHOSE_REQUEST);
+ return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
+ FIREHOSE_IN, FIREHOSE_REQUEST);
- return NULL;
}
static const char *firehose_enable_request_output(cmd_parms *cmd, void *dummy,
- const char *name)
+ const char *arg1, const char *arg2)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
@@ -638,14 +639,13 @@ static const char *firehose_enable_reque
return err;
}
- firehose_enable_connection(cmd, name, FIREHOSE_NORMAL, FIREHOSE_OUT,
- FIREHOSE_REQUEST);
+ return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_NORMAL,
+ FIREHOSE_OUT, FIREHOSE_REQUEST);
- return NULL;
}
static const char *firehose_enable_proxy_connection_input(cmd_parms *cmd,
- void *dummy, const char *name)
+ void *dummy, const char *arg1, const char *arg2)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
@@ -654,14 +654,13 @@ static const char *firehose_enable_proxy
return err;
}
- firehose_enable_connection(cmd, name, FIREHOSE_PROXY, FIREHOSE_IN,
- FIREHOSE_CONNECTION);
+ return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_PROXY,
+ FIREHOSE_IN, FIREHOSE_CONNECTION);
- return NULL;
}
static const char *firehose_enable_proxy_connection_output(cmd_parms *cmd,
- void *dummy, const char *name)
+ void *dummy, const char *arg1, const char *arg2)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE
@@ -670,25 +669,24 @@ static const char *firehose_enable_proxy
return err;
}
- firehose_enable_connection(cmd, name, FIREHOSE_PROXY, FIREHOSE_OUT,
- FIREHOSE_CONNECTION);
+ return firehose_enable_connection(cmd, arg1, arg2, FIREHOSE_PROXY,
+ FIREHOSE_OUT, FIREHOSE_CONNECTION);
- return NULL;
}
static const command_rec firehose_cmds[] =
{
- AP_INIT_TAKE1("FirehoseConnectionInput", firehose_enable_connection_input, NULL,
+ AP_INIT_TAKE12("FirehoseConnectionInput", firehose_enable_connection_input, NULL,
RSRC_CONF, "Enable firehose on connection input data written to the given file/pipe"),
- AP_INIT_TAKE1("FirehoseConnectionOutput", firehose_enable_connection_output, NULL,
+ AP_INIT_TAKE12("FirehoseConnectionOutput", firehose_enable_connection_output, NULL,
RSRC_CONF, "Enable firehose on connection output data written to the given file/pipe"),
- AP_INIT_TAKE1("FirehoseRequestInput", firehose_enable_request_input, NULL,
+ AP_INIT_TAKE12("FirehoseRequestInput", firehose_enable_request_input, NULL,
RSRC_CONF, "Enable firehose on request input data written to the given file/pipe"),
- AP_INIT_TAKE1("FirehoseRequestOutput", firehose_enable_request_output, NULL,
+ AP_INIT_TAKE12("FirehoseRequestOutput", firehose_enable_request_output, NULL,
RSRC_CONF, "Enable firehose on request output data written to the given file/pipe"),
- AP_INIT_TAKE1("FirehoseProxyConnectionInput", firehose_enable_proxy_connection_input, NULL,
+ AP_INIT_TAKE12("FirehoseProxyConnectionInput", firehose_enable_proxy_connection_input, NULL,
RSRC_CONF, "Enable firehose on proxied connection input data written to the given file/pipe"),
- AP_INIT_TAKE1("FirehoseProxyConnectionOutput", firehose_enable_proxy_connection_output, NULL,
+ AP_INIT_TAKE12("FirehoseProxyConnectionOutput", firehose_enable_proxy_connection_output, NULL,
RSRC_CONF, "Enable firehose on proxied connection output data written to the given file/pipe"),
{ NULL }
};