Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
e7de5e9f
Commit
e7de5e9f
authored
Feb 07, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Rename cl_tls_session as downstream_tls_session
parent
5c10534b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
24 deletions
+25
-24
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+2
-2
src/shrpx_worker.cc
src/shrpx_worker.cc
+18
-18
src/shrpx_worker.h
src/shrpx_worker.h
+5
-4
No files found.
src/shrpx_http_downstream_connection.cc
View file @
e7de5e9f
...
...
@@ -136,7 +136,7 @@ HttpDownstreamConnection::~HttpDownstreamConnection() {
auto
&
downstreamconf
=
get_config
()
->
conn
.
downstream
;
auto
&
addr
=
downstreamconf
.
addr_groups
[
group_
].
addrs
[
addr_idx_
];
worker_
->
cache_
cl
_tls_session
(
&
addr
,
session
);
worker_
->
cache_
downstream
_tls_session
(
&
addr
,
session
);
}
}
}
...
...
@@ -221,7 +221,7 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
SSL_set_tlsext_host_name
(
conn_
.
tls
.
ssl
,
sni_name
.
c_str
());
}
auto
session
=
worker_
->
reuse_
cl
_tls_session
(
&
addrs
[
i
]);
auto
session
=
worker_
->
reuse_
downstream
_tls_session
(
&
addrs
[
i
]);
if
(
session
)
{
SSL_set_session
(
conn_
.
tls
.
ssl
,
session
);
SSL_SESSION_free
(
session
);
...
...
src/shrpx_worker.cc
View file @
e7de5e9f
...
...
@@ -73,7 +73,7 @@ Worker::Worker(struct ev_loop *loop, SSL_CTX *sv_ssl_ctx, SSL_CTX *cl_ssl_ctx,
dconn_pool_
(
get_config
()
->
conn
.
downstream
.
addr_groups
.
size
()),
worker_stat_
(
get_config
()
->
conn
.
downstream
.
addr_groups
.
size
()),
dgrps_
(
get_config
()
->
conn
.
downstream
.
addr_groups
.
size
()),
cl
_tls_session_cache_size_
(
0
),
downstream
_tls_session_cache_size_
(
0
),
loop_
(
loop
),
sv_ssl_ctx_
(
sv_ssl_ctx
),
cl_ssl_ctx_
(
cl_ssl_ctx
),
...
...
@@ -118,7 +118,7 @@ Worker::~Worker() {
ev_async_stop
(
loop_
,
&
w_
);
ev_timer_stop
(
loop_
,
&
mcpool_clear_timer_
);
for
(
auto
&
p
:
cl
_tls_session_cache_
)
{
for
(
auto
&
p
:
downstream
_tls_session_cache_
)
{
for
(
auto
session
:
p
.
second
)
{
SSL_SESSION_free
(
session
);
}
...
...
@@ -307,8 +307,8 @@ mruby::MRubyContext *Worker::get_mruby_context() const {
}
#endif // HAVE_MRUBY
void
Worker
::
cache_
cl
_tls_session
(
const
DownstreamAddr
*
addr
,
SSL_SESSION
*
session
)
{
void
Worker
::
cache_
downstream
_tls_session
(
const
DownstreamAddr
*
addr
,
SSL_SESSION
*
session
)
{
auto
&
tlsconf
=
get_config
()
->
tls
;
auto
max
=
tlsconf
.
backend_session_cache_per_worker
;
...
...
@@ -316,34 +316,34 @@ void Worker::cache_cl_tls_session(const DownstreamAddr *addr,
return
;
}
if
(
cl
_tls_session_cache_size_
>=
max
)
{
if
(
downstream
_tls_session_cache_size_
>=
max
)
{
// It is implementation dependent which item is returned from
// std::begin(). Probably, this depends on hash algorithm. If it
// is random fashion, then we are mostly OK.
auto
it
=
std
::
begin
(
cl
_tls_session_cache_
);
assert
(
it
!=
std
::
end
(
cl
_tls_session_cache_
));
auto
it
=
std
::
begin
(
downstream
_tls_session_cache_
);
assert
(
it
!=
std
::
end
(
downstream
_tls_session_cache_
));
auto
&
v
=
(
*
it
).
second
;
assert
(
!
v
.
empty
());
auto
sess
=
v
.
front
();
v
.
pop_front
();
SSL_SESSION_free
(
sess
);
if
(
v
.
empty
())
{
cl
_tls_session_cache_
.
erase
(
it
);
downstream
_tls_session_cache_
.
erase
(
it
);
}
}
auto
it
=
cl
_tls_session_cache_
.
find
(
addr
);
if
(
it
==
std
::
end
(
cl
_tls_session_cache_
))
{
std
::
tie
(
it
,
std
::
ignore
)
=
cl_tls_session_cache_
.
emplace
(
addr
,
std
::
deque
<
SSL_SESSION
*>
());
auto
it
=
downstream
_tls_session_cache_
.
find
(
addr
);
if
(
it
==
std
::
end
(
downstream
_tls_session_cache_
))
{
std
::
tie
(
it
,
std
::
ignore
)
=
downstream_tls_session_cache_
.
emplace
(
addr
,
std
::
deque
<
SSL_SESSION
*>
());
}
(
*
it
).
second
.
push_back
(
session
);
++
cl
_tls_session_cache_size_
;
++
downstream
_tls_session_cache_size_
;
}
SSL_SESSION
*
Worker
::
reuse_
cl
_tls_session
(
const
DownstreamAddr
*
addr
)
{
auto
it
=
cl
_tls_session_cache_
.
find
(
addr
);
if
(
it
==
std
::
end
(
cl
_tls_session_cache_
))
{
SSL_SESSION
*
Worker
::
reuse_
downstream
_tls_session
(
const
DownstreamAddr
*
addr
)
{
auto
it
=
downstream
_tls_session_cache_
.
find
(
addr
);
if
(
it
==
std
::
end
(
downstream
_tls_session_cache_
))
{
return
nullptr
;
}
...
...
@@ -351,10 +351,10 @@ SSL_SESSION *Worker::reuse_cl_tls_session(const DownstreamAddr *addr) {
assert
(
!
v
.
empty
());
auto
session
=
v
.
back
();
v
.
pop_back
();
--
cl
_tls_session_cache_size_
;
--
downstream
_tls_session_cache_size_
;
if
(
v
.
empty
())
{
cl
_tls_session_cache_
.
erase
(
it
);
downstream
_tls_session_cache_
.
erase
(
it
);
}
return
session
;
...
...
src/shrpx_worker.h
View file @
e7de5e9f
...
...
@@ -148,12 +148,13 @@ public:
// Caches |session| which is associated to downstream address
// |addr|. The caller is responsible to increment the reference
// count of |session|, since this function does not do so.
void
cache_cl_tls_session
(
const
DownstreamAddr
*
addr
,
SSL_SESSION
*
session
);
void
cache_downstream_tls_session
(
const
DownstreamAddr
*
addr
,
SSL_SESSION
*
session
);
// Returns cached session associated |addr|. If non-nullptr value
// is returned, its cache entry was successfully removed from cache.
// If no cache entry is found associated to |addr|, nullptr will be
// returned.
SSL_SESSION
*
reuse_
cl
_tls_session
(
const
DownstreamAddr
*
addr
);
SSL_SESSION
*
reuse_
downstream
_tls_session
(
const
DownstreamAddr
*
addr
);
private:
#ifndef NOTHREADS
...
...
@@ -175,8 +176,8 @@ private:
// When doing eviction due to storage limitation, the SSL_SESSION
// which sits at the front of deque is removed.
std
::
unordered_map
<
const
DownstreamAddr
*
,
std
::
deque
<
SSL_SESSION
*>>
cl
_tls_session_cache_
;
size_t
cl
_tls_session_cache_size_
;
downstream
_tls_session_cache_
;
size_t
downstream
_tls_session_cache_size_
;
std
::
unique_ptr
<
MemcachedDispatcher
>
session_cache_memcached_dispatcher_
;
#ifdef HAVE_MRUBY
...
...
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