Commit 23c608f7 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Update st->len inside the bo->mtx in VBO_extend() so that it

is always synchronized with obj->len.
parent 27c7ff03
......@@ -212,6 +212,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
void
VBO_extend(struct busyobj *bo, ssize_t l)
{
struct storage *st;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC);
......@@ -219,6 +220,8 @@ VBO_extend(struct busyobj *bo, ssize_t l)
return;
assert(l > 0);
Lck_Lock(&bo->mtx);
st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead);
st->len += l;
bo->fetch_obj->len += l;
AZ(pthread_cond_signal(&bo->cond));
Lck_Unlock(&bo->mtx);
......
......@@ -101,7 +101,6 @@ vfp_esi_bytes_uu(struct busyobj *bo, const struct vef_priv *vef,
if (wl <= 0)
return (wl);
VEP_Parse(bo, (const char *)st->ptr + st->len, wl);
st->len += wl;
VBO_extend(bo, wl);
bytes -= wl;
}
......
......@@ -541,7 +541,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
if (tl > st->space - st->len)
tl = st->space - st->len;
memcpy(st->ptr + st->len, sp, tl);
st->len += tl;
al += tl;
sp = (char *)sp + tl;
sl -= tl;
......
......@@ -129,7 +129,6 @@ vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
wl = HTTP1_Read(htc, st->ptr + st->len, l);
if (wl <= 0)
return (wl);
st->len += wl;
VBO_extend(bo, wl);
bytes -= wl;
}
......
......@@ -55,8 +55,6 @@ struct vgz {
char *tmp_snapshot;
int last_i;
struct storage *st_obuf;
/* Wrw stuff */
char *m_buf;
ssize_t m_sz;
......@@ -210,7 +208,6 @@ VGZ_ObufStorage(struct busyobj *bo, struct vgz *vg)
if (st == NULL)
return (-1);
vg->st_obuf = st;
VGZ_Obuf(vg, st->ptr + st->len, st->space - st->len);
return (0);
......@@ -237,8 +234,6 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen)
*pptr = before;
l = (const uint8_t *)vg->vz.next_out - before;
*plen = l;
if (vg->st_obuf != NULL)
vg->st_obuf->len += l;
}
vg->last_i = i;
if (i == Z_OK)
......@@ -280,8 +275,6 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags)
*pptr = before;
l = (const uint8_t *)vg->vz.next_out - before;
*plen = l;
if (vg->st_obuf != NULL)
vg->st_obuf->len += l;
}
vg->last_i = i;
if (i == Z_OK)
......@@ -683,7 +676,6 @@ vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
return (wl);
bytes -= wl;
VGZ_Ibuf(vg, st->ptr + st->len, wl);
st->len += wl;
VBO_extend(bo, wl);
while (!VGZ_IbufEmpty(vg)) {
......
......@@ -63,7 +63,6 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l)
{
ssize_t ol;
ssize_t nl;
volatile unsigned u;
CHECK_OBJ_NOTNULL(oi, OBJITER_MAGIC);
CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC);
......@@ -98,15 +97,16 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l)
Lck_Lock(&oi->bo->mtx);
AZ(VTAILQ_EMPTY(&oi->obj->store));
VTAILQ_FOREACH(oi->st, &oi->obj->store, list) {
u = (volatile unsigned)(oi->st->len);
if (u > ol) {
if (oi->st->len > ol) {
*p = oi->st->ptr + ol;
*l = u - ol;
*l = oi->st->len - ol;
oi->len += *l;
break;
}
ol -= u;
nl -= u;
ol -= oi->st->len;
assert(ol >= 0);
nl -= oi->st->len;
assert(nl > 0);
}
CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC);
......
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