[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modules
Subject:    RE: [apache-modules] Delays with Apache 2 filter
From:       "Tikka, Sami" <Sami.Tikka () F-Secure ! com>
Date:       2004-03-26 9:32:44
Message-ID: 83879A37F8F8E8439B850BD8F9364A660813D9 () fsfimail3 ! fi ! f-secure ! com
[Download RAW message or body]

Yep, you're missing handling of the EOS bucket. 

At the end of your filter, before you pass the brigade, you should check if
the last bucket in input brigade 'bb' is an EOS and if it is, move it to the
end of the output brigade 'out'. Something like:

apr_bucket_t *b = APR_BRIGADE_LAST(bb);
If (APR_BUCKET_IS_EOS(b)) {
	APR_BUCKET_REMOVE(b);
	APR_BRIGADE_INSERT_TAIL(out, b);
}

Also, my understanding of the buckets is that if you do not pass a bucket
down to the next filter, YOU are responsible for freeing it. Buckets are not
associated with any pools, so they are not automatically freed during pool
cleanup. So you need to add:

apr_brigade_cleanup(bb);

... before returning. Otherwise you will leak memory.

-- Sami

>-----Original Message-----
>From: Vacuum Joe [mailto:vacuumjoe@yahoo.com] 
>Sent: Friday, March 26, 2004 1:58 AM
>To: apache-modules@covalent.net
>Subject: [apache-modules] Delays with Apache 2 filter
>
>
>Hello, I have one last question on Apache 2 filters: I
>wrote this simple filter method:
>
>  char *html;
>  apr_size_t length;
>  request_rec *r = filter->r;
>  assert(r);
>  assert(r->pool);
>  apr_brigade_pflatten(bb, &html, &length, r->pool);
>  char *output = calloc(length + 1, sizeof(char));
>  int i;
>  for(i = 0; i < length; i++) *(output + i) = *(html +
>length - i - 1);
>  conn_rec *c = r->connection;
>  assert(c);
>  apr_bucket_brigade *out =
>apr_brigade_create(r->pool, c->bucket_alloc);
>  assert(out);
>  apr_brigade_write(out, NULL, NULL, output, length);
>  return ap_pass_brigade(filter->next, out);
>
>All it does is take the input and output it reversed,
>character by character.  It works fine when outputting
>a static file, but when I apply this to a
>PHP-generated document, it outputs quickly but somehow
>the service hangs before closing for a few seconds.  I
>observe this when I use curl to get the page, and the
>page I am looking at is just the simple phpinfo()
>function.
>
>I have a feeling I'm missing something which flushes
>the brigade or somehow tells the server core "I'm done
>here".  Any ideas?
>
>Thanks
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Finance Tax Center - File online. File on time. 
http://taxes.yahoo.com/filing.html

---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net


---------------------------------------------------------------------
To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net
For additional commands, e-mail: apache-modules-help@covalent.net


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic