Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
9765f1a8
Commit
9765f1a8
authored
Oct 24, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Downgrade ESI parse from using struct sess to struct worker.
parent
78f18e85
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
55 deletions
+63
-55
cache.h
bin/varnishd/cache.h
+8
-1
cache_esi.h
bin/varnishd/cache_esi.h
+4
-5
cache_esi_fetch.c
bin/varnishd/cache_esi_fetch.c
+15
-15
cache_esi_parse.c
bin/varnishd/cache_esi_parse.c
+31
-29
cache_gzip.c
bin/varnishd/cache_gzip.c
+5
-5
No files found.
bin/varnishd/cache.h
View file @
9765f1a8
...
...
@@ -717,7 +717,7 @@ void VGZ_Ibuf(struct vgz *, const void *, ssize_t len);
int
VGZ_IbufEmpty
(
const
struct
vgz
*
vg
);
void
VGZ_Obuf
(
struct
vgz
*
,
void
*
,
ssize_t
len
);
int
VGZ_ObufFull
(
const
struct
vgz
*
vg
);
int
VGZ_ObufStorage
(
const
struct
sess
*
sp
,
struct
vgz
*
vg
);
int
VGZ_ObufStorage
(
struct
worker
*
w
,
struct
vgz
*
vg
);
int
VGZ_Gzip
(
struct
vgz
*
,
const
void
**
,
size_t
*
len
,
enum
vgz_flag
);
int
VGZ_Gunzip
(
struct
vgz
*
,
const
void
**
,
size_t
*
len
);
void
VGZ_Destroy
(
struct
vgz
**
);
...
...
@@ -863,6 +863,13 @@ void VSM_Free(const void *ptr);
void
VSL
(
enum
VSL_tag_e
tag
,
int
id
,
const
char
*
fmt
,
...);
void
WSLR
(
struct
worker
*
w
,
enum
VSL_tag_e
tag
,
int
id
,
txt
t
);
void
WSL
(
struct
worker
*
w
,
enum
VSL_tag_e
tag
,
int
id
,
const
char
*
fmt
,
...);
#define WSLB(w, tag, ...) \
do { \
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); \
CHECK_OBJ_NOTNULL(w->vbc, VBC_MAGIC); \
WSL(w, tag, (w)->vbc->vsl_id, __VA_ARGS__); \
} while (0)
void
WSL_Flush
(
struct
worker
*
w
,
int
overflow
);
#define DSL(flag, tag, id, ...) \
...
...
bin/varnishd/cache_esi.h
View file @
9765f1a8
...
...
@@ -39,11 +39,10 @@
#define VEC_S8 (0x60 + 8)
#define VEC_INCL 'I'
typedef
ssize_t
vep_callback_t
(
const
struct
sess
*
sp
,
ssize_t
l
,
enum
vgz_flag
flg
);
typedef
ssize_t
vep_callback_t
(
struct
worker
*
w
,
ssize_t
l
,
enum
vgz_flag
flg
);
void
VEP_Init
(
const
struct
sess
*
sp
,
vep_callback_t
*
cb
);
void
VEP_
parse
(
const
struct
sess
*
sp
,
const
char
*
p
,
size_t
l
);
struct
vsb
*
VEP_Finish
(
const
struct
sess
*
sp
);
void
VEP_Init
(
struct
worker
*
w
,
vep_callback_t
*
cb
);
void
VEP_
Parse
(
const
struct
worker
*
w
,
const
char
*
p
,
size_t
l
);
struct
vsb
*
VEP_Finish
(
struct
worker
*
w
);
bin/varnishd/cache_esi_fetch.c
View file @
9765f1a8
...
...
@@ -78,7 +78,7 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
st
->
ptr
+
st
->
len
,
st
->
space
-
st
->
len
,
bytes
);
if
(
w
<=
0
)
return
(
w
);
VEP_
parse
(
sp
,
(
const
char
*
)
st
->
ptr
+
st
->
len
,
w
);
VEP_
Parse
(
sp
->
wrk
,
(
const
char
*
)
st
->
ptr
+
st
->
len
,
w
);
st
->
len
+=
w
;
sp
->
obj
->
len
+=
w
;
bytes
-=
w
;
...
...
@@ -111,11 +111,11 @@ vfp_esi_bytes_gu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
VGZ_Ibuf
(
vg
,
ibuf
,
w
);
bytes
-=
w
;
}
if
(
VGZ_ObufStorage
(
sp
,
vg
))
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
return
(
-
1
);
i
=
VGZ_Gunzip
(
vg
,
&
dp
,
&
dl
);
xxxassert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
VEP_
parse
(
sp
,
dp
,
dl
);
VEP_
Parse
(
sp
->
wrk
,
dp
,
dl
);
sp
->
obj
->
len
+=
dl
;
}
return
(
1
);
...
...
@@ -141,15 +141,15 @@ struct vef_priv {
*/
static
ssize_t
vfp_vep_callback
(
const
struct
sess
*
sp
,
ssize_t
l
,
enum
vgz_flag
flg
)
vfp_vep_callback
(
struct
worker
*
w
,
ssize_t
l
,
enum
vgz_flag
flg
)
{
struct
vef_priv
*
vef
;
size_t
dl
,
px
;
const
void
*
dp
;
int
i
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
vef
=
sp
->
wrk
->
vef_priv
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
vef
=
w
->
vef_priv
;
CHECK_OBJ_NOTNULL
(
vef
,
VEF_MAGIC
);
assert
(
l
>=
0
);
...
...
@@ -179,14 +179,14 @@ vfp_vep_callback(const struct sess *sp, ssize_t l, enum vgz_flag flg)
l
=
0
;
}
do
{
if
(
VGZ_ObufStorage
(
sp
,
vef
->
vgz
))
{
if
(
VGZ_ObufStorage
(
w
,
vef
->
vgz
))
{
vef
->
error
=
errno
;
vef
->
tot
+=
l
;
return
(
vef
->
tot
);
}
i
=
VGZ_Gzip
(
vef
->
vgz
,
&
dp
,
&
dl
,
flg
);
vef
->
tot
+=
dl
;
sp
->
obj
->
len
+=
dl
;
w
->
fetch_
obj
->
len
+=
dl
;
}
while
(
!
VGZ_IbufEmpty
(
vef
->
vgz
)
||
(
flg
!=
VGZ_NORMAL
&&
VGZ_ObufFull
(
vef
->
vgz
)));
if
(
px
!=
0
)
{
...
...
@@ -219,7 +219,7 @@ vfp_esi_bytes_ug(struct sess *sp, struct http_conn *htc, ssize_t bytes)
return
(
w
);
bytes
-=
w
;
vef
->
bufp
=
ibuf
;
VEP_
parse
(
sp
,
ibuf
,
w
);
VEP_
Parse
(
sp
->
wrk
,
ibuf
,
w
);
assert
(
vef
->
bufp
>=
ibuf
&&
vef
->
bufp
<=
ibuf
+
w
);
if
(
vef
->
error
)
{
errno
=
vef
->
error
;
...
...
@@ -271,7 +271,7 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
assert
(
i
>=
VGZ_OK
);
vef
->
bufp
=
ibuf2
;
if
(
dl
>
0
)
VEP_
parse
(
sp
,
ibuf2
,
dl
);
VEP_
Parse
(
sp
->
wrk
,
ibuf2
,
dl
);
if
(
vef
->
error
)
{
errno
=
vef
->
error
;
return
(
-
1
);
...
...
@@ -302,7 +302,7 @@ vfp_esi_begin(struct sess *sp, size_t estimate)
AZ
(
sp
->
wrk
->
vgz_rx
);
if
(
sp
->
wrk
->
is_gzip
&&
sp
->
wrk
->
do_gunzip
)
{
sp
->
wrk
->
vgz_rx
=
VGZ_NewUngzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"U F E"
);
VEP_Init
(
sp
,
NULL
);
VEP_Init
(
sp
->
wrk
,
NULL
);
}
else
if
(
sp
->
wrk
->
is_gunzip
&&
sp
->
wrk
->
do_gzip
)
{
ALLOC_OBJ
(
vef
,
VEF_MAGIC
);
AN
(
vef
);
...
...
@@ -312,7 +312,7 @@ vfp_esi_begin(struct sess *sp, size_t estimate)
vef
->
vgz
=
VGZ_NewGzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"G F E"
);
AZ
(
sp
->
wrk
->
vef_priv
);
sp
->
wrk
->
vef_priv
=
vef
;
VEP_Init
(
sp
,
vfp_vep_callback
);
VEP_Init
(
sp
->
wrk
,
vfp_vep_callback
);
}
else
if
(
sp
->
wrk
->
is_gzip
)
{
sp
->
wrk
->
vgz_rx
=
VGZ_NewUngzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"U F E"
);
ALLOC_OBJ
(
vef
,
VEF_MAGIC
);
...
...
@@ -323,10 +323,10 @@ vfp_esi_begin(struct sess *sp, size_t estimate)
vef
->
vgz
=
VGZ_NewGzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"G F E"
);
AZ
(
sp
->
wrk
->
vef_priv
);
sp
->
wrk
->
vef_priv
=
vef
;
VEP_Init
(
sp
,
vfp_vep_callback
);
VEP_Init
(
sp
->
wrk
,
vfp_vep_callback
);
}
else
{
AZ
(
sp
->
wrk
->
vef_priv
);
VEP_Init
(
sp
,
NULL
);
VEP_Init
(
sp
->
wrk
,
NULL
);
}
(
void
)
estimate
;
...
...
@@ -362,7 +362,7 @@ vfp_esi_end(struct sess *sp)
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
AN
(
sp
->
wrk
->
vep
);
vsb
=
VEP_Finish
(
sp
);
vsb
=
VEP_Finish
(
sp
->
wrk
);
if
(
vsb
!=
NULL
)
{
l
=
VSB_len
(
vsb
);
...
...
bin/varnishd/cache_esi_parse.c
View file @
9765f1a8
...
...
@@ -35,6 +35,7 @@
#include "cache.h"
#include "cache_backend.h" // XXX: w->vbc for WSLB
#include "cache_esi.h"
#include "vct.h"
#include "vend.h"
...
...
@@ -60,7 +61,7 @@ struct vep_state {
#define VEP_MAGIC 0x55cb9b82
struct
vsb
*
vsb
;
const
struct
sess
*
sp
;
struct
worker
*
wrk
;
int
dogzip
;
vep_callback_t
*
cb
;
...
...
@@ -186,7 +187,7 @@ vep_error(const struct vep_state *vep, const char *p)
VSC_C_main
->
esi_errors
++
;
l
=
(
intmax_t
)(
vep
->
ver_p
-
vep
->
hack_p
);
WS
P
(
vep
->
sp
,
SLT_ESI_xmlerror
,
"ERR at %jd %s"
,
l
,
p
);
WS
LB
(
vep
->
wrk
,
SLT_ESI_xmlerror
,
"ERR at %jd %s"
,
l
,
p
);
}
...
...
@@ -202,7 +203,7 @@ vep_warn(const struct vep_state *vep, const char *p)
VSC_C_main
->
esi_warnings
++
;
l
=
(
intmax_t
)(
vep
->
ver_p
-
vep
->
hack_p
);
printf
(
"WARNING at %jd %s
\n
"
,
l
,
p
);
WS
P
(
vep
->
sp
,
SLT_ESI_xmlerror
,
"WARN at %jd %s"
,
l
,
p
);
WS
LB
(
vep
->
wrk
,
SLT_ESI_xmlerror
,
"WARN at %jd %s"
,
l
,
p
);
}
...
...
@@ -328,7 +329,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark)
*/
if
(
vep
->
last_mark
!=
mark
&&
(
vep
->
o_wait
>
0
||
vep
->
startup
))
{
lcb
=
vep
->
cb
(
vep
->
sp
,
0
,
lcb
=
vep
->
cb
(
vep
->
wrk
,
0
,
mark
==
VERBATIM
?
VGZ_RESET
:
VGZ_ALIGN
);
if
(
lcb
-
vep
->
o_last
>
0
)
vep_emit_common
(
vep
,
lcb
-
vep
->
o_last
,
vep
->
last_mark
);
...
...
@@ -338,7 +339,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark)
/* Transfer pending bytes CRC into active mode CRC */
if
(
vep
->
o_pending
)
{
(
void
)
vep
->
cb
(
vep
->
sp
,
vep
->
o_pending
,
VGZ_NORMAL
);
(
void
)
vep
->
cb
(
vep
->
wrk
,
vep
->
o_pending
,
VGZ_NORMAL
);
if
(
vep
->
o_crc
==
0
)
{
vep
->
crc
=
vep
->
crcp
;
vep
->
o_crc
=
vep
->
o_pending
;
...
...
@@ -362,7 +363,7 @@ vep_mark_common(struct vep_state *vep, const char *p, enum vep_mark mark)
vep
->
o_wait
+=
l
;
vep
->
last_mark
=
mark
;
(
void
)
vep
->
cb
(
vep
->
sp
,
l
,
VGZ_NORMAL
);
(
void
)
vep
->
cb
(
vep
->
wrk
,
l
,
VGZ_NORMAL
);
}
static
void
...
...
@@ -499,7 +500,7 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
VSB_printf
(
vep
->
vsb
,
"%c"
,
0
);
}
else
{
VSB_printf
(
vep
->
vsb
,
"%c"
,
0
);
url
=
vep
->
sp
->
wrk
->
bereq
->
hd
[
HTTP_HDR_URL
];
url
=
vep
->
wrk
->
bereq
->
hd
[
HTTP_HDR_URL
];
/* Look for the last / before a '?' */
h
=
NULL
;
for
(
q
=
url
.
b
;
q
<
url
.
e
&&
*
q
!=
'?'
;
q
++
)
...
...
@@ -548,15 +549,15 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
*/
void
VEP_
parse
(
const
struct
sess
*
sp
,
const
char
*
p
,
size_t
l
)
VEP_
Parse
(
const
struct
worker
*
w
,
const
char
*
p
,
size_t
l
)
{
struct
vep_state
*
vep
;
const
char
*
e
;
struct
vep_match
*
vm
;
int
i
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
vep
=
sp
->
wrk
->
vep
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
vep
=
w
->
vep
;
CHECK_OBJ_NOTNULL
(
vep
,
VEP_MAGIC
);
assert
(
l
>
0
);
...
...
@@ -601,7 +602,7 @@ VEP_parse(const struct sess *sp, const char *p, size_t l)
p
++
;
vep
->
state
=
VEP_STARTTAG
;
}
else
if
(
p
<
e
)
{
WS
P
(
vep
->
sp
,
SLT_ESI_xmlerror
,
WS
LB
(
vep
->
wrk
,
SLT_ESI_xmlerror
,
"No ESI processing, first char not '<'"
);
vep
->
state
=
VEP_NOTXML
;
}
...
...
@@ -978,33 +979,34 @@ VEP_parse(const struct sess *sp, const char *p, size_t l)
/*---------------------------------------------------------------------
*/
static
ssize_t
vep_default_cb
(
const
struct
sess
*
sp
,
ssize_t
l
,
enum
vgz_flag
flg
)
static
ssize_t
__match_proto__
()
vep_default_cb
(
struct
worker
*
w
,
ssize_t
l
,
enum
vgz_flag
flg
)
{
(
void
)
flg
;
AN
(
sp
->
wrk
->
vep
);
sp
->
wrk
->
vep
->
cb_x
+=
l
;
Debug
(
"CB(%jd,%d) = %jd
\n
"
,
(
intmax_t
)
l
,
flg
,
(
intmax_t
)
sp
->
wrk
->
vep
->
cb_x
);
return
(
sp
->
wrk
->
vep
->
cb_x
);
AN
(
w
->
vep
);
w
->
vep
->
cb_x
+=
l
;
Debug
(
"CB(%jd,%d) = %jd
\n
"
,
(
intmax_t
)
l
,
flg
,
(
intmax_t
)
w
->
vep
->
cb_x
);
return
(
w
->
vep
->
cb_x
);
}
/*---------------------------------------------------------------------
*/
void
VEP_Init
(
const
struct
sess
*
sp
,
vep_callback_t
*
cb
)
VEP_Init
(
struct
worker
*
w
,
vep_callback_t
*
cb
)
{
struct
vep_state
*
vep
;
AZ
(
sp
->
wrk
->
vep
);
sp
->
wrk
->
vep
=
(
void
*
)
WS_Alloc
(
sp
->
wrk
->
ws
,
sizeof
*
vep
);
AN
(
sp
->
wrk
->
vep
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER_MAGIC
);
AZ
(
w
->
vep
);
w
->
vep
=
(
void
*
)
WS_Alloc
(
w
->
ws
,
sizeof
*
vep
);
AN
(
w
->
vep
);
vep
=
sp
->
wrk
->
vep
;
vep
=
w
->
vep
;
memset
(
vep
,
0
,
sizeof
*
vep
);
vep
->
magic
=
VEP_MAGIC
;
vep
->
sp
=
sp
;
vep
->
wrk
=
w
;
vep
->
vsb
=
VSB_new_auto
();
AN
(
vep
->
vsb
);
...
...
@@ -1037,24 +1039,24 @@ VEP_Init(const struct sess *sp, vep_callback_t *cb)
*/
struct
vsb
*
VEP_Finish
(
const
struct
sess
*
sp
)
VEP_Finish
(
struct
worker
*
w
)
{
struct
vep_state
*
vep
;
ssize_t
l
,
lcb
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
vep
=
sp
->
wrk
->
vep
;
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
vep
=
w
->
vep
;
CHECK_OBJ_NOTNULL
(
vep
,
VEP_MAGIC
);
if
(
vep
->
o_pending
)
vep_mark_common
(
vep
,
vep
->
ver_p
,
vep
->
last_mark
);
if
(
vep
->
o_wait
>
0
)
{
lcb
=
vep
->
cb
(
vep
->
sp
,
0
,
VGZ_ALIGN
);
lcb
=
vep
->
cb
(
vep
->
wrk
,
0
,
VGZ_ALIGN
);
vep_emit_common
(
vep
,
lcb
-
vep
->
o_last
,
vep
->
last_mark
);
}
(
void
)
vep
->
cb
(
vep
->
sp
,
0
,
VGZ_FINISH
);
(
void
)
vep
->
cb
(
vep
->
wrk
,
0
,
VGZ_FINISH
);
sp
->
wrk
->
vep
=
NULL
;
w
->
vep
=
NULL
;
AZ
(
VSB_finish
(
vep
->
vsb
));
l
=
VSB_len
(
vep
->
vsb
);
...
...
bin/varnishd/cache_gzip.c
View file @
9765f1a8
...
...
@@ -255,11 +255,11 @@ VGZ_ObufFull(const struct vgz *vg)
*/
int
VGZ_ObufStorage
(
const
struct
sess
*
sp
,
struct
vgz
*
vg
)
VGZ_ObufStorage
(
struct
worker
*
w
,
struct
vgz
*
vg
)
{
struct
storage
*
st
;
st
=
FetchStorage
(
sp
->
wrk
,
0
);
st
=
FetchStorage
(
w
,
0
);
if
(
st
==
NULL
)
return
(
-
1
);
...
...
@@ -466,7 +466,7 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
bytes
-=
w
;
}
if
(
VGZ_ObufStorage
(
sp
,
vg
))
{
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
{
htc
->
error
=
"Could not get storage"
;
return
(
-
1
);
}
...
...
@@ -541,7 +541,7 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
VGZ_Ibuf
(
vg
,
ibuf
,
w
);
bytes
-=
w
;
}
if
(
VGZ_ObufStorage
(
sp
,
vg
))
{
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
{
htc
->
error
=
"Could not get storage"
;
return
(
-
1
);
}
...
...
@@ -567,7 +567,7 @@ vfp_gzip_end(struct sess *sp)
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
do
{
VGZ_Ibuf
(
vg
,
""
,
0
);
if
(
VGZ_ObufStorage
(
sp
,
vg
))
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
return
(
-
1
);
i
=
VGZ_Gzip
(
vg
,
&
dp
,
&
dl
,
VGZ_FINISH
);
sp
->
obj
->
len
+=
dl
;
...
...
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