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
9015c6d0
Unverified
Commit
9015c6d0
authored
Jun 12, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor node init
parent
bbed74ff
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
24 deletions
+26
-24
node.c
src/node.c
+13
-1
node.h
src/node.h
+1
-1
vdp_pesi.c
src/vdp_pesi.c
+12
-22
No files found.
src/node.c
View file @
9015c6d0
...
...
@@ -198,7 +198,7 @@ vmod_workspace_prealloc(VRT_CTX, VCL_BYTES min_free, VCL_INT max_nodes)
ws_max_nodes
=
max_nodes
;
}
struct
node
*
st
atic
st
ruct
node
*
node_alloc
(
struct
pesi
*
pesi
)
{
struct
node
*
node
;
...
...
@@ -225,6 +225,18 @@ node_alloc(struct pesi *pesi)
return
(
node
);
}
struct
node
*
node_new
(
struct
pesi
*
pesi
,
enum
n_type
type
,
enum
n_state
state
)
{
struct
node
*
node
;
node
=
node_alloc
(
pesi
);
AN
(
node
);
node
->
type
=
type
;
node
->
state
=
state
;
return
(
node
);
}
static
void
node_fini
(
struct
vdp_ctx
*
vdx
,
struct
node
*
node
)
{
...
...
src/node.h
View file @
9015c6d0
...
...
@@ -241,7 +241,7 @@ void node_fill_nodestock(struct ws *, struct node_head *);
//--------------
struct
pesi
;
struct
node
*
node_
alloc
(
struct
pesi
*
);
struct
node
*
node_
new
(
struct
pesi
*
pesi
,
enum
n_type
type
,
enum
n_state
state
);
void
node_insert
(
const
struct
bytes_tree
*
,
struct
node
*
,
struct
node
*
);
void
set_closed
(
struct
bytes_tree
*
,
struct
node
*
);
...
...
src/vdp_pesi.c
View file @
9015c6d0
...
...
@@ -500,11 +500,8 @@ pesi_buf_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
VSLdbg
(
vdx
,
"bytes_add: adding data to node"
);
node
=
node_
alloc
(
pesi
);
node
=
node_
new
(
pesi
,
T_DATA
,
ST_DATA
);
CHECK_OBJ_NOTNULL
(
node
,
NODE_MAGIC
);
node
->
type
=
T_DATA
;
node
->
state
=
ST_DATA
;
node
->
data
.
len
=
len
;
node
->
data
.
act
=
act
;
...
...
@@ -634,17 +631,19 @@ bytes_tree_fini(struct bytes_tree *bytes_tree, struct vdp_ctx *vdc)
Lck_Delete
(
&
bytes_tree
->
nodes_lock
);
}
static
void
root_node_
init
(
struct
node
*
root_node
,
struct
req
*
req
)
static
struct
node
*
root_node_
new
(
struct
pesi
*
pesi
,
struct
req
*
req
)
{
struct
node
*
root_node
;
root_node
=
node_new
(
pesi
,
T_NEXUS
,
ST_PRIVATE
);
CHECK_OBJ_NOTNULL
(
root_node
,
NODE_MAGIC
);
root_node
->
state
=
ST_PRIVATE
;
root_node
->
type
=
T_NEXUS
;
root_node
->
nexus
.
req
=
req
;
root_node
->
nexus
.
gzip
.
magic
=
NEXUS_GZIP_MAGIC
;
root_node
->
nexus
.
npending_private
=
1
;
VSTAILQ_INIT
(
&
root_node
->
nexus
.
children
);
return
(
root_node
);
}
...
...
@@ -724,8 +723,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
node_fill_nodestock
(
req
->
ws
,
&
pesi
->
nodestock
);
root_node
=
node_alloc
(
pesi
);
root_node_init
(
root_node
,
req
);
root_node
=
root_node_new
(
pesi
,
req
);
bytes_tree_init
(
pesi_tasks
->
bytes_tree
,
root_node
);
...
...
@@ -921,10 +919,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
if
(
*
pecx
->
p
==
VEC_GZ
)
{
if
(
parent_gzip
==
NULL
)
{
AZ
(
child
);
child
=
node_
alloc
(
pesi
);
child
=
node_
new
(
pesi
,
T_CRC
,
ST_DATA
);
CHECK_OBJ_NOTNULL
(
child
,
NODE_MAGIC
);
child
->
type
=
T_CRC
;
child
->
state
=
ST_DATA
;
child
->
crc
.
ctype
=
GZIP_HDR
;
node_insert
(
tree
,
node
,
child
);
child
=
NULL
;
...
...
@@ -960,10 +956,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
return
(
-
1
);
AZ
(
child
);
child
=
node_
alloc
(
pesi
);
child
=
node_
new
(
pesi
,
T_CRC
,
ST_DATA
);
CHECK_OBJ_NOTNULL
(
child
,
NODE_MAGIC
);
child
->
type
=
T_CRC
;
child
->
state
=
ST_DATA
;
child
->
crc
.
ctype
=
UPDATE
;
child
->
crc
.
icrc
=
vbe32dec
(
pecx
->
p
);
child
->
crc
.
l_icrc
=
l
;
...
...
@@ -997,10 +991,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
Debug
(
"INCL [%s][%s] BEGIN
\n
"
,
q
,
pecx
->
p
);
AZ
(
child
);
child
=
node_
alloc
(
pesi
);
child
=
node_
new
(
pesi
,
T_NEXUS
,
ST_PRIVATE
);
CHECK_OBJ_NOTNULL
(
child
,
NODE_MAGIC
);
child
->
type
=
T_NEXUS
;
child
->
state
=
ST_PRIVATE
;
child
->
nexus
.
gzip
.
magic
=
NEXUS_GZIP_MAGIC
;
node_insert
(
tree
,
node
,
child
);
...
...
@@ -1029,10 +1021,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
case
2
:
if
(
node
->
nexus
.
gzip
.
is
)
{
AZ
(
child
);
child
=
node_
alloc
(
pesi
);
child
=
node_
new
(
pesi
,
T_CRC
,
ST_DATA
);
CHECK_OBJ_NOTNULL
(
child
,
NODE_MAGIC
);
child
->
type
=
T_CRC
;
child
->
state
=
ST_DATA
;
child
->
crc
.
ctype
=
FINAL
;
node_insert
(
tree
,
node
,
child
);
child
=
NULL
;
...
...
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