void SES_GetReq(struct sess *sp) { struct sesspool *pp; uint16_t nhttp; unsigned sz, hl; char *p, *e; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); AN(pp->pool); AZ(sp->req); sp->req = MPL_Get(pp->mpl_req, &sz); AN(sp->req); sp->req->magic = REQ_MAGIC; e = (char*)sp->req + sz; p = (char*)(sp->req + 1); p = (void*)PRNDUP(p); assert(p < e); nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); sp->req->http = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); sp->req->http0 = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); sp->req->resp = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); sz = cache_param->workspace_thread; VSL_Setup(sp->req->vsl, p, sz); sp->req->vsl->wid = sp->vsl_id; p += sz; p = (void*)PRNDUP(p); assert(p < e); WS_Init(sp->req->ws, "req", p, e - p); }
static struct sessmem * ses_sm_alloc(void) { struct sessmem *sm; unsigned char *p, *q; unsigned nws; uint16_t nhttp; unsigned l, hl; /* * It is not necessary to lock these, but we need to * cache them locally, to make sure we get a consistent * view of the value. */ nws = cache_param->sess_workspace; nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); l = sizeof *sm + nws + 2 * hl; VSC_C_main->sessmem_size = l; p = malloc(l); if (p == NULL) return (NULL); q = p + l; /* Don't waste time zeroing the workspace */ memset(p, 0, l - nws); sm = (void*)p; p += sizeof *sm; sm->magic = SESSMEM_MAGIC; sm->workspace = nws; sm->nhttp = nhttp; sm->http[0] = HTTP_create(p, nhttp); p += hl; sm->http[1] = HTTP_create(p, nhttp); p += hl; sm->wsp = p; p += nws; assert(p == q); return (sm); }
void * WRK_thread(void *priv) { uint16_t nhttp; unsigned siov; assert(cache_param->http_max_hdr <= 65535); /* We need to snapshot these two for consistency */ nhttp = (uint16_t)cache_param->http_max_hdr; siov = nhttp * 2; if (siov > IOV_MAX) siov = IOV_MAX; return (wrk_thread_real(priv, cache_param->shm_workspace, cache_param->wthread_workspace, nhttp, HTTP_estimate(nhttp), siov)); }
struct busyobj * VBO_GetBusyObj(struct worker *wrk, const struct req *req) { struct busyobj *bo = NULL; uint16_t nhttp; unsigned sz; char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); if (wrk->nbo != NULL) { bo = wrk->nbo; wrk->nbo = NULL; } if (bo == NULL) bo = vbo_New(); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(bo->refcount); bo->refcount = 1; p = (void*)(bo + 1); p = (void*)PRNDUP(p); assert(p < bo->end); nhttp = (uint16_t)cache_param->http_max_hdr; sz = HTTP_estimate(nhttp); bo->bereq0 = HTTP_create(p, nhttp); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); bo->bereq = HTTP_create(p, nhttp); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); bo->beresp = HTTP_create(p, nhttp); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); sz = cache_param->vsl_buffer; VSL_Setup(bo->vsl, p, sz); bo->vsl->wid = VXID_Get(wrk, VSL_BACKENDMARKER); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); WS_Init(bo->ws, "bo", p, bo->end - p); bo->do_stream = 1; bo->director = req->director_hint; bo->vcl = req->vcl; VCL_Ref(bo->vcl); bo->t_first = bo->t_prev = NAN; bo->content_length = -1; bo->doclose = SC_NULL; return (bo); }
struct busyobj * VBO_GetBusyObj(struct worker *wrk, struct req *req) { struct busyobj *bo = NULL; uint16_t nhttp; unsigned sz; char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); if (wrk->nbo != NULL) { bo = wrk->nbo; wrk->nbo = NULL; } if (bo == NULL) bo = vbo_New(); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(bo->refcount); bo->refcount = 1; p = (void*)(bo + 1); p = (void*)PRNDUP(p); assert(p < bo->end); nhttp = (uint16_t)cache_param->http_max_hdr; sz = HTTP_estimate(nhttp); bo->bereq0 = HTTP_create(p, nhttp); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); bo->bereq = HTTP_create(p, nhttp); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); bo->beresp = HTTP_create(p, nhttp); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); sz = cache_param->vsl_buffer; VSL_Setup(bo->vsl, p, sz); bo->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_BACKENDMARKER; VSLb(bo->vsl, SLT_Begin, "bereq %u", req->vsl->wid & VSL_IDENTMASK); VSLb(req->vsl, SLT_Link, "bereq %u", bo->vsl->wid & VSL_IDENTMASK); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); WS_Init(bo->ws, "bo", p, bo->end - p); bo->do_stream = 1; bo->director = req->director; bo->vcl = req->vcl; VCL_Ref(bo->vcl); bo->t_fetch = req->t_req; return (bo); }
struct req * SES_GetReq(const struct worker *wrk, struct sess *sp) { struct sesspool *pp; struct req *req; uint16_t nhttp; unsigned sz, hl; char *p, *e; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); AN(pp->pool); req = MPL_Get(pp->mpl_req, &sz); AN(req); req->magic = REQ_MAGIC; req->sp = sp; e = (char*)req + sz; p = (char*)(req + 1); p = (void*)PRNDUP(p); assert(p < e); nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); req->http = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); req->http0 = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); req->resp = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); sz = cache_param->vsl_buffer; VSL_Setup(req->vsl, p, sz); p += sz; p = (void*)PRNDUP(p); assert(p < e); WS_Init(req->ws, "req", p, e - p); req->req_bodybytes = 0; req->resp_hdrbytes = 0; req->resp_bodybytes = 0; req->t_first = NAN; req->t_prev = NAN; req->t_req = NAN; return (req); }
struct req * Req_New(const struct worker *wrk, struct sess *sp) { struct pool *pp; struct req *req; uint16_t nhttp; unsigned sz, hl; char *p, *e; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->pool; CHECK_OBJ_NOTNULL(pp, POOL_MAGIC); req = MPL_Get(pp->mpl_req, &sz); AN(req); req->magic = REQ_MAGIC; req->sp = sp; e = (char*)req + sz; p = (char*)(req + 1); p = (void*)PRNDUP(p); assert(p < e); nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); req->http = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); req->http0 = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); req->resp = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); sz = cache_param->vsl_buffer; VSL_Setup(req->vsl, p, sz); p += sz; p = (void*)PRNDUP(p); req->vfc = (void*)p; INIT_OBJ(req->vfc, VFP_CTX_MAGIC); p = (void*)PRNDUP(p + sizeof(*req->vfc)); req->htc = (void*)p; p = (void*)PRNDUP(p + sizeof(*req->htc)); req->vdc = (void*)p; INIT_OBJ(req->vdc, VDP_CTX_MAGIC); VTAILQ_INIT(&req->vdc->vdp); p = (void*)PRNDUP(p + sizeof(*req->vdc)); req->htc = (void*)p; INIT_OBJ(req->htc, HTTP_CONN_MAGIC); p = (void*)PRNDUP(p + sizeof(*req->htc)); assert(p < e); WS_Init(req->ws, "req", p, e - p); req->t_first = NAN; req->t_prev = NAN; req->t_req = NAN; req->topreq = req; return (req); }
struct req * SES_GetReq(struct worker *wrk, struct sess *sp) { struct sesspool *pp; struct req *req; uint16_t nhttp; unsigned sz, hl; char *p, *e; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC); AN(pp->pool); req = MPL_Get(pp->mpl_req, &sz); AN(req); req->magic = REQ_MAGIC; req->sp = sp; e = (char*)req + sz; p = (char*)(req + 1); p = (void*)PRNDUP(p); assert(p < e); nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); req->http = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); req->http0 = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); req->resp = HTTP_create(p, nhttp); p += hl; p = (void*)PRNDUP(p); assert(p < e); sz = cache_param->vsl_buffer; VSL_Setup(req->vsl, p, sz); req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; VSLb(req->vsl, SLT_Begin, "req %u", sp->vxid & VSL_IDENTMASK); VSL(SLT_Link, req->sp->vxid, "req %u", req->vsl->wid & VSL_IDENTMASK); p += sz; p = (void*)PRNDUP(p); assert(p < e); WS_Init(req->ws, "req", p, e - p); req->t_req = NAN; req->t_resp = NAN; VTAILQ_INIT(&req->body); return (req); }