Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-zipflow
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-zipflow
Commits
326a225c
Unverified
Commit
326a225c
authored
Aug 21, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flexelinting
parent
d95bf1d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
30 deletions
+48
-30
flint.lnt
src/flint.lnt
+5
-0
vmod_zipflow.c
src/vmod_zipflow.c
+43
-30
No files found.
src/flint.lnt
View file @
326a225c
...
...
@@ -15,3 +15,8 @@
// must always be included to ensure sanity
-efile(766, config.h)
// assert constructors not referenced
-esym(528, assert_*)
-emacro(747, WS_TASK_ALLOC_OBJ)
\ No newline at end of file
src/vmod_zipflow.c
View file @
326a225c
...
...
@@ -44,7 +44,7 @@
static
void
__attribute__
((
constructor
))
assert_zlib
(
void
)
{
assert
(
Z_DEFAULT_COMPRESSION
==
-
1
);
assert
(
Z_DEFAULT_COMPRESSION
==
-
1
);
//lint !e506 const bool
}
// https://github.com/varnishcache/varnish-cache/pull/3815
...
...
@@ -60,8 +60,8 @@ assert_zlib(void)
static
char
default_level
=
Z_DEFAULT_COMPRESSION
;
static
const
void
*
zipflow_request_priv
=
&
zipflow_request_priv
;
static
const
void
*
zipflow_top_priv
=
&
zipflow_top_priv
;
static
const
void
*
const
zipflow_request_priv
=
&
zipflow_request_priv
;
static
const
void
*
const
zipflow_top_priv
=
&
zipflow_top_priv
;
struct
zipflow_top
;
struct
zipflow_request
{
...
...
@@ -111,7 +111,19 @@ get_zipflow_top(VRT_CTX)
return
(
zft
);
}
static
struct
vdp
vdp_zipflow
;
static
int
vdp_zipflow_init
(
VRT_CTX
,
struct
vdp_ctx
*
vdc
,
void
**
priv
,
struct
objcore
*
oc
);
static
int
vdp_zipflow_fini
(
struct
vdp_ctx
*
vdc
,
void
**
priv
);
static
int
vdp_zipflow_bytes
(
struct
vdp_ctx
*
vdc
,
enum
vdp_action
act
,
void
**
priv
,
const
void
*
ptr
,
ssize_t
len
);
static
const
struct
vdp
vdp_zipflow
[
1
]
=
{{
.
name
=
"zipflow"
,
.
init
=
vdp_zipflow_init
,
.
bytes
=
vdp_zipflow_bytes
,
.
fini
=
vdp_zipflow_fini
,
.
priv1
=
NULL
}};
static
struct
zipflow_request
*
new_zipflow_request
(
VRT_CTX
,
struct
zipflow_top
*
zft
)
...
...
@@ -220,7 +232,7 @@ vmod_set_level(VRT_CTX, VCL_INT level)
}
if
(
ctx
->
method
==
VCL_MET_INIT
)
{
default_level
=
level
;
default_level
=
(
typeof
(
default_level
))
level
;
return
;
}
AZ
(
ctx
->
method
&
VCL_MET_TASK_H
);
...
...
@@ -239,6 +251,7 @@ vmod_meta(VRT_CTX, struct VARGS(meta) *args)
unsigned
long
u
;
char
*
e
;
(
void
)
args
;
if
(
zfr
==
NULL
)
return
;
...
...
@@ -251,8 +264,11 @@ vmod_meta(VRT_CTX, struct VARGS(meta) *args)
if
(
u
==
ULONG_MAX
||
(
e
!=
NULL
&&
*
e
!=
'\0'
))
{
VRT_fail
(
ctx
,
".meta() error converting mode at %s: "
"%d (%s)"
,
e
,
errno
,
VAS_errtxt
(
errno
));
}
else
zfr
->
mode
=
u
;
}
else
{
assert
(
u
<
UINT_MAX
);
zfr
->
mode
=
(
unsigned
)
u
;
}
}
if
(
args
->
valid_atime
)
zfr
->
atime
=
args
->
atime
;
...
...
@@ -264,7 +280,7 @@ static const char *
get_url
(
VRT_CTX
)
{
const
char
*
url
;
VCL_HTTP
http
;
VCL_HTTP
http
=
NULL
;
if
(
ctx
->
http_bereq
!=
NULL
)
http
=
ctx
->
http_bereq
;
...
...
@@ -283,9 +299,9 @@ get_url(VRT_CTX)
static
const
char
*
default_name
(
VRT_CTX
)
{
const
char
*
url
=
get_url
(
ctx
);
size_t
l
;
char
*
p
;
const
char
*
p
,
*
url
=
get_url
(
ctx
);
s
s
ize_t
l
;
char
*
q
;
url
=
strrchr
(
url
,
'/'
);
AN
(
url
);
...
...
@@ -300,15 +316,16 @@ default_name(VRT_CTX)
assert
(
p
>
url
);
l
=
p
-
url
;
p
=
WS_Copy
(
ctx
->
ws
,
url
,
1
+
l
);
if
(
p
==
NULL
)
l
++
;
q
=
WS_Copy
(
ctx
->
ws
,
url
,
(
int
)
l
);
if
(
q
==
NULL
)
return
(
"unnamed_file"
);
p
[
l
]
=
'\0'
;
return
(
p
);
q
[
l
]
=
'\0'
;
return
(
q
);
}
static
VCL_TIME
lm
(
VRT_CTX
)
get_
lm
(
VRT_CTX
)
{
const
char
*
p
;
VCL_TIME
lm
;
...
...
@@ -331,7 +348,6 @@ lm(VRT_CTX)
static
void
fill_meta
(
VRT_CTX
,
struct
zipflow_request
*
zfr
)
{
const
char
*
r
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
zfr
,
ZIPFLOW_REQUEST_MAGIC
);
...
...
@@ -342,7 +358,7 @@ fill_meta(VRT_CTX, struct zipflow_request *zfr)
if
(
zfr
->
atime
<
0
)
zfr
->
atime
=
ctx
->
now
;
if
(
zfr
->
mtime
<
0
)
zfr
->
mtime
=
lm
(
ctx
);
zfr
->
mtime
=
get_
lm
(
ctx
);
VSLb
(
ctx
->
vsl
,
SLT_Debug
,
"%s %o %f %f"
,
zfr
->
name
,
zfr
->
mode
,
zfr
->
atime
,
zfr
->
mtime
);
}
...
...
@@ -354,11 +370,11 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
switch
(
e
)
{
case
VCL_EVENT_LOAD
:
if
(
VRT_AddFilter
(
ctx
,
NULL
,
&
vdp_zipflow
)
!=
NULL
)
if
(
VRT_AddFilter
(
ctx
,
NULL
,
vdp_zipflow
)
!=
NULL
)
return
(
1
);
break
;
case
VCL_EVENT_DISCARD
:
VRT_RemoveFilter
(
ctx
,
NULL
,
&
vdp_zipflow
);
VRT_RemoveFilter
(
ctx
,
NULL
,
vdp_zipflow
);
break
;
case
VCL_EVENT_WARM
:
case
VCL_EVENT_COLD
:
...
...
@@ -382,7 +398,7 @@ vdp_zipflow_put(void *priv, void const *ptr, size_t len)
if
(
ptr
==
NULL
||
len
==
0
)
return
(
0
);
return
(
VDP_bytes
(
priv
,
VDP_FLUSH
,
ptr
,
len
));
return
(
VDP_bytes
(
priv
,
VDP_FLUSH
,
ptr
,
(
ssize_t
)
len
));
}
static
void
...
...
@@ -402,6 +418,8 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
struct
zipflow_top
*
zft
;
struct
req
*
req
;
(
void
)
oc
;
if
(
zfr
==
NULL
)
return
(
1
);
...
...
@@ -444,6 +462,7 @@ vdp_zipflow_fini(struct vdp_ctx *vdc, void **priv)
struct
zipflow_top
*
zft
;
int
r
;
(
void
)
vdc
;
AN
(
priv
);
zfr
=
*
priv
;
*
priv
=
NULL
;
...
...
@@ -475,7 +494,8 @@ vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv,
(
void
)
zip_close
(
zft
->
zip
);
return
(
1
);
}
r
=
zip_data
(
zft
->
zip
,
ptr
,
len
,
act
==
VDP_END
);
assert
(
len
>=
0
);
r
=
zip_data
(
zft
->
zip
,
ptr
,
(
size_t
)
len
,
act
==
VDP_END
?
1
:
0
);
if
(
r
)
{
VSLb
(
vdc
->
vsl
,
SLT_Error
,
"zip_data returned %d"
,
r
);
return
(
-
1
);
...
...
@@ -489,12 +509,5 @@ vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv,
if
(
r
)
VSLb
(
vdc
->
vsl
,
SLT_Error
,
"zip_close returned %d"
,
r
);
memset
(
zfr
,
0
,
sizeof
*
zfr
);
return
(
VDP_bytes
(
vdc
,
VDP_END
,
NULL
,
0
));
return
(
VDP_bytes
(
vdc
,
VDP_END
,
NULL
,
(
size_t
)
0
));
}
static
struct
vdp
vdp_zipflow
=
{
.
name
=
"zipflow"
,
.
init
=
vdp_zipflow_init
,
.
bytes
=
vdp_zipflow_bytes
,
.
fini
=
vdp_zipflow_fini
};
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