Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvdp-pesi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
uplex-varnish
libvdp-pesi
Commits
33a73ce8
Unverified
Commit
33a73ce8
authored
Jan 26, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor out bytes_tree_init/fini
parent
b56bd733
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
40 deletions
+57
-40
vdp_pesi.c
src/vdp_pesi.c
+57
-40
No files found.
src/vdp_pesi.c
View file @
33a73ce8
...
...
@@ -649,6 +649,61 @@ static const struct vdp VDP_pesi_buf = {
.
fini
=
pesi_buf_fini
,
};
/* ------------------------------------------------------------
* init/fini for sub-structures
*/
static
void
bytes_tree_init
(
struct
bytes_tree
*
bytes_tree
)
{
AN
(
bytes_tree
);
INIT_OBJ
(
bytes_tree
,
BYTES_TREE_MAGIC
);
Lck_New
(
&
bytes_tree
->
tree_lock
,
lck_bytes_tree
);
AZ
(
pthread_cond_init
(
&
bytes_tree
->
cond
,
NULL
));
AZ
(
bytes_tree
->
retval
);
AZ
(
bytes_tree
->
npending
);
}
static
void
bytes_tree_fini
(
struct
bytes_tree
*
bytes_tree
,
struct
vdp_ctx
*
vdc
)
{
CHECK_OBJ_NOTNULL
(
bytes_tree
,
BYTES_TREE_MAGIC
);
/*
* prevent race with vped_task()
*/
Lck_Lock
(
&
bytes_tree
->
tree_lock
);
assert_node
(
bytes_tree
->
root
,
CHK_ANY
);
if
(
bytes_tree
->
root
->
nexus
.
npending_private
==
1
&&
bytes_tree
->
npending
==
0
)
{
AZ
(
bytes_tree
->
retval
);
assert
(
bytes_tree
->
root
->
state
==
ST_PRIVATE
);
assert
(
bytes_tree
->
root
->
type
==
T_NEXUS
);
}
else
if
(
bytes_tree
->
retval
==
0
)
{
assert
(
bytes_tree
->
root
->
nexus
.
npending_private
==
0
);
assert
(
bytes_tree
->
npending
==
0
);
assert_node
(
bytes_tree
->
root
,
CHK_DELI
);
}
/*
* else we got an error condition and cannot make assumptions about the
* state of the tree before all tasks have finished
*/
/*
* for an early client close, our subrequests had no chance to run
*/
tree_prune
(
vdc
,
bytes_tree
->
root
);
Lck_Unlock
(
&
bytes_tree
->
tree_lock
);
Lck_Delete
(
&
bytes_tree
->
tree_lock
);
AZ
(
pthread_cond_destroy
(
&
bytes_tree
->
cond
));
tree_free
(
vdc
,
bytes_tree
->
root
);
}
/* ------------------------------------------------------------
* process ESI objects from storage
*/
...
...
@@ -707,7 +762,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
"parallel ESI tree data"
);
return
(
-
1
);
}
INIT_OBJ
(
pesi_tree
->
bytes_tree
,
BYTES_TREE_MAGIC
);
bytes_tree_init
(
pesi_tree
->
bytes_tree
);
Lck_New
(
&
pesi_tree
->
task_lock
,
lck_pesi_tree
);
AZ
(
pthread_cond_init
(
&
pesi_tree
->
task_cond
,
NULL
));
...
...
@@ -734,10 +789,6 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
root_node
->
nexus
.
gzip
.
magic
=
NEXUS_GZIP_MAGIC
;
root_node
->
nexus
.
npending_private
=
1
;
VSTAILQ_INIT
(
&
root_node
->
nexus
.
children
);
Lck_New
(
&
pesi_tree
->
bytes_tree
->
tree_lock
,
lck_bytes_tree
);
AZ
(
pthread_cond_init
(
&
pesi_tree
->
bytes_tree
->
cond
,
NULL
));
AZ
(
pesi_tree
->
bytes_tree
->
retval
);
AZ
(
pesi_tree
->
bytes_tree
->
npending
);
pesi
->
node
=
root_node
;
AZ
(
pecx
->
state
);
...
...
@@ -756,7 +807,6 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
struct
req
*
req
;
struct
pesi
*
pesi
;
struct
pesi_tree
*
pesi_tree
;
struct
bytes_tree
*
bytes_tree
;
struct
node
*
node
;
CHECK_OBJ_NOTNULL
(
vdc
,
VDP_CTX_MAGIC
);
...
...
@@ -765,8 +815,6 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
CAST_OBJ_NOTNULL
(
pesi
,
*
priv
,
PESI_MAGIC
);
pesi_tree
=
pesi
->
pesi_tree
;
CHECK_OBJ_NOTNULL
(
pesi_tree
,
PESI_TREE_MAGIC
);
bytes_tree
=
pesi_tree
->
bytes_tree
;
CHECK_OBJ_NOTNULL
(
bytes_tree
,
BYTES_TREE_MAGIC
);
node
=
pesi
->
node
;
CHECK_OBJ_NOTNULL
(
node
,
NODE_MAGIC
);
...
...
@@ -803,25 +851,8 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
assert
(
req
->
transport_priv
==
NULL
||
*
(
unsigned
*
)
req
->
transport_priv
!=
PESI_MAGIC
);
if
(
bytes_tree
->
root
->
nexus
.
npending_private
==
1
&&
bytes_tree
->
npending
==
0
)
{
AZ
(
bytes_tree
->
retval
);
assert
(
bytes_tree
->
root
->
state
==
ST_PRIVATE
);
assert
(
bytes_tree
->
root
->
type
==
T_NEXUS
);
}
else
if
(
bytes_tree
->
retval
==
0
)
{
assert
(
bytes_tree
->
root
->
nexus
.
npending_private
==
0
);
assert
(
bytes_tree
->
npending
==
0
);
assert_node
(
bytes_tree
->
root
,
CHK_DELI
);
}
/*
* else we got an error condition and cannot make assumptions about the
* state of the tree before all tasks have finished
*/
CHECK_OBJ_NOTNULL
(
pesi_tree
,
PESI_TREE_MAGIC
);
assert
(
pesi_tree
==
pesi
->
pesi_tree
);
CHECK_OBJ_NOTNULL
(
bytes_tree
,
BYTES_TREE_MAGIC
);
assert
(
bytes_tree
==
pesi_tree
->
bytes_tree
);
pesi_destroy
(
&
pesi
);
task_fini
(
pesi_tree
,
pesi
);
...
...
@@ -839,28 +870,14 @@ vdp_pesi_fini(struct vdp_ctx *vdc, void **priv)
&
pesi_tree
->
task_lock
));
Lck_Unlock
(
&
pesi_tree
->
task_lock
);
}
/*
* prevent race with vped_task()
*/
Lck_Lock
(
&
pesi_tree
->
bytes_tree
->
tree_lock
);
assert_node
(
bytes_tree
->
root
,
CHK_ANY
);
/*
* for an early client close, our subrequests had no chance to run
*/
tree_prune
(
req
->
vdc
,
bytes_tree
->
root
);
bytes_tree_fini
(
pesi_tree
->
bytes_tree
,
req
->
vdc
);
AZ
(
pesi_tree
->
task_running
);
assert
(
VTAILQ_EMPTY
(
&
pesi_tree
->
task_head
));
Lck_Delete
(
&
pesi_tree
->
task_lock
);
AZ
(
pthread_cond_destroy
(
&
pesi_tree
->
task_cond
));
Lck_Unlock
(
&
pesi_tree
->
bytes_tree
->
tree_lock
);
Lck_Delete
(
&
bytes_tree
->
tree_lock
);
AZ
(
pthread_cond_destroy
(
&
bytes_tree
->
cond
));
tree_free
(
req
->
vdc
,
bytes_tree
->
root
);
*
priv
=
NULL
;
return
(
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment