On Fri, Aug 13, 2004 at 01:21:15PM -0400, Greg Ames wrote: > Glenn Strauss wrote: > >On Wed, Aug 11, 2004 at 03:51:13PM -0700, Justin Erenkrantz wrote: > > >>Please back up a bit. > >> > >>Why do you think the modes should be combined? -- justin > > > > >More details: > >------------- > >Why bitflags, you ask? > > > AP_MODE_MIME_FOLDING = 16 > > yuck. > > getline would be more efficient and easier to understand if we removed the > folding code and created a separate function whose only job is to do > folding, i.e., get single lines one at a time and combine them if > appropriate. ap_get_mime_headers_core() works pretty much like that now, > but it has optimizations and additional functions that won't work for a > more general ap_get_folded_line() or whatever.
ap_rgetline and ap_get_mime_headers are too specific to be useful except in a few places. They both pull from r->input_filters, which makes them unusable by any routine that wants to pull a line from a brigade and is located in the filter chain anywhere other than at the end. I'm aiming more at a generic API to aid routines that have a brigade (that they can stick in an ap_filter_ra_t) and have these routines do the dirty work, whether it be to pull a certain number of bytes or mime folding or speculative reads. > If the seldom used folding code is removed from the basic getline, there > will be no need to test a folding flag/parameter in the usual non-folding > case, and the instruction cache hit rate will improve. If you're concerned with icache performance, then there are plenty of other places where Apache could benefit from a little code reorg. (We all know that increasing code reuse and reducing code duplication often improves icache performance.) > As far as I know, only mod_proxy calls ap_getline today with the folding > flag set. Third party modules could do the same, but if we changed this on > a release boundary it shouldn't be too disruptive. That's because ap_get_mime_headers() implements its own folding. The hoop-jumping behavior of ap_rgetline_core() to not remove all whitespace from a line containing only whitespace is not needed if the API that detects MIME folding is at a lower lever and can return consistent values for completed lines. (An alternative is not having ap_rgetline_core() remove whitespace and having each routine that calls it do it itself.) Any comments on the ap_rgetline() and ap_get_mime_headers() examples using ap_brigade_ra* that I posted to the list this morning? One of the reasons I wrote this API is to be able to make the core routines ap_rgetline_core(), ap_get_mime_headers(), and others fully non-blocking if APR_NONBLOCKING_READ is requested. (Instead of using ap_regetline_core() and ap_get_mime_headers(), I'd make other routines that took an (ap_filter_ra_t *) as an arg so that state could be kept when nonblocking was desired) Do you have other suggestions how to accomplish this without having something keeping state (such as the readahead API I proposed)? Thanks. Glenn
