Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 67816 invoked from network); 2 Jan 2007 21:30:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) 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: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 23297 invoked by uid 500); 2 Jan 2007 21:30:33 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 23288 invoked by uid 99); 2 Jan 2007 21:30:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) 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 [216.218.255.169] (HELO champ.thecoop.net) (216.218.255.169) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 13:30:23 -0800 Received: from [192.168.1.6] (c-24-6-242-246.hsd1.ca.comcast.net [24.6.242.246]) (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 ; Tue, 2 Jan 2007 13:30:00 -0800 Message-ID: <459ACED7.9030402@jupiterhosting.com> Date: Tue, 02 Jan 2007 13:29:59 -0800 From: Drew Bertola User-Agent: Thunderbird 1.5.0.9 (X11/20061219) MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: splitting a string... References: <45972688.7090502@jupiterhosting.com> <1167566411.6170.22.camel@test.asus> <45981B09.8080704@jupiterhosting.com> <1167604803.6170.26.camel@test.asus> <45986BB7.2000903@joe-lewis.com> <4598D8E3.9060102@jupiterhosting.com> <1167645825.5604.13.camel@test.asus> <45991844.5070008@jupiterhosting.com> <1167665888.5604.23.camel@test.asus> <459A228B.1020107@jupiterhosting.com> <1167768315.4483.11.camel@test.asus> In-Reply-To: <1167768315.4483.11.camel@test.asus> 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 [216.218.255.169]); 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