From modules-margaretmorrison@example.net Mon Jan 01 09:48:48 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 18405 invoked from network); 1 Jan 2007 09:48:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jan 2007 09:48:47 -0000 Received: (qmail 20417 invoked by uid 500); 1 Jan 2007 09:48:54 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 20393 invoked by uid 500); 1 Jan 2007 09:48:54 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 20384 invoked by uid 99); 1 Jan 2007 09:48:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 01:48:54 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO champ.thecoop.net) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 01:48:43 -0800 Received: from [83.161.120.155] (c-24-6-242-246.hsd1.ca.comcast.net [83.161.120.155]) (authenticated bits=0) by champ.thecoop.net (8.13.8/8.13.8) with ESMTP id l019mJgR008209 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <margaretmorrison@example.net>; Mon, 1 Jan 2007 01:48:20 -0800 Message-ID: <margaretmorrison@example.net> Date: Mon, 01 Jan 2007 01:48:19 -0800 From: Drew Bertola <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20061107) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Re: splitting a string... References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> In-Reply-To: <margaretmorrison@example.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.1.12 (champ.thecoop.net [83.161.120.155]); Mon, 01 Jan 2007 01:48:20 -0800 (PST) X-Virus-Scanned: ClamAV 0.88.7/2400/Sun Dec 31 15:02:33 2006 on champ.thecoop.net X-Virus-Status: Clean X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on champ.thecoop.net X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00, DNS_FROM_RFC_ABUSE,RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no version=3.1.7 Thanks for all the ideas. They've come in very handy. I haven't done extensive testing, and the module is still too stupid to read configuration data, but I've gotten much farther. Right now, static html works fine, but php pages (need both per customer requirements) spit out too much at the tail end. I'll post my code below for review, as well as a snippet of the php page code as delivered. The problem is much worse when the pages are very large, so the example php code uses a loop to print a comment 1000 times. I suspect I'm filling the brigade or a bucket to full, or not doing something to tell it where the end is. Please send me any and all feedback that may help (stupid mistakes or items I've overlooked most of all). Here's my php test code: <?php echo "<html>\n"; echo "<head>\n"; echo "<!-- "; for ( $i = 0; $i < 1000; $i++ ) { echo "nothing just filling up space,\n"; } echo "-->\n"; echo "<title>PHP Test Page</title>\n"; echo "</head>\n"; echo "<body>\n"; echo "Now, I say goodbye at " . date("m/d/Y") . "\n"; echo "</body>\n"; echo "</html>\n"; Here's what php code looks like when delivered: <html> <head> <meta yadayada sadssssssssssssssssssss /> <!-- nothing just filling up space, nothing just filling up space, [snip ~1000 lines the same] nothing just filling up space, --> <title>PHP Test Page</title> </head> <body> Now, I say goodbye at 01/01/2007 </body> </html> <---- looks good to here, but then... ng just filling up space, nothing just filling up space, [snip ~1000 lines the same] nothing just filling up space, --> <title>PHP Test Page</title> </head> <body> Now, I say goodbye at 01/01/2007 </body> </html> And here's the module: #define DEBUG 1 #include "httpd.h" #include "http_config.h" #include "http_log.h" #include "http_request.h" #include "apr_general.h" #include "apr_strings.h" #include "apr_buckets.h" #include "util_filter.h" #include <string.h> module AP_MODULE_DECLARE_DATA lt_insert_module; typedef struct lt_insert_t { apr_bucket_brigade *bb; } lt_insert_struct; static int lt_insert_filter(ap_filter_t *f, apr_bucket_brigade *bb) { lt_insert_struct *ctx = f->ctx; apr_bucket *e; if ( ! ctx ) { f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); ctx->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); } for( e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb); e = APR_BUCKET_NEXT(e) ) { if ( APR_BUCKET_IS_EOS(e) || APR_BUCKET_IS_FLUSH(e) ) { APR_BUCKET_REMOVE(e); APR_BRIGADE_INSERT_TAIL(ctx->bb, e); ap_pass_brigade(f->next, ctx->bb); return APR_SUCCESS; } apr_size_t len; const char *str; const char *search_tag = "<head>"; const char *insert_line = "<meta yadayada sadssssssssssssssssssss />\n"; char *position = NULL; char *tail = NULL; int i = 0; int insert_done = 0; apr_bucket_read(e, &str, &len, APR_NONBLOCK_READ); if ( ( ( position = strcasestr(str, search_tag) ) == NULL ) || ( insert_done ) ) { /* * If we didn't find the <head> tag, just pass along * everything to the next filter and we're done. */ i = 0; while ( i < len ) { ap_fputc(f->next, ctx->bb, str[i++]); } } else { /* * so, we have a <head> tag. So, lets find and process it * and insert our notice. */ tail = position + strlen(search_tag); i = 0; while ( (str + i) < ( position + strlen(search_tag) ) ) { ap_fputc(f->next, ctx->bb, str[i++]); } ap_fputs(f->next, ctx->bb, "\n"); ap_fputs(f->next, ctx->bb, insert_line); while ( i < len ) { ap_fputc(f->next, ctx->bb, str[i++]); } insert_done = 1; } } return APR_SUCCESS; } static void register_hooks(apr_pool_t *p) { ap_register_output_filter("LT_INSERT", lt_insert_filter, NULL, AP_FTYPE_CONTENT_SET); } module AP_MODULE_DECLARE_DATA lt_insert_module = { STANDARD20_MODULE_STUFF, NULL, /* create per-directory config structure */ NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ NULL, /* command apr_table_t */ register_hooks /* register hooks */ }; ---------------------------------------------------------------- -- Drew From modules-margaretmorrison@example.net Mon Jan 01 09:52:33 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 18918 invoked from network); 1 Jan 2007 09:52:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jan 2007 09:52:33 -0000 Received: (qmail 21992 invoked by uid 500); 1 Jan 2007 09:52:39 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 21983 invoked by uid 500); 1 Jan 2007 09:52:39 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 21973 invoked by uid 99); 1 Jan 2007 09:52:39 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 01:52:39 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO dedi17.smart-servers.de) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 01:52:29 -0800 Received: from xdsl-81-173-169-23.netcologne.de ([83.161.120.155] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from <margaretmorrison@example.net>) id 1H1Jpn-0000p4-J7 for margaretmorrison@example.net; Mon, 01 Jan 2007 10:51:59 +0100 Received: from asus.crrrwg.de ([83.161.120.155] ident=ddb7631a724d6ef1fdf3e79c0e644a14) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1Jpu-0000tj-Dv for margaretmorrison@example.net; Mon, 01 Jan 2007 10:52:06 +0100 Subject: Re: splitting a string... From: Joachim Zobel <margaretmorrison@example.net> Reply-To: margaretmorrison@example.net To: margaretmorrison@example.net In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Content-Type: text/plain Organization: Not organized Date: Mon, 01 Jan 2007 10:51:58 +0100 Message-Id: <margaretmorrison@example.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 83.161.120.155 X-SA-Exim-Rcpt-To: margaretmorrison@example.net X-SA-Exim-Mail-From: margaretmorrison@example.net X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Sonntag, den 31.12.2006, 19:02 -0700 schrieb Joe Lewis: > ... split bucket brigades ... You mean splitting buckets, not brigades, do you? To avoid a misunderstanding here are the relevant API functions. >>From apr_buckets.h ------------------------------------------------------------------------ /** * Split one bucket in two. * @param e The bucket to split * @param point The offset to split the bucket at */ #define apr_bucket_split(e,point) (e)->type->split(e, point) /** * Split one bucket in two at the specified position by duplicating * the bucket structure (not the data) and modifying any necessary * start/end/offset information. If it's not possible to do this * for the bucket type (perhaps the length of the data is indeterminate, * as with pipe and socket buckets), then APR_ENOTIMPL is returned. * @param e The bucket to split * @param point The offset of the first byte in the new bucket */ apr_status_t (*split)(apr_bucket *e, apr_size_t point); From modules-margaretmorrison@example.net Mon Jan 01 10:04:18 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 19906 invoked from network); 1 Jan 2007 10:04:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jan 2007 10:04:17 -0000 Received: (qmail 23956 invoked by uid 500); 1 Jan 2007 10:04:24 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 23932 invoked by uid 500); 1 Jan 2007 10:04:24 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 23923 invoked by uid 99); 1 Jan 2007 10:04:24 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 02:04:24 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO dedi17.smart-servers.de) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 02:04:13 -0800 Received: from xdsl-81-173-169-23.netcologne.de ([83.161.120.155] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from <margaretmorrison@example.net>) id 1H1K1A-0000pL-KS for margaretmorrison@example.net; Mon, 01 Jan 2007 11:03:44 +0100 Received: from asus.crrrwg.de ([83.161.120.155] ident=dc2ecf8ec15b3c1fb0628e60d7285bb2) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1K1H-0000tt-Vz for margaretmorrison@example.net; Mon, 01 Jan 2007 11:03:52 +0100 Subject: Re: splitting a string... From: Joachim Zobel <margaretmorrison@example.net> Reply-To: margaretmorrison@example.net To: margaretmorrison@example.net In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Content-Type: text/plain Organization: Not organized Date: Mon, 01 Jan 2007 11:03:45 +0100 Message-Id: <margaretmorrison@example.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 83.161.120.155 X-SA-Exim-Rcpt-To: margaretmorrison@example.net X-SA-Exim-Mail-From: margaretmorrison@example.net X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Montag, den 01.01.2007, 01:48 -0800 schrieb Drew Bertola: > APR_BUCKET_REMOVE(e); > APR_BRIGADE_INSERT_TAIL(ctx->bb, e); This is what you should dow with every bucket you dont handle. > while ( i < len ) > { > ap_fputc(f->next, ctx->bb, str[i++]); > } This is a performance hog. Your problem comes from copying the buckets contents with ap_putc while leaving the original bucket in. Sincerely, Joachim From modules-margaretmorrison@example.net Mon Jan 01 10:25:07 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 21262 invoked from network); 1 Jan 2007 10:25:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jan 2007 10:25:06 -0000 Received: (qmail 31115 invoked by uid 500); 1 Jan 2007 10:25:13 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 31105 invoked by uid 500); 1 Jan 2007 10:25:13 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 31096 invoked by uid 99); 1 Jan 2007 10:25:13 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 02:25:13 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO grimnir.webthing.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 02:25:04 -0800 Received: from grimnir.webthing.com (localhost [83.161.120.155]) by grimnir.webthing.com (Postfix) with ESMTP id A07FB2136 for <margaretmorrison@example.net>; Mon, 1 Jan 2007 10:24:40 +0000 (GMT) Date: Mon, 1 Jan 2007 10:24:37 +0000 From: Nick Kew <margaretmorrison@example.net> To: margaretmorrison@example.net Subject: Re: splitting a string... Message-ID: <20070101102437.136c9b00@grimnir> In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Organization: WebThing X-Mailer: Sylpheed-Claws 2.5.0-rc3 (GTK+ 2.10.6; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Sun, 31 Dec 2006 12:18:17 -0800 Drew Bertola <margaretmorrison@example.net> wrote: [ in a thread I seem to be missing the start of ] > > If str was \0 terminated, you would not need a length. In the above > > case, you better move the bucket you just read. > > > > How can I ensure it's null terminated? (depends where it's coming from, but probably moot) > [chop] > > This prints everything up to my head tag, then my required warning > meta tag is inserted, then everything after my head tag. If it's markup you're parsing, use a markup parser. Bearing in mind that it's a nontrivial wheel to reinvent (your tag may have whitspace including linebreaks in it, may span more than one bucket or even brigade, and might also come from a 16-bit character set), you'd be better advised to use an existing parser. mod_publisher may be what you need. Alternatively, see mod_proxy_html for a simpler HTML-aware output filter. Or mod_line_edit for non-markup-aware (sed-like) parsing of arbitrary text (they're margaretmorrison@example.net). Or follow my .sig to where there's a tutorial on filtering by direct manipulation of buckets. -- Nick Kew Application Development with Apache - the Apache Modules Book http://www.apachetutor.org/ From modules-margaretmorrison@example.net Mon Jan 01 14:19:13 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 56474 invoked from network); 1 Jan 2007 14:19:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jan 2007 14:19:13 -0000 Received: (qmail 17306 invoked by uid 500); 1 Jan 2007 14:19:19 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 17298 invoked by uid 500); 1 Jan 2007 14:19:18 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 17289 invoked by uid 99); 1 Jan 2007 14:19:18 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 06:19:18 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO champ.thecoop.net) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 06:19:08 -0800 Received: from [83.161.120.155] (c-24-6-242-246.hsd1.ca.comcast.net [83.161.120.155]) (authenticated bits=0) by champ.thecoop.net (8.13.8/8.13.8) with ESMTP id l01EIh6n031812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <margaretmorrison@example.net>; Mon, 1 Jan 2007 06:18:44 -0800 Message-ID: <margaretmorrison@example.net> Date: Mon, 01 Jan 2007 06:18:44 -0800 From: Drew Bertola <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20061107) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Re: splitting a string... References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> In-Reply-To: <margaretmorrison@example.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.1.12 (champ.thecoop.net [83.161.120.155]); Mon, 01 Jan 2007 06:18:44 -0800 (PST) X-Virus-Scanned: ClamAV 0.88.7/2400/Sun Dec 31 15:02:33 2006 on champ.thecoop.net X-Virus-Status: Clean X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on champ.thecoop.net X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00, DNS_FROM_RFC_ABUSE,RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no version=3.1.7 Joachim Zobel wrote: > Am Montag, den 01.01.2007, 01:48 -0800 schrieb Drew Bertola: > >> APR_BUCKET_REMOVE(e); >> APR_BRIGADE_INSERT_TAIL(ctx->bb, e); >> This generates segfaults when processing php and doesn't help with my problem. Is the problem due to filter order? > This is what you should dow with every bucket you dont handle. > > >> while ( i < len ) >> { >> ap_fputc(f->next, ctx->bb, str[i++]); >> } >> > > This is a performance hog. > With this, I don't have the segfaults anymore. html is ok too. -- Drew From modules-margaretmorrison@example.net Mon Jan 01 14:59:46 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 68860 invoked from network); 1 Jan 2007 14:59:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jan 2007 14:59:45 -0000 Received: (qmail 37405 invoked by uid 500); 1 Jan 2007 14:59:51 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 37396 invoked by uid 500); 1 Jan 2007 14:59:51 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 37386 invoked by uid 99); 1 Jan 2007 14:59:51 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 06:59:51 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO dedi17.smart-servers.de) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 06:59:41 -0800 Received: from xdsl-81-173-169-23.netcologne.de ([83.161.120.155] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from <margaretmorrison@example.net>) id 1H1Od4-0000uS-62 for margaretmorrison@example.net; Mon, 01 Jan 2007 15:59:10 +0100 Received: from asus.crrrwg.de ([83.161.120.155] ident=471546cc9736fa2e21e3cc7a0fe8523c) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1OdB-0000yU-Kp for margaretmorrison@example.net; Mon, 01 Jan 2007 15:59:17 +0100 Subject: Re: splitting a string... From: Joachim Zobel <margaretmorrison@example.net> Reply-To: margaretmorrison@example.net To: margaretmorrison@example.net In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Content-Type: text/plain Organization: Not organized Date: Mon, 01 Jan 2007 15:59:10 +0100 Message-Id: <margaretmorrison@example.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 83.161.120.155 X-SA-Exim-Rcpt-To: margaretmorrison@example.net X-SA-Exim-Mail-From: margaretmorrison@example.net X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Montag, den 01.01.2007, 06:18 -0800 schrieb Drew Bertola: > Joachim Zobel wrote: > > Am Montag, den 01.01.2007, 01:48 -0800 schrieb Drew Bertola: > > > >> APR_BUCKET_REMOVE(e); > >> APR_BRIGADE_INSERT_TAIL(ctx->bb, e); > >> > > This generates segfaults when processing php and doesn't help with my > problem. Is the problem due to filter order? No. The problem is due to not removing the buckets you copy. Sincerely, Joachim From modules-margaretmorrison@example.net Mon Jan 01 15:38:43 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 74741 invoked from network); 1 Jan 2007 15:38:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jan 2007 15:38:42 -0000 Received: (qmail 54806 invoked by uid 500); 1 Jan 2007 15:38:49 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 54601 invoked by uid 500); 1 Jan 2007 15:38:49 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 54592 invoked by uid 99); 1 Jan 2007 15:38:48 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 07:38:48 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO dedi17.smart-servers.de) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 07:38:38 -0800 Received: from xdsl-81-173-169-23.netcologne.de ([83.161.120.155] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from <margaretmorrison@example.net>) id 1H1PEl-0000v8-O2 for margaretmorrison@example.net; Mon, 01 Jan 2007 16:38:07 +0100 Received: from asus.crrrwg.de ([83.161.120.155] ident=ac5be653bcfed01581360a125809b38f) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1PEt-0000z7-9D for margaretmorrison@example.net; Mon, 01 Jan 2007 16:38:15 +0100 Subject: Re: splitting a string... From: Joachim Zobel <margaretmorrison@example.net> Reply-To: margaretmorrison@example.net To: margaretmorrison@example.net In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Content-Type: text/plain Organization: Not organized Date: Mon, 01 Jan 2007 16:38:08 +0100 Message-Id: <margaretmorrison@example.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 83.161.120.155 X-SA-Exim-Rcpt-To: margaretmorrison@example.net X-SA-Exim-Mail-From: margaretmorrison@example.net X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Montag, den 01.01.2007, 06:18 -0800 schrieb Drew Bertola: > This generates segfaults when processing php and doesn't help with my > problem. Is the problem due to filter order? To find out more about the segf's do # in the config CoreDumpDirectory /tmp # on the command line ulimit -c unlimited and restart apache. Then use gdb to analyze the coredump. Sincerely, Joachim From modules-margaretmorrison@example.net Tue Jan 02 09:15:22 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 43646 invoked from network); 2 Jan 2007 09:15:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 09:15:19 -0000 Received: (qmail 45747 invoked by uid 500); 2 Jan 2007 09:15:26 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 45545 invoked by uid 500); 2 Jan 2007 09:15:25 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 45536 invoked by uid 99); 2 Jan 2007 09:15:25 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 01:15:25 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO champ.thecoop.net) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 01:15:15 -0800 Received: from [83.161.120.155] (c-24-6-242-246.hsd1.ca.comcast.net [83.161.120.155]) (authenticated bits=0) by champ.thecoop.net (8.13.8/8.13.8) with ESMTP id l029EpgK020404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <margaretmorrison@example.net>; Tue, 2 Jan 2007 01:14:52 -0800 Message-ID: <margaretmorrison@example.net> Date: Tue, 02 Jan 2007 01:14:51 -0800 From: Drew Bertola <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20061219) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Re: splitting a string... References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> In-Reply-To: <margaretmorrison@example.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.1.12 (champ.thecoop.net [83.161.120.155]); Tue, 02 Jan 2007 01:14:52 -0800 (PST) X-Virus-Scanned: ClamAV 0.88.7/2403/Mon Jan 1 14:35:09 2007 on champ.thecoop.net X-Virus-Status: Clean X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on champ.thecoop.net X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00, DNS_FROM_RFC_ABUSE,RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no version=3.1.7 Joachim Zobel wrote: > Am Montag, den 01.01.2007, 06:18 -0800 schrieb Drew Bertola: > >> This generates segfaults when processing php and doesn't help with my >> problem. Is the problem due to filter order? >> > > To find out more about the segf's do [snip - thanks] I'm confused about the cause of the segfaults. Here's what gdb is showing me (again, only for php files)... tail end of gdb /usr/sbin/httpd core.xxxxx: Loaded symbols for /usr/lib/libart_lgpl_2.so.2 Failed to read a valid object file image from memory. Core was generated by `/usr/sbin/httpd'. Program terminated with signal 11, Segmentation fault. #0 0x00000058 in ?? () and the full backtrace shows: #0 0x00000058 in ?? () No symbol table info available. #1 0x001347bf in lt_insert_filter (f=0xa0cbd30, bb=0xa0cc168) at lt_insert.c:91 len = 4104 str = 0xa0d3cb4 "000108 nothing just filling up space,\n000109 nothing just filling up space,\n000110 nothing just filling up space,\n000111 nothing just filling up space,\n000112 nothing just filling up space,\n000113 not"... position = <value optimized out> i = 4123 ctx = (lt_insert_struct *) 0xa0cc188 e = (apr_bucket *) 0xa0cc194 #2 0x007b8f60 in ap_pass_brigade () from /usr/sbin/httpd No symbol table info available. line 91 looks like this: apr_bucket_read(e, &str, &len, APR_NONBLOCK_READ); Also, it only happens if I use APR_BRIGADE_INSERT_TAIL(ctx->bb, e); rather than i = 0; while ( i < len ) { ap_fputc(f->next, ctx->bb, str[i++]); } which works well, but, as you note, is a bit expensive. I'd love to get my hands on a well written "null_output_filter_module". Thanks, -- Drew From modules-margaretmorrison@example.net Tue Jan 02 11:48:17 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 77505 invoked from network); 2 Jan 2007 11:48:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 11:48:16 -0000 Received: (qmail 83351 invoked by uid 500); 2 Jan 2007 11:48:23 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 83328 invoked by uid 500); 2 Jan 2007 11:48:22 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 83319 invoked by uid 99); 2 Jan 2007 11:48:22 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 03:48:22 -0800 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of margaretmorrison@example.net designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO bay0-omc2-s1.bay0.hotmail.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 03:48:10 -0800 Received: from hotmail.com ([83.161.120.155]) by bay0-omc2-s1.bay0.hotmail.com with Microsoft SMTPSVC(929)695-8794); Tue, 2 Jan 2007 03:47:50 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 2 Jan 2007 03:47:49 -0800 Message-ID: <margaretmorrison@example.net> Received: from 83.161.120.155 by by134fd.bay134.hotmail.msn.com with HTTP; Tue, 02 Jan 2007 11:47:48 GMT X-Originating-IP: [83.161.120.155] X-Originating-Email: [margaretmorrison@example.net] X-Sender: margaretmorrison@example.net From: =?gb2312?B?1cUg1emyqQ==?= <margaretmorrison@example.net> To: margaretmorrison@example.net Subject: a different layer Date: Tue, 02 Jan 2007 11:47:48 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=gb2312; format=flowed X-OriginalArrivalTime: 02 Jan 2007 11:47:49.0958 (UTC) FILETIME=[D42B0E60:01C72E63] X-Virus-Checked: Checked by ClamAV on apache.org hello, I am now doing a project which trying to insert one layer between tcp and application layer. It means for the apache server, i can not listen to the tcp socket...Instead listen to another layer socket. Is it possible to realize this by using a module? Or i have to change some other code like, protocol.c in httpd-2.2.3\server folder. Is there somebody who has done something similar and can give some hints? Thanks a lot. br frankie _________________________________________________________________ ÓëÊÀ½ç¸÷µØµÄÅóÓѽøÐн»Á÷£¬Ãâ·ÑÏÂÔØ Live Messenger; http://get.live.com/messenger/overview From modules-margaretmorrison@example.net Tue Jan 02 15:51:37 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 39759 invoked from network); 2 Jan 2007 15:51:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 15:51:36 -0000 Received: (qmail 51152 invoked by uid 500); 2 Jan 2007 15:51:42 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 51131 invoked by uid 500); 2 Jan 2007 15:51:42 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 51122 invoked by uid 99); 2 Jan 2007 15:51:41 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from [83.161.120.155] (HELO jericho.provo.novell.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 07:51:38 -0800 Received: from [83.161.120.155] (jlewis4.provo.novell.com [83.161.120.155]) by jericho.provo.novell.com with ESMTP; Tue, 02 Jan 2007 08:49:39 -0700 Message-ID: <margaretmorrison@example.net> Date: Tue, 02 Jan 2007 08:52:31 -0700 From: Joe Lewis <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20060516) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Re: splitting a string... References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> In-Reply-To: <margaretmorrison@example.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Drew Bertola wrote: >> >> >>> while ( i < len ) >>> { >>> ap_fputc(f->next, ctx->bb, str[i++]); >>> } >>> >>> >> This is a performance hog. >> >> > > With this, I don't have the segfaults anymore. > > html is ok too. > > -- > Drew > I would expect it to be a performance hog. You are playing with creating a good number of individual buckets. Make SURE you are not using things like strcasestr - it is not platform independent (requires GNU source definitions). Besides, you may want to change that to a series of apr_strmatch_precompile and apr_strmatch commands to do the searching - those take an additional parameter for the length of the bucket, and give you another added precaution against the dreaded NULL-termination issues across platforms and other modules. Joe Orton helped me a great deal when I started finding problems that I thought were PHP bugs, but really allowed me to adapt for any lazy module that gets written. If this information is not enough to help, let me know, and I will rip a lot of the code out of my template wrapper and shoot that to you (and hope it works in that state - I won't be doing the "checks" on it). Joe From modules-margaretmorrison@example.net Tue Jan 02 20:05:54 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 27349 invoked from network); 2 Jan 2007 20:05:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 20:05:52 -0000 Received: (qmail 65867 invoked by uid 500); 2 Jan 2007 20:05:57 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 65785 invoked by uid 500); 2 Jan 2007 20:05:57 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 65740 invoked by uid 99); 2 Jan 2007 20:05:57 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 12:05:56 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=RCVD_IN_SORBS_WEB X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO dedi17.smart-servers.de) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 12:05:46 -0800 Received: from xdsl-213-196-247-200.netcologne.de ([83.161.120.155] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from <margaretmorrison@example.net>) id 1H1psd-0003W9-H2 for margaretmorrison@example.net; Tue, 02 Jan 2007 21:05:03 +0100 Received: from asus.crrrwg.de ([83.161.120.155] ident=c18cc80a948ce4fecc66532df34afa21) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1psp-0001cg-PK for margaretmorrison@example.net; Tue, 02 Jan 2007 21:05:15 +0100 Subject: Re: splitting a string... From: Joachim Zobel <margaretmorrison@example.net> Reply-To: margaretmorrison@example.net To: margaretmorrison@example.net In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Content-Type: text/plain Organization: Not organized Date: Tue, 02 Jan 2007 21:05:15 +0100 Message-Id: <margaretmorrison@example.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 83.161.120.155 X-SA-Exim-Rcpt-To: margaretmorrison@example.net X-SA-Exim-Mail-From: margaretmorrison@example.net X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Dienstag, den 02.01.2007, 01:14 -0800 schrieb Drew Bertola: > line 91 looks like this: > > apr_bucket_read(e, &str, &len, APR_NONBLOCK_READ); > > Also, it only happens if I use > > APR_BRIGADE_INSERT_TAIL(ctx->bb, e); Ah, understood. You don't mention this, but you probably have a for ( e = APR_BRIGADE_FIRST(bb) ; e != APR_BRIGADE_SENTINEL(bb) ; e = APR_BUCKET_NEXT(e) ) { for your loop. Right? So if you _move_ e to another brigade, the e != APR_BRIGADE_SENTINEL(bb) will never be fullfilled and APR_BUCKET_NEXT(e) will step through the wrong brigade and will treat the sentinel as a bucket. This causes the observed segfault. You could instead copy the bucket using /** * Copy a bucket. * @param e The bucket to copy * @param c Returns a pointer to the new bucket */ #define apr_bucket_copy(e,c) (e)->type->copy(e, c) And then delete the bucket at the end of the loop using /** * Delete a bucket by removing it from its brigade (if any) and then * destroying it. * @remark This mainly acts as an aid in avoiding code verbosity. It is * the preferred exact equivalent to: * <pre> * APR_BUCKET_REMOVE(e); * apr_bucket_destroy(e); * </pre> * @param e The bucket to delete */ #define apr_bucket_delete(e) do { \ APR_BUCKET_REMOVE(e); \ apr_bucket_destroy(e); \ } while (0) Since buckets do reference counting this is not copying of the data, so its relatively cheap. There are other solutions, which work equally well. Sincerely, Joachim From modules-margaretmorrison@example.net Tue Jan 02 21:15:36 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 62955 invoked from network); 2 Jan 2007 21:15:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 21:15:35 -0000 Received: (qmail 94668 invoked by uid 500); 2 Jan 2007 21:15:41 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 94648 invoked by uid 500); 2 Jan 2007 21:15:41 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 94639 invoked by uid 99); 2 Jan 2007 21:15:40 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:15:40 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO champ.thecoop.net) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:15:30 -0800 Received: from [83.161.120.155] (c-24-6-242-246.hsd1.ca.comcast.net [83.161.120.155]) (authenticated bits=0) by champ.thecoop.net (8.13.8/8.13.8) with ESMTP id l02LF65f013398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <margaretmorrison@example.net>; Tue, 2 Jan 2007 13:15:07 -0800 Message-ID: <margaretmorrison@example.net> Date: Tue, 02 Jan 2007 13:15:06 -0800 From: Drew Bertola <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20061219) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Re: splitting a string... References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> In-Reply-To: <margaretmorrison@example.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.1.12 (champ.thecoop.net [83.161.120.155]); Tue, 02 Jan 2007 13:15:07 -0800 (PST) X-Virus-Scanned: ClamAV 0.88.7/2406/Tue Jan 2 03:58:55 2007 on champ.thecoop.net X-Virus-Status: Clean X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on champ.thecoop.net X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00, DNS_FROM_RFC_ABUSE,RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no version=3.1.7 Joe Lewis wrote: > Make SURE you are not using things like strcasestr - it is not > platform independent (requires GNU source definitions). Besides, you > may want to change that to a series of apr_strmatch_precompile and > apr_strmatch commands to do the searching - those take an additional > parameter for the length of the bucket, and give you another added > precaution against the dreaded NULL-termination issues across > platforms and other modules. Joe Orton helped me a great deal when I > started finding problems that I thought were PHP bugs, but really > allowed me to adapt for any lazy module that gets written. Thanks, Joe. I made a mental note to revisit apr_strmatch and friends. I have to find an example of how to allocate the pool used in the precompile. It would be nice if I could attach it to the server pool so that it would only be precompiled once, no? Any help there? -- Drew From modules-margaretmorrison@example.net Tue Jan 02 21:29:33 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 67674 invoked from network); 2 Jan 2007 21:29:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 21:29:32 -0000 Received: (qmail 22394 invoked by uid 500); 2 Jan 2007 21:29:38 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 22376 invoked by uid 500); 2 Jan 2007 21:29:38 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 22367 invoked by uid 99); 2 Jan 2007 21:29:38 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:29:38 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=RCVD_IN_SORBS_WEB X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO dedi17.smart-servers.de) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:29:28 -0800 Received: from xdsl-213-196-247-200.netcologne.de ([83.161.120.155] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from <margaretmorrison@example.net>) id 1H1rBj-0003YN-77 for margaretmorrison@example.net; Tue, 02 Jan 2007 22:28:51 +0100 Received: from asus.crrrwg.de ([83.161.120.155] ident=302379a3772363ee4c207b489dae2900) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1rBx-0001e0-HK for margaretmorrison@example.net; Tue, 02 Jan 2007 22:29:05 +0100 Subject: Re: splitting a string... From: Joachim Zobel <margaretmorrison@example.net> Reply-To: margaretmorrison@example.net To: margaretmorrison@example.net In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Content-Type: text/plain Organization: Not organized Date: Tue, 02 Jan 2007 22:29:05 +0100 Message-Id: <margaretmorrison@example.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 83.161.120.155 X-SA-Exim-Rcpt-To: margaretmorrison@example.net X-SA-Exim-Mail-From: margaretmorrison@example.net X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Dienstag, den 02.01.2007, 13:15 -0800 schrieb Drew Bertola: > I made a mental note to revisit apr_strmatch and friends. I have to > find an example of how to allocate the pool used in the precompile. I doubt that this is worth the effort, but a child init handler, that initialises a static would be the place to do this. See http://www.google.com/codesearch?q=ap_hook_child_init for examples. Sincerely, Joachim From modules-margaretmorrison@example.net Tue Jan 02 21:30:28 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 67816 invoked from network); 2 Jan 2007 21:30:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 21:30:27 -0000 Received: (qmail 23499 invoked by uid 500); 2 Jan 2007 21:30:34 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 23297 invoked by uid 500); 2 Jan 2007 21:30:33 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 23288 invoked by uid 99); 2 Jan 2007 21:30:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:30:33 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO champ.thecoop.net) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:30:23 -0800 Received: from [83.161.120.155] (c-24-6-242-246.hsd1.ca.comcast.net [83.161.120.155]) (authenticated bits=0) by champ.thecoop.net (8.13.8/8.13.8) with ESMTP id l02LTxuw018202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <margaretmorrison@example.net>; Tue, 2 Jan 2007 13:30:00 -0800 Message-ID: <margaretmorrison@example.net> Date: Tue, 02 Jan 2007 13:29:59 -0800 From: Drew Bertola <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20061219) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Re: splitting a string... References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> In-Reply-To: <margaretmorrison@example.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.1.12 (champ.thecoop.net [83.161.120.155]); Tue, 02 Jan 2007 13:30:00 -0800 (PST) X-Virus-Scanned: ClamAV 0.88.7/2406/Tue Jan 2 03:58:55 2007 on champ.thecoop.net X-Virus-Status: Clean X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on champ.thecoop.net X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00, DNS_FROM_RFC_ABUSE,RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no version=3.1.7 Joachim Zobel wrote: > Am Dienstag, den 02.01.2007, 01:14 -0800 schrieb Drew Bertola: > >> line 91 looks like this: >> >> apr_bucket_read(e, &str, &len, APR_NONBLOCK_READ); >> >> Also, it only happens if I use >> >> APR_BRIGADE_INSERT_TAIL(ctx->bb, e); >> > > Ah, understood. > > You don't mention this, but you probably have a > > for ( e = APR_BRIGADE_FIRST(bb) ; > e != APR_BRIGADE_SENTINEL(bb) ; > e = APR_BUCKET_NEXT(e) ) { > > for your loop. Right? > > So if you _move_ e to another brigade, the e != APR_BRIGADE_SENTINEL(bb) > will never be fullfilled and APR_BUCKET_NEXT(e) will step through the > wrong brigade and will treat the sentinel as a bucket. This causes the > observed segfault. Are you sure about that? Again, makes me wish for a null output filter example. My understanding is that it would need this: - create context if it doesn't already exist. - loop through buckets (from FIRST to SENTINEL) in brigade passed to filter appending each bucket to my context's brigade. - pass my brigade to next filter. So, shouldn't this work? ... static int null_filter(ap_filter_t *f, apr_bucket_brigade *bb) { null_filter_struct *ctx = f->ctx; apr_bucket *e; /* * if we don't have a context for this filter, let's create one and * create it's bucket brigade. */ if ( ! ctx ) { f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); ctx->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); } /* * let's loop through the buckets passed to us. */ for( e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb); e = APR_BUCKET_NEXT(e) ) { /* * if the bucket is an end of stream bucket or a flush bucket, * we can pass on what we have so far and be done with this brigade. */ if ( APR_BUCKET_IS_EOS(e) || APR_BUCKET_IS_FLUSH(e) ) { APR_BRIGADE_INSERT_TAIL(ctx->bb, e); APR_BUCKET_REMOVE(e); ap_pass_brigade(f->next, ctx->bb); return APR_SUCCESS; } APR_BRIGADE_INSERT_TAIL(ctx->bb, e); APR_BUCKET_REMOVE(e); } ap_pass_brigade(f->next, ctx->bb); return APR_SUCCESS; } I'm not sure about these things: - do I need to look out for APR_BUCKET_IS_EOS or APR_BUCKET_IS_FLUSH or are they implicit before APR_BRIGADE_IS_SENTINEL? - do I need to use ap_pass_brigade()? I've used it here before returning. -- Drew From modules-margaretmorrison@example.net Tue Jan 02 21:52:50 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 77185 invoked from network); 2 Jan 2007 21:52:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 21:52:49 -0000 Received: (qmail 68811 invoked by uid 500); 2 Jan 2007 21:52:56 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 68792 invoked by uid 500); 2 Jan 2007 21:52:56 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 68783 invoked by uid 99); 2 Jan 2007 21:52:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:52:55 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO jericho.provo.novell.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:52:45 -0800 Received: from [83.161.120.155] (jlewis4.provo.novell.com [83.161.120.155]) by jericho.provo.novell.com with ESMTP; Tue, 02 Jan 2007 14:52:19 -0700 Message-ID: <margaretmorrison@example.net> Date: Tue, 02 Jan 2007 14:55:11 -0700 From: Joe Lewis <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20060516) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Re: splitting a string... References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> In-Reply-To: <margaretmorrison@example.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Drew Bertola wrote: > Again, makes me wish for a null output filter example. > Try this link - it was written about 6 years ago, but still applies. It's a Ryan Bloom article (he was one of the APR developers). The link : http://www.serverwatch.com/news/article.php/1127731 > My understanding is that it would need this: > > - create context if it doesn't already exist. > Only if you are going to use it. > - loop through buckets (from FIRST to SENTINEL) in brigade passed to > filter appending each bucket to my context's brigade. > Yes. > - pass my brigade to next filter. > Yes. (If they are not passed, you will not get that data). [snip] > - do I need to look out for APR_BUCKET_IS_EOS or APR_BUCKET_IS_FLUSH or > are they implicit before APR_BRIGADE_IS_SENTINEL? > Watch for them.. > - do I need to use ap_pass_brigade()? I've used it here before returning. > Yes. When done, always pass a brigade, whether it is a new one or the original brigade (modified or not). Joe From modules-margaretmorrison@example.net Tue Jan 02 21:59:39 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 81833 invoked from network); 2 Jan 2007 21:59:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 21:59:38 -0000 Received: (qmail 79091 invoked by uid 500); 2 Jan 2007 21:59:45 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 79080 invoked by uid 500); 2 Jan 2007 21:59:45 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 79071 invoked by uid 99); 2 Jan 2007 21:59:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:59:45 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=RCVD_IN_SORBS_WEB X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO dedi17.smart-servers.de) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:59:33 -0800 Received: from xdsl-213-196-247-200.netcologne.de ([83.161.120.155] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from <margaretmorrison@example.net>) id 1H1req-0003Z6-2m for margaretmorrison@example.net; Tue, 02 Jan 2007 22:58:56 +0100 Received: from asus.crrrwg.de ([83.161.120.155] ident=517d7d45de0e3c7a96a770b66e0ed8a4) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1rf4-0001eR-GZ for margaretmorrison@example.net; Tue, 02 Jan 2007 22:59:10 +0100 Subject: Re: splitting a string... From: Joachim Zobel <margaretmorrison@example.net> Reply-To: margaretmorrison@example.net To: margaretmorrison@example.net In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> <margaretmorrison@example.net> Content-Type: text/plain Organization: Not organized Date: Tue, 02 Jan 2007 22:59:09 +0100 Message-Id: <margaretmorrison@example.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 83.161.120.155 X-SA-Exim-Rcpt-To: margaretmorrison@example.net X-SA-Exim-Mail-From: margaretmorrison@example.net X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Dienstag, den 02.01.2007, 13:29 -0800 schrieb Drew Bertola: > > for ( e = APR_BRIGADE_FIRST(bb) ; > > e != APR_BRIGADE_SENTINEL(bb) ; > > e = APR_BUCKET_NEXT(e) ) { > - create context if it doesn't already exist. > - loop through buckets (from FIRST to SENTINEL) in brigade passed to > filter appending each bucket to my context's brigade. The moment you append e the value of APR_BUCKET_NEXT(e) changes to your context brigades sentinel. > - pass my brigade to next filter. > > So, shouldn't this work? ... > - do I need to look out for APR_BUCKET_IS_EOS or APR_BUCKET_IS_FLUSH or > are they implicit before APR_BRIGADE_IS_SENTINEL? Yes and no. You can have multiple brigades and only the last one holds _the_ EOS bucket. > - do I need to use ap_pass_brigade()? I've used it here before returning. That depends, but usually you will use it. ap_pass_brigade is misnomed. It passes the buckets held by the parameter brigade to the next filters brigade. Alternatively you probably could append to the next filters brigade. See also http://www.heute-morgen.de/modules/doc/well_behaved_filters.html Sincerely, Joachim From modules-margaretmorrison@example.net Thu Jan 04 00:09:32 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 2113 invoked from network); 4 Jan 2007 00:09:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Jan 2007 00:09:31 -0000 Received: (qmail 92258 invoked by uid 500); 4 Jan 2007 00:09:38 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 92056 invoked by uid 500); 4 Jan 2007 00:09:37 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 91948 invoked by uid 99); 4 Jan 2007 00:09:37 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 16:09:37 -0800 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO champ.thecoop.net) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 16:09:14 -0800 Received: from [83.161.120.155] (c-24-6-242-246.hsd1.ca.comcast.net [83.161.120.155]) (authenticated bits=0) by champ.thecoop.net (8.13.8/8.13.8) with ESMTP id l0408pkr032057 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <margaretmorrison@example.net>; Wed, 3 Jan 2007 16:08:51 -0800 Message-ID: <margaretmorrison@example.net> Date: Wed, 03 Jan 2007 16:08:51 -0800 From: Drew Bertola <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (X11/20061219) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: help with filter example: null_filter... Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.1.12 (champ.thecoop.net [83.161.120.155]); Wed, 03 Jan 2007 16:08:51 -0800 (PST) X-Virus-Scanned: ClamAV 0.88.7/2411/Wed Jan 3 10:04:33 2007 on champ.thecoop.net X-Virus-Status: Clean X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on champ.thecoop.net X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00, DNS_FROM_RFC_ABUSE,RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no version=3.1.7 Hey everyone, I'm trying to create a demonstration filter that does nothing but pass buckets to the next filter. I'll extend this later to include reading configuration data, and other standard tasks. Right now, it's not working and I could use some expert help. Since this will be a demonstration filter, I'll gladly create a tutorial for others to see. Hopefully, we can document some best practices this way. The problem right now looks like it doesn't finish. Requesting a test page that uses this filter never completes. I've gotten this far by looking at examples, and discussing here some of the problems I'm having with a real (usable) filter I'm writing. Here's the code so far: -------------------------------------------------------------------------- /* * file: null_filter.c * * description: a null output filter module for apache2.x that will pass * all data through to the next filter. This will also be used to * test configuration handling and file handling. */ #define DEBUG 1 #include "httpd.h" #include "http_config.h" #include "http_log.h" #include "http_request.h" #include "apr_general.h" #include "apr_strings.h" #include "apr_strmatch.h" #include "apr_buckets.h" #include "apr_pools.h" #include "apr_file_io.h" #include "util_filter.h" module AP_MODULE_DECLARE_DATA null_filter_module; typedef struct null_filter_context_t { apr_bucket_brigade *bb; } null_filter_context; static int null_filter(ap_filter_t *f, apr_bucket_brigade *bb) { null_filter_context *ctx = f->ctx; apr_bucket *e; /* * if we don't have a context for this filter, let's create one and * create it's bucket brigade. */ if ( ! ctx ) { f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); ctx->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc); } /* * let's loop through the buckets passed to us. */ for( e = APR_BRIGADE_FIRST(bb); e != APR_BRIGADE_SENTINEL(bb); e = APR_BUCKET_NEXT(e) ) { /* * if the bucket is an end of stream bucket or a flush bucket, * we can pass on what we have so far and be done with this brigade. */ if ( APR_BUCKET_IS_EOS(e) || APR_BUCKET_IS_FLUSH(e) ) { APR_BUCKET_REMOVE(e); APR_BRIGADE_INSERT_TAIL(ctx->bb, e); ap_pass_brigade(f->next, ctx->bb); return APR_SUCCESS; } APR_BUCKET_REMOVE(e); APR_BRIGADE_INSERT_TAIL(ctx->bb, e); } ap_pass_brigade(f->next, ctx->bb); return APR_SUCCESS; } static void register_hooks(apr_pool_t *p) { ap_register_output_filter("NULL_FILTER", null_filter, NULL, AP_FTYPE_CONTENT_SET); } module AP_MODULE_DECLARE_DATA null_filter_module = { STANDARD20_MODULE_STUFF, NULL, /* create per-directory config structure */ NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ NULL, /* command apr_table_t */ register_hooks /* register hooks */ }; -------------------------------------------------------------------------- -- Drew From modules-margaretmorrison@example.net Thu Jan 04 00:16:34 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 5070 invoked from network); 4 Jan 2007 00:16:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Jan 2007 00:16:32 -0000 Received: (qmail 2954 invoked by uid 500); 4 Jan 2007 00:16:37 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 2914 invoked by uid 500); 4 Jan 2007 00:16:37 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 2895 invoked by uid 99); 4 Jan 2007 00:16:37 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 16:16:37 -0800 X-ASF-Spam-Status: No, hits=0.9 required=10.0 tests=DNS_FROM_RFC_WHOIS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO bangkok.infostreet.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 16:16:27 -0800 Received: (qmail 11052 invoked from network); 4 Jan 2007 00:14:48 -0000 Received: from dsl253-062-155.lax1.dsl.speakeasy.net (HELO ?83.161.120.155?) (83.161.120.155) by bangkok.infostreet.com with SMTP; 4 Jan 2007 00:14:48 -0000 Message-ID: <margaretmorrison@example.net> Date: Wed, 03 Jan 2007 16:16:14 -0800 From: Shezaan Topiwala <margaretmorrison@example.net> User-Agent: Thunderbird 83.161.120.155 (Windows/20061207) MIME-Version: 1.0 To: margaretmorrison@example.net Subject: Help with http_protocol.c Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, The following snippet of code is from the http_protocol.c from Apache1.3. I would like to know what its equivalent would be in Apache2.0. Here is the code. static int send_buffer( request_rec *r, void *buf, size_t len ){ unsigned written; written = ap_bwrite( r->connection->client, buf, len ); if (written > 0) ap_reset_timeout(r); else if (written < 0){ if (!r->connection->aborted){ ap_log_rerror( APLOG_MARK, APLOG_INFO,0,r, "client stopped connection before send body completed" ); ap_bsetflag( r->connection->client, B_EOUT, 1 ); r->connection->aborted = 1; } return 0; } return written; } Thanks in advance From modules-margaretmorrison@example.net Thu Jan 04 00:34:59 2007 Return-Path: <modules-margaretmorrison@example.net> Delivered-To: margaretmorrison@example.net Received: (qmail 8018 invoked from network); 4 Jan 2007 00:34:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 4 Jan 2007 00:34:59 -0000 Received: (qmail 21002 invoked by uid 500); 4 Jan 2007 00:35:05 -0000 Delivered-To: margaretmorrison@example.net Received: (qmail 20971 invoked by uid 500); 4 Jan 2007 00:35:05 -0000 Mailing-List: contact margaretmorrison@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:margaretmorrison@example.net> List-Unsubscribe: <mailto:margaretmorrison@example.net> List-Post: <mailto:margaretmorrison@example.net> List-Id: <modules-dev.httpd.apache.org> Reply-To: margaretmorrison@example.net Delivered-To: mailing list margaretmorrison@example.net Received: (qmail 20960 invoked by uid 99); 4 Jan 2007 00:35:05 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 16:35:05 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [83.161.120.155] (HELO grimnir.webthing.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 16:34:56 -0800 Received: from grimnir.webthing.com (localhost [83.161.120.155]) by grimnir.webthing.com (Postfix) with ESMTP id E78E12136 for <margaretmorrison@example.net>; Thu, 4 Jan 2007 00:34:34 +0000 (GMT) Date: Thu, 4 Jan 2007 00:34:34 +0000 From: Nick Kew <margaretmorrison@example.net> To: margaretmorrison@example.net Subject: Re: help with filter example: null_filter... Message-ID: <20070104003434.33ead4f9@grimnir> In-Reply-To: <margaretmorrison@example.net> References: <margaretmorrison@example.net> Organization: WebThing X-Mailer: Sylpheed-Claws 2.5.0-rc3 (GTK+ 2.10.6; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Wed, 03 Jan 2007 16:08:51 -0800 Drew Bertola <margaretmorrison@example.net> wrote: > Hey everyone, > > I'm trying to create a demonstration filter that does nothing but pass > buckets to the next filter. Take a look at mod_diagnostics, which is a lot simpler than your code. > typedef struct null_filter_context_t { > apr_bucket_brigade *bb; > } null_filter_context; That's no part of a null filter. Neither is any use of f->ctx, whose purpose is to save state. > static int null_filter(ap_filter_t *f, apr_bucket_brigade *bb) > { > null_filter_context *ctx = f->ctx; > apr_bucket *e; > > /* > * if we don't have a context for this filter, let's create one and > *
{'source': 'Apache Software Foundation Public Mail Archives'}