Rename task head struct to what it is

parent 656cd656
@@ @@
struct pesi_tree *ptr; struct pesi_tasks *ptr;
@@ @@
- ptr->tree - ptr->tree
...@@ -9,11 +9,11 @@ struct pesi_tree *ptr; ...@@ -9,11 +9,11 @@ struct pesi_tree *ptr;
struct pesi *pesi; struct pesi *pesi;
@@ @@
- pesi->pesi_tree->tree - pesi->pesi_tasks->tree
+ pesi->pesi_tree->bytes_tree + pesi->pesi_tasks->bytes_tree
@@ @@
struct pesi_tree val; struct pesi_tasks val;
@@ @@
- val.tree - val.tree
......
...@@ -16,7 +16,7 @@ libvmod_pesi_la_SOURCES = \ ...@@ -16,7 +16,7 @@ libvmod_pesi_la_SOURCES = \
misc.c \ misc.c \
pesi.h \ pesi.h \
pesi_flags.h \ pesi_flags.h \
pesi_tree.h \ pesi_tasks.h \
pesi.c \ pesi.c \
node.h \ node.h \
node_assert.h \ node_assert.h \
...@@ -55,13 +55,13 @@ vmod_pesi.lo: vcc_pesi_if.h VSC_pesi.c VSC_pesi.h misc.h node_mempool.h \ ...@@ -55,13 +55,13 @@ vmod_pesi.lo: vcc_pesi_if.h VSC_pesi.c VSC_pesi.h misc.h node_mempool.h \
pesi_flags.h vdp_pesi.h tbl_set_parameter.h pesi_flags.h vdp_pesi.h tbl_set_parameter.h
vdp_pesi.lo: debug.h vdp_pesi.h node.h node_assert.h pesi.h pesi_flags.h \ vdp_pesi.lo: debug.h vdp_pesi.h node.h node_assert.h pesi.h pesi_flags.h \
pesi_tree.h misc.h pesi_tasks.h misc.h
misc.lo: misc.h debug.h misc.lo: misc.h debug.h
node.lo: debug.h node.h node_assert.h node_mempool.h pesi.h misc.h vcc_pesi_if.h node.lo: debug.h node.h node_assert.h node_mempool.h pesi.h misc.h vcc_pesi_if.h
pesi.lo: debug.h VSC_pesi.h pesi_tree.h pesi_flags.h pesi.h pesi.lo: debug.h VSC_pesi.h pesi_tasks.h pesi_flags.h pesi.h
vcc_pesi_if.h vmod_pesi.rst vmod_pesi.man.rst: vcc_pesi_if.c vcc_pesi_if.h vmod_pesi.rst vmod_pesi.man.rst: vcc_pesi_if.c
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include "VSC_pesi.h" #include "VSC_pesi.h"
#include "pesi_tree.h" #include "pesi_tasks.h"
#include "pesi_flags.h" #include "pesi_flags.h"
#include "node_head.h" #include "node_head.h"
#include "pesi.h" #include "pesi.h"
...@@ -67,7 +67,7 @@ struct VSC_pesi *stats = NULL; ...@@ -67,7 +67,7 @@ struct VSC_pesi *stats = NULL;
* - otherwise, pesi gets destroyed before the task * - otherwise, pesi gets destroyed before the task
*/ */
struct pesi * struct pesi *
pesi_new(struct ws *ws, struct pesi_tree *pesi_tree) pesi_new(struct ws *ws, struct pesi_tasks *pesi_tasks)
{ {
struct pesi *pesi; struct pesi *pesi;
...@@ -77,16 +77,16 @@ pesi_new(struct ws *ws, struct pesi_tree *pesi_tree) ...@@ -77,16 +77,16 @@ pesi_new(struct ws *ws, struct pesi_tree *pesi_tree)
INIT_OBJ(pesi, PESI_MAGIC); INIT_OBJ(pesi, PESI_MAGIC);
pesi->pecx->magic = PECX_MAGIC; pesi->pecx->magic = PECX_MAGIC;
pesi->pesi_tree = pesi_tree; pesi->pesi_tasks = pesi_tasks;
pesi->flags = PF_HAS_TASK | PF_CFG_DEFAULT; pesi->flags = PF_HAS_TASK | PF_CFG_DEFAULT;
node_init_nodestock(&pesi->nodestock); node_init_nodestock(&pesi->nodestock);
Lck_Lock(&pesi_tree->task_lock); Lck_Lock(&pesi_tasks->task_lock);
VTAILQ_INSERT_TAIL(&pesi_tree->task_head, pesi, list); VTAILQ_INSERT_TAIL(&pesi_tasks->task_head, pesi, list);
assert(pesi_tree->task_running >= 0); assert(pesi_tasks->task_running >= 0);
pesi_tree->task_running++; pesi_tasks->task_running++;
Lck_Unlock(&pesi_tree->task_lock); Lck_Unlock(&pesi_tasks->task_lock);
return (pesi); return (pesi);
} }
...@@ -94,7 +94,7 @@ pesi_new(struct ws *ws, struct pesi_tree *pesi_tree) ...@@ -94,7 +94,7 @@ pesi_new(struct ws *ws, struct pesi_tree *pesi_tree)
* shutting down a pesi request is a two stage process, because Req_Cleanup() in * shutting down a pesi request is a two stage process, because Req_Cleanup() in
* req_fini() called from vped_task() zeroes the workspace including our * req_fini() called from vped_task() zeroes the workspace including our
* per-request struct pesi, so removing the registration from * per-request struct pesi, so removing the registration from
* pesi_tree->task_head need to happen before Req_Cleanup(). * pesi_tasks->task_head need to happen before Req_Cleanup().
* *
* But notification of the topreq needs to happen after Req_Cleanup(), because * But notification of the topreq needs to happen after Req_Cleanup(), because
* it still references topreq and sp, thus the topreq may not finish until all * it still references topreq and sp, thus the topreq may not finish until all
...@@ -118,11 +118,11 @@ void ...@@ -118,11 +118,11 @@ void
pesi_destroy(struct pesi **pesip) pesi_destroy(struct pesi **pesip)
{ {
struct pesi *pesi; struct pesi *pesi;
struct pesi_tree *pesi_tree; struct pesi_tasks *pesi_tasks;
TAKE_OBJ_NOTNULL(pesi, pesip, PESI_MAGIC); TAKE_OBJ_NOTNULL(pesi, pesip, PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pecx, PECX_MAGIC); CHECK_OBJ_NOTNULL(pesi->pecx, PECX_MAGIC);
TAKE_OBJ_NOTNULL(pesi_tree, &pesi->pesi_tree, PESI_TREE_MAGIC); TAKE_OBJ_NOTNULL(pesi_tasks, &pesi->pesi_tasks, PESI_TREE_MAGIC);
if (pesi->no_thread != 0) { if (pesi->no_thread != 0) {
Lck_Lock(&stats_lock); Lck_Lock(&stats_lock);
...@@ -131,36 +131,36 @@ pesi_destroy(struct pesi **pesip) ...@@ -131,36 +131,36 @@ pesi_destroy(struct pesi **pesip)
Lck_Unlock(&stats_lock); Lck_Unlock(&stats_lock);
} }
Lck_Lock(&pesi_tree->task_lock); Lck_Lock(&pesi_tasks->task_lock);
VTAILQ_REMOVE(&pesi_tree->task_head, pesi, list); VTAILQ_REMOVE(&pesi_tasks->task_head, pesi, list);
assert(pesi_tree->task_running >= 0); assert(pesi_tasks->task_running >= 0);
if (pesi->flags & PF_HAS_TASK) if (pesi->flags & PF_HAS_TASK)
pesi_tree->task_finishing++; pesi_tasks->task_finishing++;
Lck_Unlock(&pesi_tree->task_lock); Lck_Unlock(&pesi_tasks->task_lock);
memset(pesi, 0, sizeof *pesi); memset(pesi, 0, sizeof *pesi);
} }
void void
task_fini(struct pesi_tree *pesi_tree, struct pesi *pesi) task_fini(struct pesi_tasks *pesi_tasks, struct pesi *pesi)
{ {
Lck_Lock(&pesi_tree->task_lock); Lck_Lock(&pesi_tasks->task_lock);
assert(pesi_tree->task_running > 0); assert(pesi_tasks->task_running > 0);
if (pesi == NULL) { if (pesi == NULL) {
assert(pesi_tree->task_finishing > 0); assert(pesi_tasks->task_finishing > 0);
pesi_tree->task_finishing--; pesi_tasks->task_finishing--;
} }
else { else {
AN(pesi->flags & PF_HAS_TASK); AN(pesi->flags & PF_HAS_TASK);
pesi->flags &= ~PF_HAS_TASK; pesi->flags &= ~PF_HAS_TASK;
} }
pesi_tree->task_running--; pesi_tasks->task_running--;
if (pesi_tree->task_running == 0) { if (pesi_tasks->task_running == 0) {
AZ(pesi_tree->task_finishing); AZ(pesi_tasks->task_finishing);
AZ(pthread_cond_signal(&pesi_tree->task_cond)); AZ(pthread_cond_signal(&pesi_tasks->task_cond));
} }
Lck_Unlock(&pesi_tree->task_lock); Lck_Unlock(&pesi_tasks->task_lock);
} }
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
* PESI per request state * PESI per request state
*/ */
struct pesi_tree; struct pesi_tasks;
struct pesi * pesi_new(struct ws *ws, struct pesi_tree *pesi_tree); struct pesi * pesi_new(struct ws *ws, struct pesi_tasks *pesi_tasks);
void pesi_destroy(struct pesi **pesip); void pesi_destroy(struct pesi **pesip);
void task_fini(struct pesi_tree *pesi_tree, struct pesi *pesi); void task_fini(struct pesi_tasks *pesi_tasks, struct pesi *pesi);
/* /*
* per request state * per request state
...@@ -58,7 +58,7 @@ struct pesi { ...@@ -58,7 +58,7 @@ struct pesi {
#define PESI_MAGIC 0xa6ba54a0 #define PESI_MAGIC 0xa6ba54a0
unsigned flags; unsigned flags;
struct pesi_tree *pesi_tree; struct pesi_tasks *pesi_tasks;
struct worker *wrk; struct worker *wrk;
struct node *node; struct node *node;
int woken; int woken;
......
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* pesi_tree is a global context for the entire ESI tree started at level 0. * pesi_tasks is a global context for the entire ESI tree started at level 0.
* *
* XXX merge pesi_tree with bytes_tree ? * XXX merge pesi_tasks with bytes_tree ?
*/ */
struct pesi_tree { struct pesi_tasks {
unsigned magic; unsigned magic;
#define PESI_TREE_MAGIC 0xe8ce8adb #define PESI_TREE_MAGIC 0xe8ce8adb
struct bytes_tree *bytes_tree; struct bytes_tree *bytes_tree;
......
...@@ -8,12 +8,12 @@ varnishtest "subreq.done race #2" ...@@ -8,12 +8,12 @@ varnishtest "subreq.done race #2"
# +++ b/src/vdp_pesi.c # +++ b/src/vdp_pesi.c
# @@ -232,6 +232,7 @@ vped_task(struct worker *wrk, void *priv) # @@ -232,6 +232,7 @@ vped_task(struct worker *wrk, void *priv)
# assert(pesi == req->transport_priv); # assert(pesi == req->transport_priv);
# Lck_Lock(&pesi_tree->tree->tree_lock); # Lck_Lock(&pesi_tasks->tree->tree_lock);
# task_fini(pesi_tree, pesi); # task_fini(pesi_tasks, pesi);
# + sleep(1); # + sleep(1);
# node->subreq.done = 1; # node->subreq.done = 1;
# AZ(pthread_cond_signal(&node->subreq.cond)); # AZ(pthread_cond_signal(&node->subreq.cond));
# Lck_Unlock(&pesi_tree->tree->tree_lock); # Lck_Unlock(&pesi_tasks->tree->tree_lock);
server s1 { server s1 {
rxreq rxreq
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include "node_assert.h" #include "node_assert.h"
#include "pesi.h" #include "pesi.h"
#include "pesi_flags.h" #include "pesi_flags.h"
#include "pesi_tree.h" #include "pesi_tasks.h"
#include "misc.h" #include "misc.h"
...@@ -92,7 +92,7 @@ static void vped_close_vdp(struct req *, int, const struct vdp *); ...@@ -92,7 +92,7 @@ static void vped_close_vdp(struct req *, int, const struct vdp *);
static void assert_vdp_next_not(struct req *, const struct vdp *); static void assert_vdp_next_not(struct req *, const struct vdp *);
/* shared with vmod code */ /* shared with vmod code */
struct VSC_lck *lck_bytes_tree, *lck_pesi_tree; struct VSC_lck *lck_bytes_tree, *lck_pesi_tasks;
extern struct mempool *mempool; extern struct mempool *mempool;
struct mempool *mempool = NULL; struct mempool *mempool = NULL;
...@@ -140,7 +140,7 @@ vped_task(struct worker *wrk, void *priv) ...@@ -140,7 +140,7 @@ vped_task(struct worker *wrk, void *priv)
struct req *req; struct req *req;
struct sess *sp; struct sess *sp;
struct pesi *pesi; struct pesi *pesi;
struct pesi_tree *pesi_tree; struct pesi_tasks *pesi_tasks;
struct node *node; struct node *node;
enum req_fsm_nxt s; enum req_fsm_nxt s;
...@@ -165,12 +165,12 @@ vped_task(struct worker *wrk, void *priv) ...@@ -165,12 +165,12 @@ vped_task(struct worker *wrk, void *priv)
sp = req->sp; sp = req->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CAST_OBJ_NOTNULL(pesi, req->transport_priv, PESI_MAGIC); CAST_OBJ_NOTNULL(pesi, req->transport_priv, PESI_MAGIC);
pesi_tree = pesi->pesi_tree; pesi_tasks = pesi->pesi_tasks;
CHECK_OBJ_NOTNULL(pesi_tree, PESI_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi_tasks, PESI_TREE_MAGIC);
pesi->wrk = wrk; pesi->wrk = wrk;
node = pesi->node; node = pesi->node;
CHECK_OBJ_NOTNULL(node, NODE_MAGIC); CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
CHECK_OBJ_NOTNULL(pesi_tree->bytes_tree, BYTES_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi_tasks->bytes_tree, BYTES_TREE_MAGIC);
THR_SetRequest(req); THR_SetRequest(req);
VSLb_ts_req(req, "Start", W_TIM_real(wrk)); VSLb_ts_req(req, "Start", W_TIM_real(wrk));
...@@ -226,15 +226,15 @@ vped_task(struct worker *wrk, void *priv) ...@@ -226,15 +226,15 @@ vped_task(struct worker *wrk, void *priv)
pesi_destroy(&pesi); pesi_destroy(&pesi);
req_fini(&req, wrk); req_fini(&req, wrk);
AZ(pesi); AZ(pesi);
task_fini(pesi_tree, pesi); task_fini(pesi_tasks, pesi);
break; break;
case T_SUBREQ: case T_SUBREQ:
assert(pesi == req->transport_priv); assert(pesi == req->transport_priv);
Lck_Lock(&pesi_tree->bytes_tree->tree_lock); Lck_Lock(&pesi_tasks->bytes_tree->tree_lock);
task_fini(pesi_tree, pesi); task_fini(pesi_tasks, pesi);
node->subreq.done = 1; node->subreq.done = 1;
AZ(pthread_cond_signal(&node->subreq.cond)); AZ(pthread_cond_signal(&node->subreq.cond));
Lck_Unlock(&pesi_tree->bytes_tree->tree_lock); Lck_Unlock(&pesi_tasks->bytes_tree->tree_lock);
break; break;
case T_NEXUS: case T_NEXUS:
assert(node->nexus.req == req); assert(node->nexus.req == req);
...@@ -250,11 +250,11 @@ vped_task(struct worker *wrk, void *priv) ...@@ -250,11 +250,11 @@ vped_task(struct worker *wrk, void *priv)
AZ(req->transport_priv); AZ(req->transport_priv);
pesi = NULL; pesi = NULL;
Lck_Lock(&pesi_tree->bytes_tree->tree_lock); Lck_Lock(&pesi_tasks->bytes_tree->tree_lock);
set_closed(pesi_tree->bytes_tree, node, wrk); set_closed(pesi_tasks->bytes_tree, node, wrk);
Lck_Unlock(&pesi_tree->bytes_tree->tree_lock); Lck_Unlock(&pesi_tasks->bytes_tree->tree_lock);
AZ(pesi); AZ(pesi);
task_fini(pesi_tree, pesi); task_fini(pesi_tasks, pesi);
break; break;
} }
...@@ -286,14 +286,14 @@ vped_task(struct worker *wrk, void *priv) ...@@ -286,14 +286,14 @@ vped_task(struct worker *wrk, void *priv)
req_fini(&node->nexus.req, wrk); req_fini(&node->nexus.req, wrk);
/* turn into T_DATA node */ /* turn into T_DATA node */
node_mutate_prep(pesi_tree->bytes_tree, node); node_mutate_prep(pesi_tasks->bytes_tree, node);
memset(&node->data, 0, sizeof node->data); memset(&node->data, 0, sizeof node->data);
node_mutate_lock(pesi_tree->bytes_tree, node, node_mutate_lock(pesi_tasks->bytes_tree, node,
T_DATA, ST_DATA); T_DATA, ST_DATA);
node_mutate_unlock(pesi_tree->bytes_tree); node_mutate_unlock(pesi_tasks->bytes_tree);
task_fini(pesi_tree, pesi); task_fini(pesi_tasks, pesi);
break; break;
default: default:
INCOMPL(); INCOMPL();
...@@ -310,7 +310,7 @@ vped_include(struct req *preq, const char *src, const char *host, ...@@ -310,7 +310,7 @@ vped_include(struct req *preq, const char *src, const char *host,
{ {
struct worker *wrk; struct worker *wrk;
struct sess *sp; struct sess *sp;
struct pesi_tree *pesi_tree; struct pesi_tasks *pesi_tasks;
struct req *req; struct req *req;
struct bytes_tree *tree; struct bytes_tree *tree;
struct pesi *pesi2; struct pesi *pesi2;
...@@ -321,9 +321,9 @@ vped_include(struct req *preq, const char *src, const char *host, ...@@ -321,9 +321,9 @@ vped_include(struct req *preq, const char *src, const char *host,
sp = preq->sp; sp = preq->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(pesi, PESI_MAGIC); CHECK_OBJ_NOTNULL(pesi, PESI_MAGIC);
pesi_tree = pesi->pesi_tree; pesi_tasks = pesi->pesi_tasks;
CHECK_OBJ_NOTNULL(pesi_tree, PESI_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi_tasks, PESI_TREE_MAGIC);
tree = pesi_tree->bytes_tree; tree = pesi_tasks->bytes_tree;
CHECK_OBJ_NOTNULL(tree, BYTES_TREE_MAGIC); CHECK_OBJ_NOTNULL(tree, BYTES_TREE_MAGIC);
CHECK_OBJ_NOTNULL(node, NODE_MAGIC); CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
wrk = preq->wrk; wrk = preq->wrk;
...@@ -406,7 +406,7 @@ vped_include(struct req *preq, const char *src, const char *host, ...@@ -406,7 +406,7 @@ vped_include(struct req *preq, const char *src, const char *host,
req->transport = &VPED_transport; req->transport = &VPED_transport;
pesi2 = pesi_new(req->ws, pesi_tree); pesi2 = pesi_new(req->ws, pesi_tasks);
if (pesi2 == NULL) { if (pesi2 == NULL) {
VSLb(req->vsl, SLT_Error, VSLb(req->vsl, SLT_Error,
"Cannot allocate workspace for parallel ESI data"); "Cannot allocate workspace for parallel ESI data");
...@@ -524,8 +524,8 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -524,8 +524,8 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
unsigned refok; unsigned refok;
CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC); CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree, PESI_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi->pesi_tasks, PESI_TREE_MAGIC);
tree = pesi->pesi_tree->bytes_tree; tree = pesi->pesi_tasks->bytes_tree;
CHECK_OBJ_NOTNULL(tree, BYTES_TREE_MAGIC); CHECK_OBJ_NOTNULL(tree, BYTES_TREE_MAGIC);
if (tree->retval || ptr == NULL || len == 0) if (tree->retval || ptr == NULL || len == 0)
...@@ -731,7 +731,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) ...@@ -731,7 +731,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
struct req *req; struct req *req;
struct pesi *pesi; struct pesi *pesi;
struct pecx *pecx; struct pecx *pecx;
struct pesi_tree *pesi_tree; struct pesi_tasks *pesi_tasks;
struct node *root_node; struct node *root_node;
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
...@@ -765,27 +765,27 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) ...@@ -765,27 +765,27 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
AZ(req->esi_level); AZ(req->esi_level);
if ((pesi_tree = WS_Alloc(req->ws, sizeof(*pesi_tree))) == NULL) { if ((pesi_tasks = WS_Alloc(req->ws, sizeof(*pesi_tasks))) == NULL) {
VSLb(req->vsl, SLT_Error, "insufficient workspace for " VSLb(req->vsl, SLT_Error, "insufficient workspace for "
"global parallel ESI data"); "global parallel ESI data");
return (-1); return (-1);
} }
INIT_OBJ(pesi_tree, PESI_TREE_MAGIC); INIT_OBJ(pesi_tasks, PESI_TREE_MAGIC);
if ((pesi_tree->bytes_tree = WS_Alloc(req->ws, sizeof(*pesi_tree->bytes_tree))) if ((pesi_tasks->bytes_tree = WS_Alloc(req->ws, sizeof(*pesi_tasks->bytes_tree)))
== NULL) { == NULL) {
VSLb(req->vsl, SLT_Error, "insufficient workspace for " VSLb(req->vsl, SLT_Error, "insufficient workspace for "
"parallel ESI tree data"); "parallel ESI tree data");
return (-1); return (-1);
} }
Lck_New(&pesi_tree->task_lock, lck_pesi_tree); Lck_New(&pesi_tasks->task_lock, lck_pesi_tasks);
AZ(pthread_cond_init(&pesi_tree->task_cond, NULL)); AZ(pthread_cond_init(&pesi_tasks->task_cond, NULL));
VTAILQ_INIT(&pesi_tree->task_head); VTAILQ_INIT(&pesi_tasks->task_head);
AZ(pesi_tree->task_running); AZ(pesi_tasks->task_running);
pesi = pesi_new(req->ws, pesi_tree); pesi = pesi_new(req->ws, pesi_tasks);
if (pesi == NULL) { if (pesi == NULL) {
VSLb(req->vsl, SLT_Error, VSLb(req->vsl, SLT_Error,
"Cannot allocate workspace for parallel ESI data"); "Cannot allocate workspace for parallel ESI data");
...@@ -800,7 +800,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) ...@@ -800,7 +800,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
root_node = node_alloc(pesi); root_node = node_alloc(pesi);
root_node_init(root_node, req); root_node_init(root_node, req);
bytes_tree_init(pesi_tree->bytes_tree, root_node); bytes_tree_init(pesi_tasks->bytes_tree, root_node);
pesi->node = root_node; pesi->node = root_node;
AZ(pecx->state); AZ(pecx->state);
...@@ -818,15 +818,15 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv) ...@@ -818,15 +818,15 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
{ {
struct req *req; struct req *req;
struct pesi *pesi; struct pesi *pesi;
struct pesi_tree *pesi_tree; struct pesi_tasks *pesi_tasks;
struct node *node; struct node *node;
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
AN(priv); AN(priv);
CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC); CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC);
pesi_tree = pesi->pesi_tree; pesi_tasks = pesi->pesi_tasks;
CHECK_OBJ_NOTNULL(pesi_tree, PESI_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi_tasks, PESI_TREE_MAGIC);
node = pesi->node; node = pesi->node;
CHECK_OBJ_NOTNULL(node, NODE_MAGIC); CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
...@@ -863,11 +863,11 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv) ...@@ -863,11 +863,11 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
assert(req->transport_priv == NULL || assert(req->transport_priv == NULL ||
*(unsigned *)req->transport_priv != PESI_MAGIC); *(unsigned *)req->transport_priv != PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi_tree, PESI_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi_tasks, PESI_TREE_MAGIC);
assert(pesi_tree == pesi->pesi_tree); assert(pesi_tasks == pesi->pesi_tasks);
pesi_destroy(&pesi); pesi_destroy(&pesi);
task_fini(pesi_tree, pesi); task_fini(pesi_tasks, pesi);
/* /*
* ensure that all tasks are done * ensure that all tasks are done
...@@ -875,20 +875,20 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv) ...@@ -875,20 +875,20 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
* there can be at most one signal ever being posted on task_cond, so, * there can be at most one signal ever being posted on task_cond, so,
* deliberately, this is if (...) not while (...) * deliberately, this is if (...) not while (...)
*/ */
if (pesi_tree->task_running > 0) { if (pesi_tasks->task_running > 0) {
Lck_Lock(&pesi_tree->task_lock); Lck_Lock(&pesi_tasks->task_lock);
if (pesi_tree->task_running > 0) if (pesi_tasks->task_running > 0)
AZ(Lck_CondWait(&pesi_tree->task_cond, AZ(Lck_CondWait(&pesi_tasks->task_cond,
&pesi_tree->task_lock)); &pesi_tasks->task_lock));
Lck_Unlock(&pesi_tree->task_lock); Lck_Unlock(&pesi_tasks->task_lock);
} }
bytes_tree_fini(pesi_tree->bytes_tree, req->vdc); bytes_tree_fini(pesi_tasks->bytes_tree, req->vdc);
AZ(pesi_tree->task_running); AZ(pesi_tasks->task_running);
assert(VTAILQ_EMPTY(&pesi_tree->task_head)); assert(VTAILQ_EMPTY(&pesi_tasks->task_head));
Lck_Delete(&pesi_tree->task_lock); Lck_Delete(&pesi_tasks->task_lock);
AZ(pthread_cond_destroy(&pesi_tree->task_cond)); AZ(pthread_cond_destroy(&pesi_tasks->task_cond));
*priv = NULL; *priv = NULL;
return (0); return (0);
...@@ -947,10 +947,10 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -947,10 +947,10 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
AN(priv); AN(priv);
CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC); CAST_OBJ_NOTNULL(pesi, *priv, PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pecx, PECX_MAGIC); CHECK_OBJ_NOTNULL(pesi->pecx, PECX_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree, PESI_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi->pesi_tasks, PESI_TREE_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree->bytes_tree, BYTES_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi->pesi_tasks->bytes_tree, BYTES_TREE_MAGIC);
pecx = pesi->pecx; pecx = pesi->pecx;
tree = pesi->pesi_tree->bytes_tree; tree = pesi->pesi_tasks->bytes_tree;
node = pesi->node; node = pesi->node;
CHECK_OBJ_NOTNULL(node, NODE_MAGIC); CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
...@@ -1321,9 +1321,9 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody) ...@@ -1321,9 +1321,9 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
CAST_OBJ_NOTNULL(pesi, req->transport_priv, PESI_MAGIC); CAST_OBJ_NOTNULL(pesi, req->transport_priv, PESI_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree, PESI_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi->pesi_tasks, PESI_TREE_MAGIC);
CHECK_OBJ_NOTNULL(pesi->pesi_tree->bytes_tree, BYTES_TREE_MAGIC); CHECK_OBJ_NOTNULL(pesi->pesi_tasks->bytes_tree, BYTES_TREE_MAGIC);
tree = pesi->pesi_tree->bytes_tree; tree = pesi->pesi_tasks->bytes_tree;
node = pesi->node; node = pesi->node;
parent = node->parent; parent = node->parent;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* interfaces shared between vdp_pesi.c and vmod_pesi.c * interfaces shared between vdp_pesi.c and vmod_pesi.c
*/ */
extern struct VSC_lck *lck_bytes_tree, *lck_pesi_tree; extern struct VSC_lck *lck_bytes_tree, *lck_pesi_tasks;
extern const struct vdp VDP_pesi; extern const struct vdp VDP_pesi;
/* ------------------------------------------------------------ /* ------------------------------------------------------------
......
...@@ -350,10 +350,10 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) ...@@ -350,10 +350,10 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
if (loadcnt++ == 0) { if (loadcnt++ == 0) {
AZ(vsc_seg); AZ(vsc_seg);
lck_bytes_tree = Lck_CreateClass(&vsc_seg, "pesi.buf"); lck_bytes_tree = Lck_CreateClass(&vsc_seg, "pesi.buf");
lck_pesi_tree = Lck_CreateClass(&vsc_seg, "pesi.tasks"); lck_pesi_tasks = Lck_CreateClass(&vsc_seg, "pesi.tasks");
lck_stats = Lck_CreateClass(&vsc_seg, "pesi.stats"); lck_stats = Lck_CreateClass(&vsc_seg, "pesi.stats");
AN(lck_bytes_tree); AN(lck_bytes_tree);
AN(lck_pesi_tree); AN(lck_pesi_tasks);
AZ(pesi_vsc_seg); AZ(pesi_vsc_seg);
stats = VSC_pesi_New(NULL, &pesi_vsc_seg, ""); stats = VSC_pesi_New(NULL, &pesi_vsc_seg, "");
AN(stats); AN(stats);
......
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