int
FetchBody(struct worker *w, struct sess *sp)
{
- int i, cls;
+ int cls;
struct vbe_conn *vc;
struct http *hp;
char *b;
- int body;
+ int body = 1; /* XXX */
vc = sp->vbc;
hp = sp->bkd_http;
int
FetchHeaders(struct worker *w, struct sess *sp)
{
- int i, cls;
+ int i;
struct vbe_conn *vc;
struct http *hp;
- char *b;
- int body;
sp->obj->xid = sp->xid;
{
struct objhead *oh;
struct object *o;
- char *b;
+ char *b, *c;
assert(hash != NULL);
/* Precreate an objhead and object in case we need them */
}
assert(http_GetURL(h, &b));
- oh = hash->lookup(b, w->nobjhead);
+ if (!http_GetHdr(h, "Host", &c))
+ c = b;
+ oh = hash->lookup(b, c, w->nobjhead);
if (oh == w->nobjhead)
w->nobjhead = NULL;
AZ(pthread_mutex_lock(&oh->mtx));
struct hcl_entry {
TAILQ_ENTRY(hcl_entry) list;
- char *key;
+ char *key1;
+ char *key2;
struct objhead *obj;
unsigned refcnt;
unsigned hash;
*/
static struct objhead *
-hcl_lookup(const char *key, struct objhead *nobj)
+hcl_lookup(const char *key1, const char *key2, struct objhead *nobj)
{
struct hcl_entry *he, *he2;
MD5_CTX c;
int i;
MD5Init(&c);
- MD5Update(&c, key, strlen(key));
+ MD5Update(&c, key1, strlen(key1));
+ MD5Update(&c, "", 1);
+ MD5Update(&c, key2, strlen(key2));
MD5Final(md5, &c);
memcpy(&u1, md5, sizeof u1);
u1 %= hcl_nhash;
AZ(pthread_mutex_lock(&hcl_mutex[u2]));
TAILQ_FOREACH(he, &hcl_head[u1], list) {
- i = strcmp(key, he->key);
+ i = strcmp(key1, he->key1);
if (i < 0)
continue;
- if (i == 0) {
- he->refcnt++;
- nobj = he->obj;
- nobj->hashpriv = he;
- AZ(pthread_mutex_unlock(&hcl_mutex[u2]));
- return (nobj);
- }
- if (nobj == NULL) {
- AZ(pthread_mutex_unlock(&hcl_mutex[u2]));
- return (NULL);
- }
- break;
+ if (i > 0)
+ break;
+ i = strcmp(key2, he->key2);
+ if (i < 0)
+ continue;
+ if (i > 0)
+ break;
+ he->refcnt++;
+ nobj = he->obj;
+ nobj->hashpriv = he;
+ AZ(pthread_mutex_unlock(&hcl_mutex[u2]));
+ return (nobj);
+ }
+ if (nobj == NULL) {
+ AZ(pthread_mutex_unlock(&hcl_mutex[u2]));
+ return (NULL);
}
he2 = calloc(sizeof *he2, 1);
assert(he2 != NULL);
he2->refcnt = 1;
he2->hash = u1;
he2->mtx = u2;
- he2->key = strdup(key);
- assert(he2->key != NULL);
+ he2->key1 = strdup(key1);
+ assert(he2->key1 != NULL);
+ he2->key2 = strdup(key2);
+ assert(he2->key2 != NULL);
nobj->hashpriv = he2;
if (he != NULL)
TAILQ_INSERT_BEFORE(he, he2, list);
mtx = he->mtx;
AZ(pthread_mutex_lock(&hcl_mutex[mtx]));
if (--he->refcnt == 0) {
- free(he->key);
+ free(he->key1);
+ free(he->key2);
TAILQ_REMOVE(&hcl_head[he->hash], he, list);
free(he);
ret = 0;
struct hsl_entry {
TAILQ_ENTRY(hsl_entry) list;
- char *key;
+ char *key1;
+ char *key2;
struct objhead *obj;
unsigned refcnt;
};
*/
static struct objhead *
-hsl_lookup(const char *key, struct objhead *nobj)
+hsl_lookup(const char *key1, const char *key2, struct objhead *nobj)
{
struct hsl_entry *he, *he2;
int i;
AZ(pthread_mutex_lock(&hsl_mutex));
TAILQ_FOREACH(he, &hsl_head, list) {
- i = strcmp(key, he->key);
+ i = strcmp(key1, he->key1);
if (i < 0)
continue;
- if (i == 0) {
- he->refcnt++;
- nobj = he->obj;
- nobj->hashpriv = he;
- AZ(pthread_mutex_unlock(&hsl_mutex));
- return (nobj);
- }
- if (nobj == NULL) {
- AZ(pthread_mutex_unlock(&hsl_mutex));
- return (NULL);
- }
- break;
+ if (i > 0)
+ break;
+ i = strcmp(key2, he->key2);
+ if (i < 0)
+ continue;
+ if (i > 0)
+ break;
+ he->refcnt++;
+ nobj = he->obj;
+ nobj->hashpriv = he;
+ AZ(pthread_mutex_unlock(&hsl_mutex));
+ return (nobj);
+ }
+ if (nobj == NULL) {
+ AZ(pthread_mutex_unlock(&hsl_mutex));
+ return (NULL);
}
he2 = calloc(sizeof *he2, 1);
assert(he2 != NULL);
he2->obj = nobj;
he2->refcnt = 1;
- he2->key = strdup(key);
- assert(he2->key != NULL);
+ he2->key1 = strdup(key1);
+ assert(he2->key1 != NULL);
+ he2->key2 = strdup(key2);
+ assert(he2->key2 != NULL);
nobj->hashpriv = he2;
if (he != NULL)
TAILQ_INSERT_BEFORE(he, he2, list);
he = obj->hashpriv;
AZ(pthread_mutex_lock(&hsl_mutex));
if (--he->refcnt == 0) {
- free(he->key);
+ free(he->key1);
+ free(he->key2);
TAILQ_REMOVE(&hsl_head, he, list);
free(he);
ret = 0;
typedef int hash_init_f(const char *);
typedef void hash_start_f(void);
-typedef struct objhead *hash_lookup_f(const char *key, struct objhead *nobj);
+typedef struct objhead *hash_lookup_f(const char *key1, const char *key2, struct objhead *nobj);
typedef int hash_deref_f(struct objhead *obj);
struct hash_slinger {