Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
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
unique-xids
Commits
3e4b8291
Commit
3e4b8291
authored
Oct 24, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Push struct session out of all the vfp's in one go.
parent
4133b274
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
202 additions
and
199 deletions
+202
-199
cache.h
bin/varnishd/cache.h
+5
-4
cache_esi_fetch.c
bin/varnishd/cache_esi_fetch.c
+101
-100
cache_fetch.c
bin/varnishd/cache_fetch.c
+31
-31
cache_gzip.c
bin/varnishd/cache_gzip.c
+65
-64
No files found.
bin/varnishd/cache.h
View file @
3e4b8291
...
@@ -110,6 +110,7 @@ struct vef_priv;
...
@@ -110,6 +110,7 @@ struct vef_priv;
struct
vrt_backend
;
struct
vrt_backend
;
struct
vsb
;
struct
vsb
;
struct
waitinglist
;
struct
waitinglist
;
struct
worker
;
#define DIGEST_LEN 32
#define DIGEST_LEN 32
...
@@ -226,9 +227,9 @@ struct dstat {
...
@@ -226,9 +227,9 @@ struct dstat {
/* Fetch processors --------------------------------------------------*/
/* Fetch processors --------------------------------------------------*/
typedef
void
vfp_begin_f
(
struct
sess
*
,
size_t
);
typedef
void
vfp_begin_f
(
struct
worker
*
,
size_t
);
typedef
int
vfp_bytes_f
(
struct
sess
*
,
struct
http_conn
*
,
ssize_t
);
typedef
int
vfp_bytes_f
(
struct
worker
*
,
struct
http_conn
*
,
ssize_t
);
typedef
int
vfp_end_f
(
struct
sess
*
sp
);
typedef
int
vfp_end_f
(
struct
worker
*
);
struct
vfp
{
struct
vfp
{
vfp_begin_f
*
begin
;
vfp_begin_f
*
begin
;
...
@@ -703,7 +704,7 @@ int EXP_NukeOne(struct worker *w, struct lru *lru);
...
@@ -703,7 +704,7 @@ int EXP_NukeOne(struct worker *w, struct lru *lru);
/* cache_fetch.c */
/* cache_fetch.c */
struct
storage
*
FetchStorage
(
struct
worker
*
w
,
ssize_t
sz
);
struct
storage
*
FetchStorage
(
struct
worker
*
w
,
ssize_t
sz
);
int
FetchHdr
(
struct
sess
*
sp
);
int
FetchHdr
(
struct
sess
*
sp
);
int
FetchBody
(
struct
sess
*
sp
,
struct
object
*
obj
);
int
FetchBody
(
const
struct
sess
*
sp
,
struct
object
*
obj
);
int
FetchReqBody
(
struct
sess
*
sp
);
int
FetchReqBody
(
struct
sess
*
sp
);
void
Fetch_Init
(
void
);
void
Fetch_Init
(
void
);
...
...
bin/varnishd/cache_esi_fetch.c
View file @
3e4b8291
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "cache.h"
#include "cache.h"
#include "cache_backend.h" // for w->vbc
#include "cache_esi.h"
#include "cache_esi.h"
/*---------------------------------------------------------------------
/*---------------------------------------------------------------------
...
@@ -62,26 +63,26 @@ vef_read(struct http_conn *htc, void *buf, ssize_t buflen, ssize_t bytes)
...
@@ -62,26 +63,26 @@ vef_read(struct http_conn *htc, void *buf, ssize_t buflen, ssize_t bytes)
* We receive a ungzip'ed object, and want to store it ungzip'ed.
* We receive a ungzip'ed object, and want to store it ungzip'ed.
*/
*/
static
int
__match_proto__
()
static
int
vfp_esi_bytes_uu
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_esi_bytes_uu
(
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
ssize_t
w
;
ssize_t
w
l
;
struct
storage
*
st
;
struct
storage
*
st
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
while
(
bytes
>
0
)
{
while
(
bytes
>
0
)
{
st
=
FetchStorage
(
sp
->
wrk
,
0
);
st
=
FetchStorage
(
w
,
0
);
if
(
st
==
NULL
)
if
(
st
==
NULL
)
return
(
-
1
);
return
(
-
1
);
w
=
vef_read
(
htc
,
w
l
=
vef_read
(
htc
,
st
->
ptr
+
st
->
len
,
st
->
space
-
st
->
len
,
bytes
);
st
->
ptr
+
st
->
len
,
st
->
space
-
st
->
len
,
bytes
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
VEP_Parse
(
sp
->
wrk
,
(
const
char
*
)
st
->
ptr
+
st
->
len
,
w
);
VEP_Parse
(
w
,
(
const
char
*
)
st
->
ptr
+
st
->
len
,
wl
);
st
->
len
+=
w
;
st
->
len
+=
w
l
;
sp
->
obj
->
len
+=
w
;
w
->
fetch_obj
->
len
+=
wl
;
bytes
-=
w
;
bytes
-=
w
l
;
}
}
return
(
1
);
return
(
1
);
}
}
...
@@ -90,33 +91,33 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -90,33 +91,33 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
* We receive a gzip'ed object, and want to store it ungzip'ed.
* We receive a gzip'ed object, and want to store it ungzip'ed.
*/
*/
static
int
__match_proto__
()
static
int
vfp_esi_bytes_gu
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_esi_bytes_gu
(
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
struct
vgz
*
vg
;
struct
vgz
*
vg
;
ssize_t
w
;
ssize_t
w
l
;
uint8_t
ibuf
[
params
->
gzip_stack_buffer
];
uint8_t
ibuf
[
params
->
gzip_stack_buffer
];
int
i
;
int
i
;
size_t
dl
;
size_t
dl
;
const
void
*
dp
;
const
void
*
dp
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
vg
=
sp
->
wrk
->
vgz_rx
;
vg
=
w
->
vgz_rx
;
while
(
bytes
>
0
)
{
while
(
bytes
>
0
)
{
if
(
VGZ_IbufEmpty
(
vg
)
&&
bytes
>
0
)
{
if
(
VGZ_IbufEmpty
(
vg
)
&&
bytes
>
0
)
{
w
=
vef_read
(
htc
,
ibuf
,
sizeof
ibuf
,
bytes
);
w
l
=
vef_read
(
htc
,
ibuf
,
sizeof
ibuf
,
bytes
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
VGZ_Ibuf
(
vg
,
ibuf
,
w
);
VGZ_Ibuf
(
vg
,
ibuf
,
w
l
);
bytes
-=
w
;
bytes
-=
w
l
;
}
}
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
if
(
VGZ_ObufStorage
(
w
,
vg
))
return
(
-
1
);
return
(
-
1
);
i
=
VGZ_Gunzip
(
vg
,
&
dp
,
&
dl
);
i
=
VGZ_Gunzip
(
vg
,
&
dp
,
&
dl
);
xxxassert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
xxxassert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
VEP_Parse
(
sp
->
wrk
,
dp
,
dl
);
VEP_Parse
(
w
,
dp
,
dl
);
sp
->
obj
->
len
+=
dl
;
w
->
fetch_
obj
->
len
+=
dl
;
}
}
return
(
1
);
return
(
1
);
}
}
...
@@ -202,34 +203,34 @@ vfp_vep_callback(struct worker *w, ssize_t l, enum vgz_flag flg)
...
@@ -202,34 +203,34 @@ vfp_vep_callback(struct worker *w, ssize_t l, enum vgz_flag flg)
return
(
vef
->
tot
);
return
(
vef
->
tot
);
}
}
static
int
__match_proto__
()
static
int
vfp_esi_bytes_ug
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_esi_bytes_ug
(
const
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
ssize_t
w
;
ssize_t
w
l
;
char
ibuf
[
params
->
gzip_stack_buffer
];
char
ibuf
[
params
->
gzip_stack_buffer
];
struct
vef_priv
*
vef
;
struct
vef_priv
*
vef
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
vef
=
sp
->
wrk
->
vef_priv
;
vef
=
w
->
vef_priv
;
CHECK_OBJ_NOTNULL
(
vef
,
VEF_MAGIC
);
CHECK_OBJ_NOTNULL
(
vef
,
VEF_MAGIC
);
while
(
bytes
>
0
)
{
while
(
bytes
>
0
)
{
w
=
vef_read
(
htc
,
ibuf
,
sizeof
ibuf
,
bytes
);
w
l
=
vef_read
(
htc
,
ibuf
,
sizeof
ibuf
,
bytes
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
bytes
-=
w
;
bytes
-=
w
l
;
vef
->
bufp
=
ibuf
;
vef
->
bufp
=
ibuf
;
VEP_Parse
(
sp
->
wrk
,
ibuf
,
w
);
VEP_Parse
(
w
,
ibuf
,
wl
);
assert
(
vef
->
bufp
>=
ibuf
&&
vef
->
bufp
<=
ibuf
+
w
);
assert
(
vef
->
bufp
>=
ibuf
&&
vef
->
bufp
<=
ibuf
+
w
l
);
if
(
vef
->
error
)
{
if
(
vef
->
error
)
{
errno
=
vef
->
error
;
errno
=
vef
->
error
;
return
(
-
1
);
return
(
-
1
);
}
}
if
(
vef
->
bufp
<
ibuf
+
w
)
{
if
(
vef
->
bufp
<
ibuf
+
w
l
)
{
w
=
(
ibuf
+
w
)
-
vef
->
bufp
;
w
l
=
(
ibuf
+
wl
)
-
vef
->
bufp
;
assert
(
w
+
vef
->
npend
<
sizeof
vef
->
pending
);
assert
(
w
l
+
vef
->
npend
<
sizeof
vef
->
pending
);
memmove
(
vef
->
pending
+
vef
->
npend
,
vef
->
bufp
,
w
);
memmove
(
vef
->
pending
+
vef
->
npend
,
vef
->
bufp
,
w
l
);
vef
->
npend
+=
w
;
vef
->
npend
+=
w
l
;
}
}
}
}
return
(
1
);
return
(
1
);
...
@@ -239,10 +240,10 @@ vfp_esi_bytes_ug(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -239,10 +240,10 @@ vfp_esi_bytes_ug(struct sess *sp, struct http_conn *htc, ssize_t bytes)
* We receive a gzip'ed object, and want to store it gzip'ed.
* We receive a gzip'ed object, and want to store it gzip'ed.
*/
*/
static
int
__match_proto__
()
static
int
vfp_esi_bytes_gg
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
size_t
bytes
)
vfp_esi_bytes_gg
(
const
struct
worker
*
w
,
struct
http_conn
*
htc
,
size_t
bytes
)
{
{
ssize_t
w
;
ssize_t
w
l
;
char
ibuf
[
params
->
gzip_stack_buffer
];
char
ibuf
[
params
->
gzip_stack_buffer
];
char
ibuf2
[
params
->
gzip_stack_buffer
];
char
ibuf2
[
params
->
gzip_stack_buffer
];
struct
vef_priv
*
vef
;
struct
vef_priv
*
vef
;
...
@@ -250,28 +251,28 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
...
@@ -250,28 +251,28 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
const
void
*
dp
;
const
void
*
dp
;
int
i
;
int
i
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
vef
=
sp
->
wrk
->
vef_priv
;
vef
=
w
->
vef_priv
;
CHECK_OBJ_NOTNULL
(
vef
,
VEF_MAGIC
);
CHECK_OBJ_NOTNULL
(
vef
,
VEF_MAGIC
);
assert
(
sizeof
ibuf
>=
1024
);
assert
(
sizeof
ibuf
>=
1024
);
ibuf2
[
0
]
=
0
;
/* For Flexelint */
ibuf2
[
0
]
=
0
;
/* For Flexelint */
while
(
bytes
>
0
)
{
while
(
bytes
>
0
)
{
w
=
vef_read
(
htc
,
ibuf
,
sizeof
ibuf
,
bytes
);
w
l
=
vef_read
(
htc
,
ibuf
,
sizeof
ibuf
,
bytes
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
bytes
-=
w
;
bytes
-=
w
l
;
vef
->
bufp
=
ibuf
;
vef
->
bufp
=
ibuf
;
VGZ_Ibuf
(
sp
->
wrk
->
vgz_rx
,
ibuf
,
w
);
VGZ_Ibuf
(
w
->
vgz_rx
,
ibuf
,
wl
);
do
{
do
{
VGZ_Obuf
(
sp
->
wrk
->
vgz_rx
,
ibuf2
,
sizeof
ibuf2
);
VGZ_Obuf
(
w
->
vgz_rx
,
ibuf2
,
sizeof
ibuf2
);
i
=
VGZ_Gunzip
(
sp
->
wrk
->
vgz_rx
,
&
dp
,
&
dl
);
i
=
VGZ_Gunzip
(
w
->
vgz_rx
,
&
dp
,
&
dl
);
/* XXX: check i */
/* XXX: check i */
assert
(
i
>=
VGZ_OK
);
assert
(
i
>=
VGZ_OK
);
vef
->
bufp
=
ibuf2
;
vef
->
bufp
=
ibuf2
;
if
(
dl
>
0
)
if
(
dl
>
0
)
VEP_Parse
(
sp
->
wrk
,
ibuf2
,
dl
);
VEP_Parse
(
w
,
ibuf2
,
dl
);
if
(
vef
->
error
)
{
if
(
vef
->
error
)
{
errno
=
vef
->
error
;
errno
=
vef
->
error
;
return
(
-
1
);
return
(
-
1
);
...
@@ -283,7 +284,7 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
...
@@ -283,7 +284,7 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
vef
->
bufp
,
dl
);
vef
->
bufp
,
dl
);
vef
->
npend
+=
dl
;
vef
->
npend
+=
dl
;
}
}
}
while
(
!
VGZ_IbufEmpty
(
sp
->
wrk
->
vgz_rx
));
}
while
(
!
VGZ_IbufEmpty
(
w
->
vgz_rx
));
}
}
return
(
1
);
return
(
1
);
}
}
...
@@ -292,96 +293,96 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
...
@@ -292,96 +293,96 @@ vfp_esi_bytes_gg(struct sess *sp, struct http_conn *htc, size_t bytes)
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
static
void
__match_proto__
()
static
void
__match_proto__
()
vfp_esi_begin
(
struct
sess
*
sp
,
size_t
estimate
)
vfp_esi_begin
(
struct
worker
*
w
,
size_t
estimate
)
{
{
struct
vef_priv
*
vef
;
struct
vef_priv
*
vef
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
/* XXX: snapshot WS's ? We'll need the space */
/* XXX: snapshot WS's ? We'll need the space */
AZ
(
sp
->
wrk
->
vgz_rx
);
AZ
(
w
->
vgz_rx
);
if
(
sp
->
wrk
->
is_gzip
&&
sp
->
wrk
->
do_gunzip
)
{
if
(
w
->
is_gzip
&&
w
->
do_gunzip
)
{
sp
->
wrk
->
vgz_rx
=
VGZ_NewUngzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"U F E"
);
w
->
vgz_rx
=
VGZ_NewUngzip
(
w
,
w
->
vbc
->
vsl_id
,
"U F E"
);
VEP_Init
(
sp
->
wrk
,
NULL
);
VEP_Init
(
w
,
NULL
);
}
else
if
(
sp
->
wrk
->
is_gunzip
&&
sp
->
wrk
->
do_gzip
)
{
}
else
if
(
w
->
is_gunzip
&&
w
->
do_gzip
)
{
ALLOC_OBJ
(
vef
,
VEF_MAGIC
);
ALLOC_OBJ
(
vef
,
VEF_MAGIC
);
AN
(
vef
);
AN
(
vef
);
//vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
//vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
//memset(vef, 0, sizeof *vef);
//memset(vef, 0, sizeof *vef);
//vef->magic = VEF_MAGIC;
//vef->magic = VEF_MAGIC;
vef
->
vgz
=
VGZ_NewGzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"G F E"
);
vef
->
vgz
=
VGZ_NewGzip
(
w
,
w
->
vbc
->
vsl_id
,
"G F E"
);
AZ
(
sp
->
wrk
->
vef_priv
);
AZ
(
w
->
vef_priv
);
sp
->
wrk
->
vef_priv
=
vef
;
w
->
vef_priv
=
vef
;
VEP_Init
(
sp
->
wrk
,
vfp_vep_callback
);
VEP_Init
(
w
,
vfp_vep_callback
);
}
else
if
(
sp
->
wrk
->
is_gzip
)
{
}
else
if
(
w
->
is_gzip
)
{
sp
->
wrk
->
vgz_rx
=
VGZ_NewUngzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"U F E"
);
w
->
vgz_rx
=
VGZ_NewUngzip
(
w
,
w
->
vbc
->
vsl_id
,
"U F E"
);
ALLOC_OBJ
(
vef
,
VEF_MAGIC
);
ALLOC_OBJ
(
vef
,
VEF_MAGIC
);
AN
(
vef
);
AN
(
vef
);
//vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
//vef = (void*)WS_Alloc(sp->ws, sizeof *vef);
//memset(vef, 0, sizeof *vef);
//memset(vef, 0, sizeof *vef);
//vef->magic = VEF_MAGIC;
//vef->magic = VEF_MAGIC;
vef
->
vgz
=
VGZ_NewGzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"G F E"
);
vef
->
vgz
=
VGZ_NewGzip
(
w
,
w
->
vbc
->
vsl_id
,
"G F E"
);
AZ
(
sp
->
wrk
->
vef_priv
);
AZ
(
w
->
vef_priv
);
sp
->
wrk
->
vef_priv
=
vef
;
w
->
vef_priv
=
vef
;
VEP_Init
(
sp
->
wrk
,
vfp_vep_callback
);
VEP_Init
(
w
,
vfp_vep_callback
);
}
else
{
}
else
{
AZ
(
sp
->
wrk
->
vef_priv
);
AZ
(
w
->
vef_priv
);
VEP_Init
(
sp
->
wrk
,
NULL
);
VEP_Init
(
w
,
NULL
);
}
}
(
void
)
estimate
;
(
void
)
estimate
;
AN
(
sp
->
wrk
->
vep
);
AN
(
w
->
vep
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_esi_bytes
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_esi_bytes
(
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
int
i
;
int
i
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
AN
(
sp
->
wrk
->
vep
);
AN
(
w
->
vep
);
if
(
sp
->
wrk
->
is_gzip
&&
sp
->
wrk
->
do_gunzip
)
if
(
w
->
is_gzip
&&
w
->
do_gunzip
)
i
=
vfp_esi_bytes_gu
(
sp
,
htc
,
bytes
);
i
=
vfp_esi_bytes_gu
(
w
,
htc
,
bytes
);
else
if
(
sp
->
wrk
->
is_gunzip
&&
sp
->
wrk
->
do_gzip
)
else
if
(
w
->
is_gunzip
&&
w
->
do_gzip
)
i
=
vfp_esi_bytes_ug
(
sp
,
htc
,
bytes
);
i
=
vfp_esi_bytes_ug
(
w
,
htc
,
bytes
);
else
if
(
sp
->
wrk
->
is_gzip
)
else
if
(
w
->
is_gzip
)
i
=
vfp_esi_bytes_gg
(
sp
,
htc
,
bytes
);
i
=
vfp_esi_bytes_gg
(
w
,
htc
,
bytes
);
else
else
i
=
vfp_esi_bytes_uu
(
sp
,
htc
,
bytes
);
i
=
vfp_esi_bytes_uu
(
w
,
htc
,
bytes
);
AN
(
sp
->
wrk
->
vep
);
AN
(
w
->
vep
);
return
(
i
);
return
(
i
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_esi_end
(
struct
sess
*
sp
)
vfp_esi_end
(
struct
worker
*
w
)
{
{
struct
vsb
*
vsb
;
struct
vsb
*
vsb
;
struct
vef_priv
*
vef
;
struct
vef_priv
*
vef
;
ssize_t
l
;
ssize_t
l
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS
_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
,
WORKER
_MAGIC
);
AN
(
sp
->
wrk
->
vep
);
AN
(
w
->
vep
);
vsb
=
VEP_Finish
(
sp
->
wrk
);
vsb
=
VEP_Finish
(
w
);
if
(
vsb
!=
NULL
)
{
if
(
vsb
!=
NULL
)
{
l
=
VSB_len
(
vsb
);
l
=
VSB_len
(
vsb
);
assert
(
l
>
0
);
assert
(
l
>
0
);
/* XXX: This is a huge waste of storage... */
/* XXX: This is a huge waste of storage... */
sp
->
obj
->
esidata
=
STV_alloc
(
sp
->
wrk
,
l
);
w
->
fetch_obj
->
esidata
=
STV_alloc
(
w
,
l
);
XXXAN
(
sp
->
obj
->
esidata
);
XXXAN
(
w
->
fetch_
obj
->
esidata
);
memcpy
(
sp
->
obj
->
esidata
->
ptr
,
VSB_data
(
vsb
),
l
);
memcpy
(
w
->
fetch_
obj
->
esidata
->
ptr
,
VSB_data
(
vsb
),
l
);
sp
->
obj
->
esidata
->
len
=
l
;
w
->
fetch_
obj
->
esidata
->
len
=
l
;
VSB_delete
(
vsb
);
VSB_delete
(
vsb
);
}
}
if
(
sp
->
wrk
->
vgz_rx
!=
NULL
)
if
(
w
->
vgz_rx
!=
NULL
)
VGZ_Destroy
(
&
sp
->
wrk
->
vgz_rx
);
VGZ_Destroy
(
&
w
->
vgz_rx
);
if
(
sp
->
wrk
->
vef_priv
!=
NULL
)
{
if
(
w
->
vef_priv
!=
NULL
)
{
vef
=
sp
->
wrk
->
vef_priv
;
vef
=
w
->
vef_priv
;
CHECK_OBJ_NOTNULL
(
vef
,
VEF_MAGIC
);
CHECK_OBJ_NOTNULL
(
vef
,
VEF_MAGIC
);
sp
->
wrk
->
vef_priv
=
NULL
;
w
->
vef_priv
=
NULL
;
VGZ_UpdateObj
(
vef
->
vgz
,
sp
->
obj
);
VGZ_UpdateObj
(
vef
->
vgz
,
w
->
fetch_
obj
);
VGZ_Destroy
(
&
vef
->
vgz
);
VGZ_Destroy
(
&
vef
->
vgz
);
XXXAZ
(
vef
->
error
);
XXXAZ
(
vef
->
error
);
FREE_OBJ
(
vef
);
FREE_OBJ
(
vef
);
...
...
bin/varnishd/cache_fetch.c
View file @
3e4b8291
...
@@ -58,15 +58,15 @@ static unsigned fetchfrag;
...
@@ -58,15 +58,15 @@ static unsigned fetchfrag;
* as seen on the socket, or zero if unknown.
* as seen on the socket, or zero if unknown.
*/
*/
static
void
__match_proto__
()
static
void
__match_proto__
()
vfp_nop_begin
(
struct
sess
*
sp
,
size_t
estimate
)
vfp_nop_begin
(
struct
worker
*
w
,
size_t
estimate
)
{
{
if
(
fetchfrag
>
0
)
{
if
(
fetchfrag
>
0
)
{
estimate
=
fetchfrag
;
estimate
=
fetchfrag
;
WS
P
(
sp
,
SLT_Debug
,
"Fetch %d byte segments:"
,
fetchfrag
);
WS
LB
(
w
,
SLT_Debug
,
"Fetch %d byte segments:"
,
fetchfrag
);
}
}
if
(
estimate
>
0
)
if
(
estimate
>
0
)
(
void
)
FetchStorage
(
sp
->
wrk
,
estimate
);
(
void
)
FetchStorage
(
w
,
estimate
);
}
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
...
@@ -80,13 +80,13 @@ vfp_nop_begin(struct sess *sp, size_t estimate)
...
@@ -80,13 +80,13 @@ vfp_nop_begin(struct sess *sp, size_t estimate)
*/
*/
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_nop_bytes
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_nop_bytes
(
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
ssize_t
l
,
w
;
ssize_t
l
,
w
l
;
struct
storage
*
st
;
struct
storage
*
st
;
while
(
bytes
>
0
)
{
while
(
bytes
>
0
)
{
st
=
FetchStorage
(
sp
->
wrk
,
0
);
st
=
FetchStorage
(
w
,
0
);
if
(
st
==
NULL
)
{
if
(
st
==
NULL
)
{
htc
->
error
=
"Could not get storage"
;
htc
->
error
=
"Could not get storage"
;
return
(
-
1
);
return
(
-
1
);
...
@@ -94,14 +94,14 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -94,14 +94,14 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
l
=
st
->
space
-
st
->
len
;
l
=
st
->
space
-
st
->
len
;
if
(
l
>
bytes
)
if
(
l
>
bytes
)
l
=
bytes
;
l
=
bytes
;
w
=
HTC_Read
(
htc
,
st
->
ptr
+
st
->
len
,
l
);
w
l
=
HTC_Read
(
htc
,
st
->
ptr
+
st
->
len
,
l
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
st
->
len
+=
w
;
st
->
len
+=
w
l
;
sp
->
obj
->
len
+=
w
;
w
->
fetch_obj
->
len
+=
wl
;
bytes
-=
w
;
bytes
-=
w
l
;
if
(
sp
->
wrk
->
do_stream
)
if
(
w
->
do_stream
)
RES_StreamPoll
(
sp
->
wrk
);
RES_StreamPoll
(
w
);
}
}
return
(
1
);
return
(
1
);
}
}
...
@@ -116,16 +116,16 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -116,16 +116,16 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
*/
*/
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_nop_end
(
struct
sess
*
sp
)
vfp_nop_end
(
struct
worker
*
w
)
{
{
struct
storage
*
st
;
struct
storage
*
st
;
st
=
VTAILQ_LAST
(
&
sp
->
obj
->
store
,
storagehead
);
st
=
VTAILQ_LAST
(
&
w
->
fetch_
obj
->
store
,
storagehead
);
if
(
st
==
NULL
)
if
(
st
==
NULL
)
return
(
0
);
return
(
0
);
if
(
st
->
len
==
0
)
{
if
(
st
->
len
==
0
)
{
VTAILQ_REMOVE
(
&
sp
->
obj
->
store
,
st
,
list
);
VTAILQ_REMOVE
(
&
w
->
fetch_
obj
->
store
,
st
,
list
);
STV_free
(
st
);
STV_free
(
st
);
return
(
0
);
return
(
0
);
}
}
...
@@ -198,7 +198,7 @@ fetch_number(const char *nbr, int radix)
...
@@ -198,7 +198,7 @@ fetch_number(const char *nbr, int radix)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
int
static
int
fetch_straight
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
const
char
*
b
)
fetch_straight
(
const
struct
sess
*
sp
,
struct
http_conn
*
htc
,
const
char
*
b
)
{
{
int
i
;
int
i
;
ssize_t
cl
;
ssize_t
cl
;
...
@@ -206,14 +206,14 @@ fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
...
@@ -206,14 +206,14 @@ fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
assert
(
sp
->
wrk
->
body_status
==
BS_LENGTH
);
assert
(
sp
->
wrk
->
body_status
==
BS_LENGTH
);
cl
=
fetch_number
(
b
,
10
);
cl
=
fetch_number
(
b
,
10
);
sp
->
wrk
->
vfp
->
begin
(
sp
,
cl
>
0
?
cl
:
0
);
sp
->
wrk
->
vfp
->
begin
(
sp
->
wrk
,
cl
>
0
?
cl
:
0
);
if
(
cl
<
0
)
{
if
(
cl
<
0
)
{
WSP
(
sp
,
SLT_FetchError
,
"straight length field bogus"
);
WSP
(
sp
,
SLT_FetchError
,
"straight length field bogus"
);
return
(
-
1
);
return
(
-
1
);
}
else
if
(
cl
==
0
)
}
else
if
(
cl
==
0
)
return
(
0
);
return
(
0
);
i
=
sp
->
wrk
->
vfp
->
bytes
(
sp
,
htc
,
cl
);
i
=
sp
->
wrk
->
vfp
->
bytes
(
sp
->
wrk
,
htc
,
cl
);
if
(
i
<=
0
)
{
if
(
i
<=
0
)
{
WSP
(
sp
,
SLT_FetchError
,
"straight read_error: %d %d (%s)"
,
WSP
(
sp
,
SLT_FetchError
,
"straight read_error: %d %d (%s)"
,
i
,
errno
,
htc
->
error
);
i
,
errno
,
htc
->
error
);
...
@@ -235,14 +235,14 @@ fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
...
@@ -235,14 +235,14 @@ fetch_straight(struct sess *sp, struct http_conn *htc, const char *b)
} while (0)
} while (0)
static
int
static
int
fetch_chunked
(
struct
sess
*
sp
,
struct
http_conn
*
htc
)
fetch_chunked
(
const
struct
sess
*
sp
,
struct
http_conn
*
htc
)
{
{
int
i
;
int
i
;
char
buf
[
20
];
/* XXX: 20 is arbitrary */
char
buf
[
20
];
/* XXX: 20 is arbitrary */
unsigned
u
;
unsigned
u
;
ssize_t
cl
;
ssize_t
cl
;
sp
->
wrk
->
vfp
->
begin
(
sp
,
0
);
sp
->
wrk
->
vfp
->
begin
(
sp
->
wrk
,
0
);
assert
(
sp
->
wrk
->
body_status
==
BS_CHUNKED
);
assert
(
sp
->
wrk
->
body_status
==
BS_CHUNKED
);
do
{
do
{
/* Skip leading whitespace */
/* Skip leading whitespace */
...
@@ -283,7 +283,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
...
@@ -283,7 +283,7 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
WSP
(
sp
,
SLT_FetchError
,
"chunked header nbr syntax"
);
WSP
(
sp
,
SLT_FetchError
,
"chunked header nbr syntax"
);
return
(
-
1
);
return
(
-
1
);
}
else
if
(
cl
>
0
)
{
}
else
if
(
cl
>
0
)
{
i
=
sp
->
wrk
->
vfp
->
bytes
(
sp
,
htc
,
cl
);
i
=
sp
->
wrk
->
vfp
->
bytes
(
sp
->
wrk
,
htc
,
cl
);
CERR
();
CERR
();
}
}
i
=
HTC_Read
(
htc
,
buf
,
1
);
i
=
HTC_Read
(
htc
,
buf
,
1
);
...
@@ -305,13 +305,13 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
...
@@ -305,13 +305,13 @@ fetch_chunked(struct sess *sp, struct http_conn *htc)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
static
int
static
int
fetch_eof
(
struct
sess
*
sp
,
struct
http_conn
*
htc
)
fetch_eof
(
const
struct
sess
*
sp
,
struct
http_conn
*
htc
)
{
{
int
i
;
int
i
;
assert
(
sp
->
wrk
->
body_status
==
BS_EOF
);
assert
(
sp
->
wrk
->
body_status
==
BS_EOF
);
sp
->
wrk
->
vfp
->
begin
(
sp
,
0
);
sp
->
wrk
->
vfp
->
begin
(
sp
->
wrk
,
0
);
i
=
sp
->
wrk
->
vfp
->
bytes
(
sp
,
htc
,
SSIZE_MAX
);
i
=
sp
->
wrk
->
vfp
->
bytes
(
sp
->
wrk
,
htc
,
SSIZE_MAX
);
if
(
i
<
0
)
{
if
(
i
<
0
)
{
WSP
(
sp
,
SLT_FetchError
,
"eof read_error: %d (%s)"
,
WSP
(
sp
,
SLT_FetchError
,
"eof read_error: %d (%s)"
,
errno
,
htc
->
error
);
errno
,
htc
->
error
);
...
@@ -480,7 +480,7 @@ FetchHdr(struct sess *sp)
...
@@ -480,7 +480,7 @@ FetchHdr(struct sess *sp)
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
int
int
FetchBody
(
struct
sess
*
sp
,
struct
object
*
obj
)
FetchBody
(
const
struct
sess
*
sp
,
struct
object
*
obj
)
{
{
int
cls
;
int
cls
;
struct
storage
*
st
;
struct
storage
*
st
;
...
@@ -518,17 +518,17 @@ FetchBody(struct sess *sp, struct object *obj)
...
@@ -518,17 +518,17 @@ FetchBody(struct sess *sp, struct object *obj)
cls
=
fetch_straight
(
sp
,
w
->
htc
,
cls
=
fetch_straight
(
sp
,
w
->
htc
,
w
->
h_content_length
);
w
->
h_content_length
);
mklen
=
1
;
mklen
=
1
;
XXXAZ
(
w
->
vfp
->
end
(
sp
));
XXXAZ
(
w
->
vfp
->
end
(
sp
->
wrk
));
break
;
break
;
case
BS_CHUNKED
:
case
BS_CHUNKED
:
cls
=
fetch_chunked
(
sp
,
w
->
htc
);
cls
=
fetch_chunked
(
sp
,
w
->
htc
);
mklen
=
1
;
mklen
=
1
;
XXXAZ
(
w
->
vfp
->
end
(
sp
));
XXXAZ
(
w
->
vfp
->
end
(
sp
->
wrk
));
break
;
break
;
case
BS_EOF
:
case
BS_EOF
:
cls
=
fetch_eof
(
sp
,
w
->
htc
);
cls
=
fetch_eof
(
sp
,
w
->
htc
);
mklen
=
1
;
mklen
=
1
;
XXXAZ
(
w
->
vfp
->
end
(
sp
));
XXXAZ
(
w
->
vfp
->
end
(
sp
->
wrk
));
break
;
break
;
case
BS_ERROR
:
case
BS_ERROR
:
cls
=
1
;
cls
=
1
;
...
@@ -546,7 +546,7 @@ FetchBody(struct sess *sp, struct object *obj)
...
@@ -546,7 +546,7 @@ FetchBody(struct sess *sp, struct object *obj)
* sitting on w->storage, we will always call vfp_nop_end()
* sitting on w->storage, we will always call vfp_nop_end()
* to get it trimmed or thrown out if empty.
* to get it trimmed or thrown out if empty.
*/
*/
AZ
(
vfp_nop_end
(
sp
));
AZ
(
vfp_nop_end
(
sp
->
wrk
));
w
->
fetch_obj
=
NULL
;
w
->
fetch_obj
=
NULL
;
...
...
bin/varnishd/cache_gzip.c
View file @
3e4b8291
...
@@ -71,6 +71,7 @@
...
@@ -71,6 +71,7 @@
#include "cache.h"
#include "cache.h"
#include "cache_backend.h" // for w->vbc
#include "vgz.h"
#include "vgz.h"
struct
vgz
{
struct
vgz
{
...
@@ -434,24 +435,24 @@ VGZ_Destroy(struct vgz **vgp)
...
@@ -434,24 +435,24 @@ VGZ_Destroy(struct vgz **vgp)
*/
*/
static
void
__match_proto__
()
static
void
__match_proto__
()
vfp_gunzip_begin
(
struct
sess
*
sp
,
size_t
estimate
)
vfp_gunzip_begin
(
struct
worker
*
w
,
size_t
estimate
)
{
{
(
void
)
estimate
;
(
void
)
estimate
;
AZ
(
sp
->
wrk
->
vgz_rx
);
AZ
(
w
->
vgz_rx
);
sp
->
wrk
->
vgz_rx
=
VGZ_NewUngzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"U F -"
);
w
->
vgz_rx
=
VGZ_NewUngzip
(
w
,
w
->
vbc
->
vsl_id
,
"U F -"
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_gunzip_bytes
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_gunzip_bytes
(
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
struct
vgz
*
vg
;
struct
vgz
*
vg
;
ssize_t
l
,
w
;
ssize_t
l
,
w
l
;
int
i
=
-
100
;
int
i
=
-
100
;
uint8_t
ibuf
[
params
->
gzip_stack_buffer
];
uint8_t
ibuf
[
params
->
gzip_stack_buffer
];
size_t
dl
;
size_t
dl
;
const
void
*
dp
;
const
void
*
dp
;
vg
=
sp
->
wrk
->
vgz_rx
;
vg
=
w
->
vgz_rx
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
AZ
(
vg
->
vz
.
avail_in
);
AZ
(
vg
->
vz
.
avail_in
);
while
(
bytes
>
0
||
vg
->
vz
.
avail_in
>
0
)
{
while
(
bytes
>
0
||
vg
->
vz
.
avail_in
>
0
)
{
...
@@ -459,37 +460,37 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -459,37 +460,37 @@ vfp_gunzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
l
=
sizeof
ibuf
;
l
=
sizeof
ibuf
;
if
(
l
>
bytes
)
if
(
l
>
bytes
)
l
=
bytes
;
l
=
bytes
;
w
=
HTC_Read
(
htc
,
ibuf
,
l
);
w
l
=
HTC_Read
(
htc
,
ibuf
,
l
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
VGZ_Ibuf
(
vg
,
ibuf
,
w
);
VGZ_Ibuf
(
vg
,
ibuf
,
w
l
);
bytes
-=
w
;
bytes
-=
w
l
;
}
}
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
{
if
(
VGZ_ObufStorage
(
w
,
vg
))
{
htc
->
error
=
"Could not get storage"
;
htc
->
error
=
"Could not get storage"
;
return
(
-
1
);
return
(
-
1
);
}
}
i
=
VGZ_Gunzip
(
vg
,
&
dp
,
&
dl
);
i
=
VGZ_Gunzip
(
vg
,
&
dp
,
&
dl
);
assert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
assert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
sp
->
obj
->
len
+=
dl
;
w
->
fetch_
obj
->
len
+=
dl
;
if
(
sp
->
wrk
->
do_stream
)
if
(
w
->
do_stream
)
RES_StreamPoll
(
sp
->
wrk
);
RES_StreamPoll
(
w
);
}
}
if
(
i
==
Z_OK
||
i
==
Z_STREAM_END
)
if
(
i
==
Z_OK
||
i
==
Z_STREAM_END
)
return
(
1
);
return
(
1
);
htc
->
error
=
"See other message"
;
htc
->
error
=
"See other message"
;
WS
P
(
sp
,
SLT_FetchError
,
"Gunzip trouble (%d)"
,
i
);
WS
LB
(
w
,
SLT_FetchError
,
"Gunzip trouble (%d)"
,
i
);
return
(
-
1
);
return
(
-
1
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_gunzip_end
(
struct
sess
*
sp
)
vfp_gunzip_end
(
struct
worker
*
w
)
{
{
struct
vgz
*
vg
;
struct
vgz
*
vg
;
vg
=
sp
->
wrk
->
vgz_rx
;
vg
=
w
->
vgz_rx
;
sp
->
wrk
->
vgz_rx
=
NULL
;
w
->
vgz_rx
=
NULL
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
VGZ_Destroy
(
&
vg
);
VGZ_Destroy
(
&
vg
);
return
(
0
);
return
(
0
);
...
@@ -509,25 +510,25 @@ struct vfp vfp_gunzip = {
...
@@ -509,25 +510,25 @@ struct vfp vfp_gunzip = {
*/
*/
static
void
__match_proto__
()
static
void
__match_proto__
()
vfp_gzip_begin
(
struct
sess
*
sp
,
size_t
estimate
)
vfp_gzip_begin
(
struct
worker
*
w
,
size_t
estimate
)
{
{
(
void
)
estimate
;
(
void
)
estimate
;
AZ
(
sp
->
wrk
->
vgz_rx
);
AZ
(
w
->
vgz_rx
);
sp
->
wrk
->
vgz_rx
=
VGZ_NewGzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"G F -"
);
w
->
vgz_rx
=
VGZ_NewGzip
(
w
,
w
->
vbc
->
vsl_id
,
"G F -"
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_gzip_bytes
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_gzip_bytes
(
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
struct
vgz
*
vg
;
struct
vgz
*
vg
;
ssize_t
l
,
w
;
ssize_t
l
,
w
l
;
int
i
=
-
100
;
int
i
=
-
100
;
uint8_t
ibuf
[
params
->
gzip_stack_buffer
];
uint8_t
ibuf
[
params
->
gzip_stack_buffer
];
size_t
dl
;
size_t
dl
;
const
void
*
dp
;
const
void
*
dp
;
vg
=
sp
->
wrk
->
vgz_rx
;
vg
=
w
->
vgz_rx
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
AZ
(
vg
->
vz
.
avail_in
);
AZ
(
vg
->
vz
.
avail_in
);
while
(
bytes
>
0
||
!
VGZ_IbufEmpty
(
vg
))
{
while
(
bytes
>
0
||
!
VGZ_IbufEmpty
(
vg
))
{
...
@@ -535,46 +536,46 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -535,46 +536,46 @@ vfp_gzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
l
=
sizeof
ibuf
;
l
=
sizeof
ibuf
;
if
(
l
>
bytes
)
if
(
l
>
bytes
)
l
=
bytes
;
l
=
bytes
;
w
=
HTC_Read
(
htc
,
ibuf
,
l
);
w
l
=
HTC_Read
(
htc
,
ibuf
,
l
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
VGZ_Ibuf
(
vg
,
ibuf
,
w
);
VGZ_Ibuf
(
vg
,
ibuf
,
w
l
);
bytes
-=
w
;
bytes
-=
w
l
;
}
}
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
{
if
(
VGZ_ObufStorage
(
w
,
vg
))
{
htc
->
error
=
"Could not get storage"
;
htc
->
error
=
"Could not get storage"
;
return
(
-
1
);
return
(
-
1
);
}
}
i
=
VGZ_Gzip
(
vg
,
&
dp
,
&
dl
,
VGZ_NORMAL
);
i
=
VGZ_Gzip
(
vg
,
&
dp
,
&
dl
,
VGZ_NORMAL
);
assert
(
i
==
Z_OK
);
assert
(
i
==
Z_OK
);
sp
->
obj
->
len
+=
dl
;
w
->
fetch_
obj
->
len
+=
dl
;
if
(
sp
->
wrk
->
do_stream
)
if
(
w
->
do_stream
)
RES_StreamPoll
(
sp
->
wrk
);
RES_StreamPoll
(
w
);
}
}
return
(
1
);
return
(
1
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_gzip_end
(
struct
sess
*
sp
)
vfp_gzip_end
(
struct
worker
*
w
)
{
{
struct
vgz
*
vg
;
struct
vgz
*
vg
;
size_t
dl
;
size_t
dl
;
const
void
*
dp
;
const
void
*
dp
;
int
i
;
int
i
;
vg
=
sp
->
wrk
->
vgz_rx
;
vg
=
w
->
vgz_rx
;
sp
->
wrk
->
vgz_rx
=
NULL
;
w
->
vgz_rx
=
NULL
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
do
{
do
{
VGZ_Ibuf
(
vg
,
""
,
0
);
VGZ_Ibuf
(
vg
,
""
,
0
);
if
(
VGZ_ObufStorage
(
sp
->
wrk
,
vg
))
if
(
VGZ_ObufStorage
(
w
,
vg
))
return
(
-
1
);
return
(
-
1
);
i
=
VGZ_Gzip
(
vg
,
&
dp
,
&
dl
,
VGZ_FINISH
);
i
=
VGZ_Gzip
(
vg
,
&
dp
,
&
dl
,
VGZ_FINISH
);
sp
->
obj
->
len
+=
dl
;
w
->
fetch_
obj
->
len
+=
dl
;
}
while
(
i
!=
Z_STREAM_END
);
}
while
(
i
!=
Z_STREAM_END
);
if
(
sp
->
wrk
->
do_stream
)
if
(
w
->
do_stream
)
RES_StreamPoll
(
sp
->
wrk
);
RES_StreamPoll
(
w
);
VGZ_UpdateObj
(
vg
,
sp
->
obj
);
VGZ_UpdateObj
(
vg
,
w
->
fetch_
obj
);
VGZ_Destroy
(
&
vg
);
VGZ_Destroy
(
&
vg
);
return
(
0
);
return
(
0
);
}
}
...
@@ -593,29 +594,29 @@ struct vfp vfp_gzip = {
...
@@ -593,29 +594,29 @@ struct vfp vfp_gzip = {
*/
*/
static
void
__match_proto__
()
static
void
__match_proto__
()
vfp_testgzip_begin
(
struct
sess
*
sp
,
size_t
estimate
)
vfp_testgzip_begin
(
struct
worker
*
w
,
size_t
estimate
)
{
{
(
void
)
estimate
;
(
void
)
estimate
;
sp
->
wrk
->
vgz_rx
=
VGZ_NewUngzip
(
sp
->
wrk
,
sp
->
vsl_id
,
"u F -"
);
w
->
vgz_rx
=
VGZ_NewUngzip
(
w
,
w
->
vbc
->
vsl_id
,
"u F -"
);
CHECK_OBJ_NOTNULL
(
sp
->
wrk
->
vgz_rx
,
VGZ_MAGIC
);
CHECK_OBJ_NOTNULL
(
w
->
vgz_rx
,
VGZ_MAGIC
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_testgzip_bytes
(
struct
sess
*
sp
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
vfp_testgzip_bytes
(
struct
worker
*
w
,
struct
http_conn
*
htc
,
ssize_t
bytes
)
{
{
struct
vgz
*
vg
;
struct
vgz
*
vg
;
ssize_t
l
,
w
;
ssize_t
l
,
w
l
;
int
i
=
-
100
;
int
i
=
-
100
;
uint8_t
obuf
[
params
->
gzip_stack_buffer
];
uint8_t
obuf
[
params
->
gzip_stack_buffer
];
size_t
dl
;
size_t
dl
;
const
void
*
dp
;
const
void
*
dp
;
struct
storage
*
st
;
struct
storage
*
st
;
vg
=
sp
->
wrk
->
vgz_rx
;
vg
=
w
->
vgz_rx
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
AZ
(
vg
->
vz
.
avail_in
);
AZ
(
vg
->
vz
.
avail_in
);
while
(
bytes
>
0
)
{
while
(
bytes
>
0
)
{
st
=
FetchStorage
(
sp
->
wrk
,
0
);
st
=
FetchStorage
(
w
,
0
);
if
(
st
==
NULL
)
{
if
(
st
==
NULL
)
{
htc
->
error
=
"Could not get storage"
;
htc
->
error
=
"Could not get storage"
;
return
(
-
1
);
return
(
-
1
);
...
@@ -623,15 +624,15 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -623,15 +624,15 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
l
=
st
->
space
-
st
->
len
;
l
=
st
->
space
-
st
->
len
;
if
(
l
>
bytes
)
if
(
l
>
bytes
)
l
=
bytes
;
l
=
bytes
;
w
=
HTC_Read
(
htc
,
st
->
ptr
+
st
->
len
,
l
);
w
l
=
HTC_Read
(
htc
,
st
->
ptr
+
st
->
len
,
l
);
if
(
w
<=
0
)
if
(
w
l
<=
0
)
return
(
w
);
return
(
w
l
);
bytes
-=
w
;
bytes
-=
w
l
;
VGZ_Ibuf
(
vg
,
st
->
ptr
+
st
->
len
,
w
);
VGZ_Ibuf
(
vg
,
st
->
ptr
+
st
->
len
,
w
l
);
st
->
len
+=
w
;
st
->
len
+=
w
l
;
sp
->
obj
->
len
+=
w
;
w
->
fetch_obj
->
len
+=
wl
;
if
(
sp
->
wrk
->
do_stream
)
if
(
w
->
do_stream
)
RES_StreamPoll
(
sp
->
wrk
);
RES_StreamPoll
(
w
);
while
(
!
VGZ_IbufEmpty
(
vg
))
{
while
(
!
VGZ_IbufEmpty
(
vg
))
{
VGZ_Obuf
(
vg
,
obuf
,
sizeof
obuf
);
VGZ_Obuf
(
vg
,
obuf
,
sizeof
obuf
);
...
@@ -642,7 +643,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -642,7 +643,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
}
}
if
(
i
!=
VGZ_OK
&&
i
!=
VGZ_END
)
{
if
(
i
!=
VGZ_OK
&&
i
!=
VGZ_END
)
{
htc
->
error
=
"See other message"
;
htc
->
error
=
"See other message"
;
WS
P
(
sp
,
SLT_FetchError
,
WS
LB
(
w
,
SLT_FetchError
,
"Invalid Gzip data: %s"
,
vg
->
vz
.
msg
);
"Invalid Gzip data: %s"
,
vg
->
vz
.
msg
);
return
(
-
1
);
return
(
-
1
);
}
}
...
@@ -651,19 +652,19 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
...
@@ -651,19 +652,19 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
if
(
i
==
VGZ_OK
||
i
==
VGZ_END
)
if
(
i
==
VGZ_OK
||
i
==
VGZ_END
)
return
(
1
);
return
(
1
);
htc
->
error
=
"See other message"
;
htc
->
error
=
"See other message"
;
WS
P
(
sp
,
SLT_FetchError
,
"Gunzip trouble (%d)"
,
i
);
WS
LB
(
w
,
SLT_FetchError
,
"Gunzip trouble (%d)"
,
i
);
return
(
-
1
);
return
(
-
1
);
}
}
static
int
__match_proto__
()
static
int
__match_proto__
()
vfp_testgzip_end
(
struct
sess
*
sp
)
vfp_testgzip_end
(
struct
worker
*
w
)
{
{
struct
vgz
*
vg
;
struct
vgz
*
vg
;
vg
=
sp
->
wrk
->
vgz_rx
;
vg
=
w
->
vgz_rx
;
sp
->
wrk
->
vgz_rx
=
NULL
;
w
->
vgz_rx
=
NULL
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
VGZ_UpdateObj
(
vg
,
sp
->
obj
);
VGZ_UpdateObj
(
vg
,
w
->
fetch_
obj
);
VGZ_Destroy
(
&
vg
);
VGZ_Destroy
(
&
vg
);
return
(
0
);
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