* Provide a string hashing function for the proxy. * We offer 2 methods: one is the APR model but we * also provide our own, based on either FNV or SDBM. * The reason is in case we want to use both to ensure no * collisions. */
| 4293 | * collisions. |
| 4294 | */ |
| 4295 | PROXY_DECLARE(unsigned int) |
| 4296 | ap_proxy_hashfunc(const char *str, proxy_hash_t method) |
| 4297 | { |
| 4298 | if (method == PROXY_HASHFUNC_APR) { |
| 4299 | apr_ssize_t slen = strlen(str); |
| 4300 | return apr_hashfunc_default(str, &slen); |
| 4301 | } |
| 4302 | else if (method == PROXY_HASHFUNC_FNV) { |
| 4303 | /* FNV model */ |
| 4304 | unsigned int hash; |
| 4305 | const unsigned int fnv_prime = 0x811C9DC5; |
| 4306 | for (hash = 0; *str; str++) { |
| 4307 | hash *= fnv_prime; |
| 4308 | hash ^= (*str); |
| 4309 | } |
| 4310 | return hash; |
| 4311 | } |
| 4312 | else { /* method == PROXY_HASHFUNC_DEFAULT */ |
| 4313 | /* SDBM model */ |
| 4314 | unsigned int hash; |
| 4315 | for (hash = 0; *str; str++) { |
| 4316 | hash = (*str) + (hash << 6) + (hash << 16) - hash; |
| 4317 | } |
| 4318 | return hash; |
| 4319 | } |
| 4320 | } |
| 4321 | |
| 4322 | PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(char c, int set, proxy_worker *w) |
| 4323 | { |
no outgoing calls
no test coverage detected