Commit a095df14 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Change VEC codes to make it possible to collapse length decoding

in ESI_Deliver()



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5756 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e4430b27
......@@ -27,10 +27,10 @@
*
*/
#define VEC_V1 'B'
#define VEC_V2 'W'
#define VEC_V8 'L'
#define VEC_S1 'b'
#define VEC_S2 'w'
#define VEC_S8 'l'
#define VEC_V1 (0x40 + 1)
#define VEC_V2 (0x40 + 2)
#define VEC_V8 (0x40 + 8)
#define VEC_S1 (0x60 + 1)
#define VEC_S2 (0x60 + 2)
#define VEC_S8 (0x60 + 8)
#define VEC_INCL 'I'
......@@ -138,13 +138,42 @@ esi_sendchunk(const struct sess *sp, const void *cb, ssize_t cl,
(void)WRW_Write(sp->wrk, "\r\n", -1);
}
static ssize_t
ved_decode_len(uint8_t **pp)
{
uint8_t *p;
ssize_t l;
p = *pp;
switch (*p & 15) {
case 1:
l = p[1];
p += 2;
break;
case 2:
l = vbe16dec(p + 1);
p += 3;
break;
case 8:
l = vbe64dec(p + 1);
p += 9;
break;
default:
printf("%d\n",(*p & 15));
INCOMPL();
}
*pp = p;
assert(l > 0);
return (l);
}
void
ESI_Deliver(struct sess *sp)
{
struct storage *st;
uint8_t *p, *e, *q, *r;
unsigned off;
size_t l;
ssize_t l;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
st = sp->obj->esidata;
......@@ -156,30 +185,11 @@ ESI_Deliver(struct sess *sp)
off = 0;
while (p < e) {
//usleep(10000);
//WRW_Flush(sp->wrk);
switch (*p) {
case VEC_V1:
l = p[1];
p += 2;
q = (void*)strchr((const char*)p, '\0');
assert (q > p);
esi_sendchunk(sp, p, q - p, st->ptr + off, l);
off += l;
p = q + 1;
break;
case VEC_V2:
l = vbe16dec(p + 1);
p += 3;
q = (void*)strchr((const char*)p, '\0');
assert (q > p);
esi_sendchunk(sp, p, q - p, st->ptr + off, l);
off += l;
p = q + 1;
break;
case VEC_V8:
l = vbe64dec(p + 1);
p += 9;
l = ved_decode_len(&p);
q = (void*)strchr((const char*)p, '\0');
assert (q > p);
esi_sendchunk(sp, p, q - p, st->ptr + off, l);
......@@ -187,21 +197,10 @@ ESI_Deliver(struct sess *sp)
p = q + 1;
break;
case VEC_S1:
l = p[1];
p += 2;
Debug("SKIP1(%d)\n", (int)l);
off += l;
break;
case VEC_S2:
l = vbe16dec(p + 1);
p += 3;
Debug("SKIP2(%d)\n", (int)l);
off += l;
break;
case VEC_S8:
l = vbe64dec(p + 1);
p += 9;
Debug("SKIP8(%d)\n", (int)l);
l = ved_decode_len(&p);
Debug("SKIP1(%d)\n", (int)l);
off += l;
break;
case VEC_INCL:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment