httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Khrustalev <d...@bog.msu.su>
Subject Re: [IDEA] using tsearch() -- was: [finrod@EWOX.ORG: YA Apache DoS attack]
Date Fri, 14 Aug 1998 00:39:29 GMT

On Thu, 13 Aug 1998, Dean Gaudet wrote:

> 
> On Thu, 13 Aug 1998, Dean Gaudet wrote:
> 
> > One option for speeding up the core and proxy, which search for fixed-name
> > such as "Content-Length" would be to "intern" the names.
> 
> BTW, we can use a perfect hash to do the intern operation as well -- so
> we'd actually have a flat file that lists all the internable names, and
> then a tool that generates a few .h files and a .c file with the perfect
> hash function in it.  Standard compiler trick :) 

Well, I played with perfect hash and structure like this:

typedef struct {
    pool *pool;
    const char *strings[HEADER_MAXVAL];
    table *more;
} headers;

with api like this:

#define ap_header_get(h, n) ((h)->strings[(n)])
#define ap_header_set(h, n, v) ((h)->strings[(n)] = (v))
#define ap_header_merge(h, n, v) ((((h)->strings[(n)]) == NULL ) ? \
		((h)->strings[(n)] = (v)) : \
		((h)->strings[(n)] = ap_pstrcat(h->pool, (h)->strings[(n)], \
		", ", (v), NULL)))
#define ap_header_unset(h, n) ((h)->strings[(n)] = NULL)
API_EXPORT(const char *) ap_header_getstr(const headers *, const char *);
API_EXPORT(void) ap_header_setstr(headers *, const char *name, const char *val);
API_EXPORT(void) ap_header_mergestr(headers *, const char *, const char *);
API_EXPORT(void) ap_header_unsetstr(headers *, const char *key);

Known headers are referenced by numeric constant, unknown go into more
table. Set-Cookie trick in util_script.c is unsupported.

	-Dima


Mime
View raw message