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
4fac23da
Commit
4fac23da
authored
Mar 29, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify the task of gunzip'ing a chunk of data and putting it in
a buf to be flushed to WRW.
parent
9434db57
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
28 deletions
+49
-28
cache.h
bin/varnishd/cache.h
+2
-0
cache_esi_deliver.c
bin/varnishd/cache_esi_deliver.c
+3
-15
cache_gzip.c
bin/varnishd/cache_gzip.c
+34
-0
cache_response.c
bin/varnishd/cache_response.c
+10
-13
No files found.
bin/varnishd/cache.h
View file @
4fac23da
...
...
@@ -689,6 +689,8 @@ 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
**
);
void
VGZ_UpdateObj
(
const
struct
vgz
*
,
struct
object
*
);
int
VGZ_WrwGunzip
(
struct
sess
*
,
struct
vgz
*
,
void
*
ibuf
,
ssize_t
ibufl
,
char
*
obuf
,
ssize_t
obufl
,
ssize_t
*
obufp
);
/* Return values */
#define VGZ_ERROR -1
...
...
bin/varnishd/cache_esi_deliver.c
View file @
4fac23da
...
...
@@ -320,21 +320,9 @@ ESI_Deliver(struct sess *sp)
* A gzip'ed VEC, but ungzip'ed ESI response
*/
AN
(
vgz
);
VGZ_Ibuf
(
vgz
,
st
->
ptr
+
off
,
l
);
do
{
VGZ_Obuf
(
vgz
,
obuf
+
obufl
,
sizeof
obuf
-
obufl
);
i
=
VGZ_Gunzip
(
vgz
,
&
dp
,
&
dl
);
assert
(
i
>=
VGZ_OK
);
obufl
+=
dl
;
assert
(
obufl
<=
sizeof
obuf
);
if
(
obufl
==
sizeof
obuf
||
i
==
VGZ_STUCK
)
{
WRW_Write
(
sp
->
wrk
,
obuf
,
obufl
);
WRW_Flush
(
sp
->
wrk
);
obufl
=
0
;
}
}
while
(
!
VGZ_IbufEmpty
(
vgz
));
i
=
VGZ_WrwGunzip
(
sp
,
vgz
,
st
->
ptr
+
off
,
l
,
obuf
,
sizeof
obuf
,
&
obufl
);
assert
(
i
==
VGZ_OK
||
i
==
VGZ_END
);
}
else
{
/*
...
...
bin/varnishd/cache_gzip.c
View file @
4fac23da
...
...
@@ -350,6 +350,40 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags)
return
(
-
1
);
}
/*--------------------------------------------------------------------
* Gunzip ibuf into outb, if it runs full, emit it with WRW.
* Leave flushing to caller, more data may be coming.
*/
int
VGZ_WrwGunzip
(
struct
sess
*
sp
,
struct
vgz
*
vg
,
void
*
ibuf
,
ssize_t
ibufl
,
char
*
obuf
,
ssize_t
obufl
,
ssize_t
*
obufp
)
{
int
i
;
size_t
dl
;
const
void
*
dp
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
VGZ_Ibuf
(
vg
,
ibuf
,
ibufl
);
VGZ_Obuf
(
vg
,
obuf
+
*
obufp
,
ibufl
-
*
obufp
);
do
{
i
=
VGZ_Gunzip
(
vg
,
&
dp
,
&
dl
);
if
(
i
<
VGZ_OK
)
{
/* XXX: VSL ? */
return
(
-
1
);
}
*
obufp
+=
dl
;
if
(
obufl
==
*
obufp
||
i
==
VGZ_STUCK
)
{
WRW_Write
(
sp
->
wrk
,
obuf
,
*
obufp
);
if
(
WRW_Flush
(
sp
->
wrk
))
return
(
-
1
);
*
obufp
=
0
;
VGZ_Obuf
(
vg
,
obuf
+
*
obufp
,
ibufl
-
*
obufp
);
}
}
while
(
!
VGZ_IbufEmpty
(
vg
));
return
(
i
);
}
/*--------------------------------------------------------------------*/
void
...
...
bin/varnishd/cache_response.c
View file @
4fac23da
...
...
@@ -245,15 +245,15 @@ res_WriteGunzipObj(struct sess *sp)
struct
storage
*
st
;
unsigned
u
=
0
;
struct
vgz
*
vg
;
const
void
*
dp
;
char
obuf
[
params
->
gzip_stack_buffer
];
s
ize_t
dl
;
s
size_t
obufl
=
0
;
int
i
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
vg
=
VGZ_NewUngzip
(
sp
,
"U D -"
);
VGZ_Obuf
(
vg
,
obuf
,
sizeof
obuf
);
VTAILQ_FOREACH
(
st
,
&
sp
->
obj
->
store
,
list
)
{
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
CHECK_OBJ_NOTNULL
(
st
,
STORAGE_MAGIC
);
...
...
@@ -262,17 +262,14 @@ res_WriteGunzipObj(struct sess *sp)
sp
->
acct_tmp
.
bodybytes
+=
st
->
len
;
/* XXX ? */
VSC_main
->
n_objwrite
++
;
VGZ_Ibuf
(
vg
,
st
->
ptr
,
st
->
len
);
do
{
VGZ_Obuf
(
vg
,
obuf
,
sizeof
obuf
);
i
=
VGZ_Gunzip
(
vg
,
&
dp
,
&
dl
);
assert
(
i
>=
VGZ_OK
);
if
(
dl
!=
0
)
{
(
void
)
WRW_Write
(
sp
->
wrk
,
dp
,
dl
);
if
(
WRW_Flush
(
sp
->
wrk
))
break
;
}
}
while
(
!
VGZ_IbufEmpty
(
vg
));
i
=
VGZ_WrwGunzip
(
sp
,
vg
,
st
->
ptr
,
st
->
len
,
obuf
,
sizeof
obuf
,
&
obufl
);
/* XXX: error check */
}
if
(
obufl
)
{
(
void
)
WRW_Write
(
sp
->
wrk
,
obuf
,
obufl
);
WRW_Flush
(
sp
->
wrk
);
}
VGZ_Destroy
(
&
vg
);
assert
(
u
==
sp
->
obj
->
len
);
...
...
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