Commit fbe7e755 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

ws: Almost ban direct access to the workspace front

Proving that this always needed for use cases dealing with workspace
reservations.

Well, almost always, for now vmod_vtc and the panic subsystem are left
alone.
parent 8a2cde41
......@@ -674,7 +674,7 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
more = 0;
spc = ospc;
nobj = 0;
ocp = (void*)wrk->aws->f;
ocp = WS_Reservation(wrk->aws);
Lck_Lock(&oh->mtx);
assert(oh->refcnt > 0);
VTAILQ_FOREACH(oc, &oh->objcs, hsh_list) {
......
......@@ -403,7 +403,7 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
if (b == NULL) {
/* Found second header, start our collection */
ml = WS_ReserveAll(hp->ws);
b = hp->ws->f;
b = WS_Reservation(hp->ws);
e = b + ml;
x = Tlen(hp->hd[f]);
if (b + x >= e) {
......@@ -444,7 +444,7 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
hp->nhd = (uint16_t)d;
AN(e);
*b = '\0';
hp->hd[f].b = hp->ws->f;
hp->hd[f].b = WS_Reservation(hp->ws);
hp->hd[f].e = b;
WS_ReleaseP(hp->ws, b + 1);
}
......
......@@ -124,7 +124,7 @@ ses_res_attr(struct sess *sp, enum sess_attr a, void **dst, int sz)
o = WS_ReserveSize(sp->ws, sz);
if (o < sz)
return (0);
*dst = sp->ws->f;
*dst = WS_Reservation(sp->ws);
o = sp->ws->f - sp->ws->s;
WS_Release(sp->ws, sz);
assert(o >= 0 && o <= 0xffff);
......@@ -210,19 +210,19 @@ HTC_Status(enum htc_status_e e)
void
HTC_RxInit(struct http_conn *htc, struct ws *ws)
{
unsigned r;
ssize_t l;
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
htc->ws = ws;
(void)WS_ReserveAll(htc->ws);
htc->rxbuf_b = ws->f;
htc->rxbuf_e = ws->f;
r = WS_ReserveAll(htc->ws);
htc->rxbuf_b = htc->rxbuf_e = WS_Reservation(ws);
if (htc->pipeline_b != NULL) {
AN(htc->pipeline_e);
// assert(WS_Inside(ws, htc->pipeline_b, htc->pipeline_e));
l = htc->pipeline_e - htc->pipeline_b;
assert(l > 0);
assert(l <= ws->r - htc->rxbuf_b);
assert(l <= r);
memmove(htc->rxbuf_b, htc->pipeline_b, l);
htc->rxbuf_e += l;
htc->pipeline_b = NULL;
......@@ -415,7 +415,7 @@ ses_handle(struct waited *wp, enum wait_event ev, vtim_real now)
CAST_OBJ_NOTNULL(sp, wp->priv1, SESS_MAGIC);
CAST_OBJ_NOTNULL(xp, (const void*)wp->priv2, TRANSPORT_MAGIC);
AN(wp->priv2);
assert((void *)sp->ws->f == wp);
assert(WS_Reservation(sp->ws) == wp);
wp->magic = 0;
wp = NULL;
......@@ -434,7 +434,7 @@ ses_handle(struct waited *wp, enum wait_event ev, vtim_real now)
CHECK_OBJ_NOTNULL(pp, POOL_MAGIC);
/* SES_Wait() guarantees the next will not assert. */
assert(sizeof *tp <= WS_ReserveSize(sp->ws, sizeof *tp));
tp = (void*)sp->ws->f;
tp = WS_Reservation(sp->ws);
tp->func = xp->unwait;
tp->priv = sp;
if (Pool_Task(pp, tp, TASK_QUEUE_REQ))
......
......@@ -234,10 +234,10 @@ VRY_Prep(struct req *req)
AZ(req->vary_e);
(void)WS_ReserveAll(req->ws);
} else {
AN(req->ws->r);
AN(WS_Reservation(req->ws));
}
req->vary_b = (void*)req->ws->f;
req->vary_e = (void*)req->ws->r;
req->vary_b = WS_Reservation(req->ws);
req->vary_e = req->vary_b + WS_ReservationSize(req->ws);
if (req->vary_b + 2 < req->vary_e)
req->vary_b[2] = '\0';
}
......
......@@ -366,7 +366,7 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
va_list aq;
u = WS_ReserveAll(ws);
e = b = ws->f;
e = b = WS_Reservation(ws);
e += u;
va_copy(aq, ap);
......@@ -422,7 +422,7 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
return (NULL);
}
e = b;
b = ws->f;
b = WS_Reservation(ws);
WS_Release(ws, e - b);
return (b);
}
......@@ -710,7 +710,7 @@ VRT_IP_string(VRT_CTX, VCL_IP ip)
WS_Release(ctx->ws, 0);
return (NULL);
}
p = ctx->ws->f;
p = WS_Reservation(ctx->ws);
VTCP_name(ip, p, len, NULL, 0);
WS_Release(ctx->ws, strlen(p) + 1);
return (p);
......
......@@ -130,7 +130,7 @@ VRT_regsub(VRT_CTX, int all, const char *str, void *re,
}
u = WS_ReserveAll(ctx->ws);
res_e = res_b = b0 = ctx->ws->f;
res_e = res_b = b0 = WS_Reservation(ctx->ws);
res_e += u;
do {
......
......@@ -246,9 +246,9 @@ Pool_Task_Arg(struct worker *wrk, enum task_prio prio, task_func_t *func,
}
AZ(wrk2->task->func);
assert(arg_len <= WS_ReserveSize(wrk2->aws, arg_len));
memcpy(wrk2->aws->f, arg, arg_len);
memcpy(WS_Reservation(wrk2->aws), arg, arg_len);
wrk2->task->func = func;
wrk2->task->priv = wrk2->aws->f;
wrk2->task->priv = WS_Reservation(wrk2->aws);
Lck_Unlock(&pp->mtx);
// see signaling_note at the top for explanation
if (retval)
......
......@@ -112,7 +112,7 @@ V1L_Open(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
u = IOV_MAX;
if (niov != 0 && u > niov)
u = niov;
v1l->iov = (void*)ws->f;
v1l->iov = WS_Reservation(ws);
v1l->siov = u;
v1l->ciov = u;
v1l->wfd = fd;
......
......@@ -183,7 +183,7 @@ h2h_decode_init(const struct h2_sess *h2)
* space. Require non-zero size.
*/
XXXAN(d->out_l);
d->out = h2->new_req->http->ws->f;
d->out = WS_Reservation(h2->new_req->http->ws);
d->reset = d->out;
}
......
......@@ -76,7 +76,7 @@ vmod_updown(VRT_CTX, int up, VCL_STRANDS s)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
u = WS_ReserveAll(ctx->ws);
e = b = ctx->ws->f;
e = b = WS_Reservation(ctx->ws);
e += u;
for (i = 0; i < s->n && b < e; i++) {
p = s->p[i];
......@@ -96,7 +96,7 @@ vmod_updown(VRT_CTX, int up, VCL_STRANDS s)
return (NULL);
} else {
e = b;
b = ctx->ws->f;
b = WS_Reservation(ctx->ws);
WS_Release(ctx->ws, e - b);
return (b);
}
......
......@@ -81,7 +81,7 @@ vmod_querysort(VRT_CTX, VCL_STRING url)
return (url);
u = WS_ReserveLumps(ctx->ws, sizeof(const char **));
pp = (const char**)(void*)(ctx->ws->f);
pp = WS_Reservation(ctx->ws);
if (u < 4) {
WS_Release(ctx->ws, 0);
WS_MarkOverflow(ctx->ws);
......
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