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
841abfec
Commit
841abfec
authored
May 26, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Absorb struct sesspool into struct pool
parent
f71729ae
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
84 deletions
+56
-84
cache.h
bin/varnishd/cache/cache.h
+3
-15
cache_acceptor.c
bin/varnishd/cache/cache_acceptor.c
+5
-8
cache_pool.c
bin/varnishd/cache/cache_pool.c
+9
-4
cache_pool.h
bin/varnishd/cache/cache_pool.h
+6
-1
cache_req.c
bin/varnishd/cache/cache_req.c
+7
-8
cache_session.c
bin/varnishd/cache/cache_session.c
+26
-48
No files found.
bin/varnishd/cache/cache.h
View file @
841abfec
...
...
@@ -616,16 +616,6 @@ struct req {
* works, is not realistic without a lot of code changes.
*/
struct
sesspool
{
unsigned
magic
;
#define SESSPOOL_MAGIC 0xd916e202
struct
pool
*
pool
;
struct
mempool
*
mpl_req
;
struct
mempool
*
mpl_sess
;
struct
waiter
*
http1_waiter
;
};
enum
sess_attr
{
#define SESS_ATTR(UP, low, typ, len) SA_##UP,
#include "tbl/sess_attr.h"
...
...
@@ -644,7 +634,7 @@ struct sess {
/* Cross references ------------------------------------------*/
struct
sesspool
*
sess
pool
;
struct
pool
*
pool
;
struct
waited
waited
;
...
...
@@ -686,7 +676,6 @@ typedef enum htc_status_e htc_complete_f(struct http_conn *);
/* cache_acceptor.c */
void
VCA_Init
(
void
);
void
VCA_Shutdown
(
void
);
void
VCA_New_SessPool
(
struct
pool
*
pp
,
struct
sesspool
*
sp
);
/* cache_backend_cfg.c */
void
VBE_InitCfg
(
void
);
...
...
@@ -990,12 +979,11 @@ int Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req);
void
Req_Fail
(
struct
req
*
req
,
enum
sess_close
reason
);
/* cache_session.c [SES] */
struct
sess
*
SES_New
(
struct
sess
pool
*
);
struct
sess
*
SES_New
(
struct
pool
*
);
void
SES_Close
(
struct
sess
*
sp
,
enum
sess_close
reason
);
void
SES_Wait
(
struct
sess
*
sp
);
void
SES_Delete
(
struct
sess
*
sp
,
enum
sess_close
reason
,
double
now
);
struct
sesspool
*
SES_NewPool
(
struct
pool
*
pp
,
unsigned
pool_no
);
void
SES_DeletePool
(
struct
sesspool
*
sp
);
void
SES_NewPool
(
struct
pool
*
pp
,
unsigned
pool_no
);
int
SES_Reschedule_Req
(
struct
req
*
);
task_func_t
SES_Proto_Sess
;
task_func_t
SES_Proto_Req
;
...
...
bin/varnishd/cache/cache_acceptor.c
View file @
841abfec
...
...
@@ -41,6 +41,7 @@
#include <netinet/tcp.h>
#include "cache.h"
#include "cache_pool.h"
#include "common/heritage.h"
#include "vcli.h"
...
...
@@ -63,7 +64,6 @@ struct wrk_accept {
socklen_t
acceptaddrlen
;
int
acceptsock
;
struct
listen_sock
*
acceptlsock
;
struct
sesspool
*
sesspool
;
};
struct
poolsock
{
...
...
@@ -71,7 +71,7 @@ struct poolsock {
#define POOLSOCK_MAGIC 0x1b0a2d38
struct
listen_sock
*
lsock
;
struct
pool_task
task
;
struct
sesspool
*
sess
pool
;
struct
pool
*
pool
;
};
/*--------------------------------------------------------------------
...
...
@@ -291,7 +291,6 @@ vca_pace_good(void)
static
void
__match_proto__
(
task_func_t
)
vca_make_session
(
struct
worker
*
wrk
,
void
*
arg
)
{
struct
sesspool
*
pp
;
struct
sess
*
sp
;
struct
wrk_accept
*
wa
;
struct
sockaddr_storage
ss
;
...
...
@@ -304,11 +303,10 @@ vca_make_session(struct worker *wrk, void *arg)
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CAST_OBJ_NOTNULL
(
wa
,
arg
,
WRK_ACCEPT_MAGIC
);
pp
=
wa
->
sesspool
;
/* Turn accepted socket into a session */
AN
(
wrk
->
aws
->
r
);
sp
=
SES_New
(
pp
);
sp
=
SES_New
(
wrk
->
pool
);
if
(
sp
==
NULL
)
{
/*
* We consider this a DoS situation and silently close the
...
...
@@ -397,7 +395,6 @@ vca_accept_task(struct worker *wrk, void *arg)
while
(
1
)
{
INIT_OBJ
(
&
wa
,
WRK_ACCEPT_MAGIC
);
wa
.
sesspool
=
ps
->
sesspool
;
wa
.
acceptlsock
=
ls
;
vca_pace_check
();
...
...
@@ -459,7 +456,7 @@ vca_accept_task(struct worker *wrk, void *arg)
*/
void
VCA_New
_SessPool
(
struct
pool
*
pp
,
struct
sesspool
*
s
p
)
VCA_New
Pool
(
struct
pool
*
p
p
)
{
struct
listen_sock
*
ls
;
struct
poolsock
*
ps
;
...
...
@@ -470,7 +467,7 @@ VCA_New_SessPool(struct pool *pp, struct sesspool *sp)
ps
->
lsock
=
ls
;
ps
->
task
.
func
=
vca_accept_task
;
ps
->
task
.
priv
=
ps
;
ps
->
sesspool
=
s
p
;
ps
->
pool
=
p
p
;
AZ
(
Pool_Task
(
pp
,
&
ps
->
task
,
POOL_QUEUE_BACK
));
}
}
...
...
bin/varnishd/cache/cache_pool.c
View file @
841abfec
...
...
@@ -145,8 +145,8 @@ pool_mkpool(unsigned pool_no)
while
(
VTAILQ_EMPTY
(
&
pp
->
idle_queue
))
(
void
)
usleep
(
10000
);
pp
->
sesspool
=
SES_NewPool
(
pp
,
pool_no
);
AN
(
pp
->
sesspool
);
SES_NewPool
(
pp
,
pool_no
);
VCA_NewPool
(
pp
);
return
(
pp
);
}
...
...
@@ -182,8 +182,13 @@ pool_poolherder(void *priv)
}
}
/* XXX: remove pools */
if
(
0
)
SES_DeletePool
(
NULL
);
if
(
0
)
{
pp
=
VTAILQ_FIRST
(
&
pools
);
AN
(
pp
);
MPL_Destroy
(
&
pp
->
mpl_sess
);
MPL_Destroy
(
&
pp
->
mpl_req
);
INCOMPL
();
}
(
void
)
sleep
(
1
);
u
=
0
;
VTAILQ_FOREACH
(
pp
,
&
pools
,
list
)
...
...
bin/varnishd/cache/cache_pool.h
View file @
841abfec
...
...
@@ -50,11 +50,16 @@ struct pool {
unsigned
lqueue
;
uintmax_t
ndropped
;
uintmax_t
nqueued
;
struct
sesspool
*
sesspool
;
struct
dstat
*
a_stat
;
struct
dstat
*
b_stat
;
struct
waitfor
wf
;
struct
mempool
*
mpl_req
;
struct
mempool
*
mpl_sess
;
struct
waiter
*
waiter
;
};
void
*
pool_herder
(
void
*
);
task_func_t
pool_stat_summ
;
extern
struct
lock
pool_mtx
;
void
VCA_NewPool
(
struct
pool
*
pp
);
bin/varnishd/cache/cache_req.c
View file @
841abfec
...
...
@@ -38,6 +38,7 @@
#include <stdlib.h>
#include "cache.h"
#include "cache_pool.h"
#include "vtim.h"
...
...
@@ -48,7 +49,7 @@
struct
req
*
Req_New
(
const
struct
worker
*
wrk
,
struct
sess
*
sp
)
{
struct
sess
pool
*
pp
;
struct
pool
*
pp
;
struct
req
*
req
;
uint16_t
nhttp
;
unsigned
sz
,
hl
;
...
...
@@ -56,9 +57,8 @@ Req_New(const struct worker *wrk, struct sess *sp)
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
pp
=
sp
->
sesspool
;
CHECK_OBJ_NOTNULL
(
pp
,
SESSPOOL_MAGIC
);
AN
(
pp
->
pool
);
pp
=
sp
->
pool
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
req
=
MPL_Get
(
pp
->
mpl_req
,
&
sz
);
AN
(
req
);
...
...
@@ -114,7 +114,7 @@ void
Req_Release
(
struct
req
*
req
)
{
struct
sess
*
sp
;
struct
sess
pool
*
pp
;
struct
pool
*
pp
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
...
...
@@ -129,9 +129,8 @@ Req_Release(struct req *req)
VSL_End
(
req
->
vsl
);
sp
=
req
->
sp
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
pp
=
sp
->
sesspool
;
CHECK_OBJ_NOTNULL
(
pp
,
SESSPOOL_MAGIC
);
AN
(
pp
->
pool
);
pp
=
sp
->
pool
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
MPL_AssertSane
(
req
);
VSL_Flush
(
req
->
vsl
,
0
);
...
...
bin/varnishd/cache/cache_session.c
View file @
841abfec
...
...
@@ -46,6 +46,7 @@
#include <stdlib.h>
#include "cache.h"
#include "cache_pool.h"
#include "vsa.h"
#include "vtcp.h"
...
...
@@ -299,16 +300,16 @@ SES_RxReq(const struct worker *wrk, struct req *req, htc_complete_f *func)
*/
struct
sess
*
SES_New
(
struct
sess
pool
*
pp
)
SES_New
(
struct
pool
*
pp
)
{
struct
sess
*
sp
;
unsigned
sz
;
char
*
p
,
*
e
;
CHECK_OBJ_NOTNULL
(
pp
,
SESS
POOL_MAGIC
);
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
sp
=
MPL_Get
(
pp
->
mpl_sess
,
&
sz
);
sp
->
magic
=
SESS_MAGIC
;
sp
->
sess
pool
=
pp
;
sp
->
pool
=
pp
;
memset
(
sp
->
sattr
,
0xff
,
sizeof
sp
->
sattr
);
e
=
(
char
*
)
sp
+
sz
;
...
...
@@ -403,19 +404,18 @@ int
SES_Reschedule_Req
(
struct
req
*
req
)
{
struct
sess
*
sp
;
struct
sess
pool
*
pp
;
struct
pool
*
pp
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
sp
=
req
->
sp
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
pp
=
sp
->
sesspool
;
CHECK_OBJ_NOTNULL
(
pp
,
SESSPOOL_MAGIC
);
AN
(
pp
->
pool
);
pp
=
sp
->
pool
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
req
->
task
.
func
=
SES_Proto_Req
;
req
->
task
.
priv
=
req
;
return
(
Pool_Task
(
pp
->
pool
,
&
req
->
task
,
POOL_QUEUE_FRONT
));
return
(
Pool_Task
(
pp
,
&
req
->
task
,
POOL_QUEUE_FRONT
));
}
/*--------------------------------------------------------------------
...
...
@@ -426,7 +426,7 @@ static void __match_proto__(waiter_handle_f)
ses_handle
(
struct
waited
*
wp
,
enum
wait_event
ev
,
double
now
)
{
struct
sess
*
sp
;
struct
sess
pool
*
pp
;
struct
pool
*
pp
;
struct
pool_task
*
tp
;
CHECK_OBJ_NOTNULL
(
wp
,
WAITED_MAGIC
);
...
...
@@ -442,14 +442,13 @@ ses_handle(struct waited *wp, enum wait_event ev, double now)
SES_Delete
(
sp
,
SC_REM_CLOSE
,
now
);
break
;
case
WAITER_ACTION
:
pp
=
sp
->
sesspool
;
CHECK_OBJ_NOTNULL
(
pp
,
SESSPOOL_MAGIC
);
AN
(
pp
->
pool
);
pp
=
sp
->
pool
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
assert
(
sizeof
*
tp
==
WS_Reserve
(
sp
->
ws
,
sizeof
*
tp
));
tp
=
(
void
*
)
sp
->
ws
->
f
;
tp
->
func
=
SES_Proto_Sess
;
tp
->
priv
=
sp
;
if
(
Pool_Task
(
pp
->
pool
,
tp
,
POOL_QUEUE_FRONT
))
if
(
Pool_Task
(
pp
,
tp
,
POOL_QUEUE_FRONT
))
SES_Delete
(
sp
,
SC_OVERLOAD
,
now
);
break
;
case
WAITER_CLOSE
:
...
...
@@ -466,11 +465,11 @@ ses_handle(struct waited *wp, enum wait_event ev, double now)
void
SES_Wait
(
struct
sess
*
sp
)
{
struct
sess
pool
*
pp
;
struct
pool
*
pp
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
pp
=
sp
->
sess
pool
;
CHECK_OBJ_NOTNULL
(
pp
,
SESS
POOL_MAGIC
);
pp
=
sp
->
pool
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
/*
* XXX: waiter_epoll prevents us from zeroing the struct because
* XXX: it keeps state across calls.
...
...
@@ -483,7 +482,7 @@ SES_Wait(struct sess *sp)
sp
->
waited
.
fd
=
sp
->
fd
;
sp
->
waited
.
ptr
=
sp
;
sp
->
waited
.
idle
=
sp
->
t_idle
;
if
(
Wait_Enter
(
pp
->
http1_
waiter
,
&
sp
->
waited
))
if
(
Wait_Enter
(
pp
->
waiter
,
&
sp
->
waited
))
SES_Delete
(
sp
,
SC_PIPE_OVERFLOW
,
NAN
);
}
...
...
@@ -541,12 +540,11 @@ SES_Close(struct sess *sp, enum sess_close reason)
void
SES_Delete
(
struct
sess
*
sp
,
enum
sess_close
reason
,
double
now
)
{
struct
sess
pool
*
pp
;
struct
pool
*
pp
;
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
pp
=
sp
->
sesspool
;
CHECK_OBJ_NOTNULL
(
pp
,
SESSPOOL_MAGIC
);
AN
(
pp
->
pool
);
pp
=
sp
->
pool
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
if
(
reason
!=
SC_NULL
)
SES_Close
(
sp
,
reason
);
...
...
@@ -573,17 +571,12 @@ SES_Delete(struct sess *sp, enum sess_close reason, double now)
* Create and delete pools
*/
static
struct
waitfor
ses_wf
;
struct
sesspool
*
SES_NewPool
(
struct
pool
*
wp
,
unsigned
pool_no
)
void
SES_NewPool
(
struct
pool
*
pp
,
unsigned
pool_no
)
{
struct
sesspool
*
pp
;
char
nb
[
8
];
ALLOC_OBJ
(
pp
,
SESSPOOL_MAGIC
);
AN
(
pp
);
pp
->
pool
=
wp
;
CHECK_OBJ_NOTNULL
(
pp
,
POOL_MAGIC
);
bprintf
(
nb
,
"req%u"
,
pool_no
);
pp
->
mpl_req
=
MPL_New
(
nb
,
&
cache_param
->
req_pool
,
&
cache_param
->
workspace_client
);
...
...
@@ -591,23 +584,8 @@ SES_NewPool(struct pool *wp, unsigned pool_no)
pp
->
mpl_sess
=
MPL_New
(
nb
,
&
cache_param
->
sess_pool
,
&
cache_param
->
workspace_session
);
INIT_OBJ
(
&
ses_wf
,
WAITFOR_MAGIC
);
ses_wf
.
func
=
ses_handle
;
ses_wf
.
tmo
=
&
cache_param
->
timeout_idle
;
pp
->
http1_waiter
=
Waiter_New
(
&
ses_wf
);
VCA_New_SessPool
(
wp
,
pp
);
return
(
pp
);
}
void
SES_DeletePool
(
struct
sesspool
*
pp
)
{
CHECK_OBJ_NOTNULL
(
pp
,
SESSPOOL_MAGIC
);
MPL_Destroy
(
&
pp
->
mpl_sess
);
MPL_Destroy
(
&
pp
->
mpl_req
);
/* Delete session pool must stop acceptor threads */
FREE_OBJ
(
pp
);
INCOMPL
();
INIT_OBJ
(
&
pp
->
wf
,
WAITFOR_MAGIC
);
pp
->
wf
.
func
=
ses_handle
;
pp
->
wf
.
tmo
=
&
cache_param
->
timeout_idle
;
pp
->
waiter
=
Waiter_New
(
&
pp
->
wf
);
}
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