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
1e1d908c
Commit
1e1d908c
authored
Mar 17, 2017
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Eliminate global std::random_device
parent
6c69d675
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
19 deletions
+20
-19
src/shrpx.cc
src/shrpx.cc
+2
-5
src/shrpx_connection_handler.cc
src/shrpx_connection_handler.cc
+6
-2
src/shrpx_worker.cc
src/shrpx_worker.cc
+3
-6
src/shrpx_worker.h
src/shrpx_worker.h
+2
-1
src/shrpx_worker_process.cc
src/shrpx_worker_process.cc
+2
-5
src/util.cc
src/util.cc
+2
-0
src/util.h
src/util.h
+3
-0
No files found.
src/shrpx.cc
View file @
1e1d908c
...
...
@@ -172,10 +172,6 @@ struct InheritedAddr {
bool
used
;
};
namespace
{
std
::
random_device
rd
;
}
// namespace
namespace
{
void
signal_cb
(
struct
ev_loop
*
loop
,
ev_signal
*
w
,
int
revents
);
}
// namespace
...
...
@@ -2914,7 +2910,8 @@ int process_options(Config *config,
auto
iov
=
make_byte_ref
(
config
->
balloc
,
SHRPX_OBFUSCATED_NODE_LENGTH
+
2
);
auto
p
=
iov
.
base
;
*
p
++
=
'_'
;
std
::
mt19937
gen
(
rd
());
std
::
random_device
rd
;
auto
gen
=
util
::
make_mt19937
(
rd
);
p
=
util
::
random_alpha_digit
(
p
,
p
+
SHRPX_OBFUSCATED_NODE_LENGTH
,
gen
);
*
p
=
'\0'
;
fwdconf
.
by_obfuscated
=
StringRef
{
iov
.
base
,
p
};
...
...
src/shrpx_connection_handler.cc
View file @
1e1d908c
...
...
@@ -232,9 +232,11 @@ int ConnectionHandler::create_single_worker() {
all_ssl_ctx_
.
push_back
(
session_cache_ssl_ctx
);
}
std
::
random_device
rd
;
single_worker_
=
make_unique
<
Worker
>
(
loop_
,
sv_ssl_ctx
,
cl_ssl_ctx
,
session_cache_ssl_ctx
,
cert_tree_
.
get
(),
ticket_keys_
,
this
,
config
->
conn
.
downstream
);
ticket_keys_
,
this
,
config
->
conn
.
downstream
,
util
::
make_mt19937
(
rd
)
);
#ifdef HAVE_MRUBY
if
(
single_worker_
->
create_mruby_context
()
!=
0
)
{
return
-
1
;
...
...
@@ -276,6 +278,8 @@ int ConnectionHandler::create_worker_thread(size_t num) {
++
num
;
}
std
::
random_device
rd
;
for
(
size_t
i
=
0
;
i
<
num
;
++
i
)
{
auto
loop
=
ev_loop_new
(
config
->
ev_loop_flags
);
...
...
@@ -291,7 +295,7 @@ int ConnectionHandler::create_worker_thread(size_t num) {
}
auto
worker
=
make_unique
<
Worker
>
(
loop
,
sv_ssl_ctx
,
cl_ssl_ctx
,
session_cache_ssl_ctx
,
cert_tree_
.
get
(),
ticket_keys_
,
this
,
config
->
conn
.
downstream
);
ticket_keys_
,
this
,
config
->
conn
.
downstream
,
util
::
make_mt19937
(
rd
)
);
#ifdef HAVE_MRUBY
if
(
worker
->
create_mruby_context
()
!=
0
)
{
return
-
1
;
...
...
src/shrpx_worker.cc
View file @
1e1d908c
...
...
@@ -109,17 +109,14 @@ bool match_shared_downstream_addr(
}
}
// namespace
namespace
{
std
::
random_device
rd
;
}
// namespace
Worker
::
Worker
(
struct
ev_loop
*
loop
,
SSL_CTX
*
sv_ssl_ctx
,
SSL_CTX
*
cl_ssl_ctx
,
SSL_CTX
*
tls_session_cache_memcached_ssl_ctx
,
ssl
::
CertLookupTree
*
cert_tree
,
const
std
::
shared_ptr
<
TicketKeys
>
&
ticket_keys
,
ConnectionHandler
*
conn_handler
,
std
::
shared_ptr
<
DownstreamConfig
>
downstreamconf
)
:
randgen_
(
rd
()),
std
::
shared_ptr
<
DownstreamConfig
>
downstreamconf
,
std
::
mt19937
randgen
)
:
randgen_
(
std
::
move
(
randgen
)),
worker_stat_
{},
dns_tracker_
(
loop
),
loop_
(
loop
),
...
...
src/shrpx_worker.h
View file @
1e1d908c
...
...
@@ -223,7 +223,8 @@ public:
ssl
::
CertLookupTree
*
cert_tree
,
const
std
::
shared_ptr
<
TicketKeys
>
&
ticket_keys
,
ConnectionHandler
*
conn_handler
,
std
::
shared_ptr
<
DownstreamConfig
>
downstreamconf
);
std
::
shared_ptr
<
DownstreamConfig
>
downstreamconf
,
std
::
mt19937
randgen
);
~
Worker
();
void
run_async
();
void
wait
();
...
...
src/shrpx_worker_process.cc
View file @
1e1d908c
...
...
@@ -392,10 +392,6 @@ void nb_child_cb(struct ev_loop *loop, ev_child *w, int revents) {
}
// namespace
#endif // HAVE_NEVERBLEED
namespace
{
std
::
random_device
rd
;
}
// namespace
int
worker_process_event_loop
(
WorkerProcessConfig
*
wpconf
)
{
int
rv
;
std
::
array
<
char
,
STRERROR_BUFSIZE
>
errbuf
;
...
...
@@ -416,7 +412,8 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) {
auto
loop
=
EV_DEFAULT
;
auto
gen
=
std
::
mt19937
(
rd
());
std
::
random_device
rd
;
auto
gen
=
util
::
make_mt19937
(
rd
);
ConnectionHandler
conn_handler
(
loop
,
gen
);
...
...
src/util.cc
View file @
1e1d908c
...
...
@@ -1452,6 +1452,8 @@ StringRef extract_host(const StringRef &hostport) {
return
StringRef
{
std
::
begin
(
hostport
),
p
};
}
std
::
mt19937
make_mt19937
(
std
::
random_device
&
rd
)
{
return
std
::
mt19937
(
rd
());
}
}
// namespace util
}
// namespace nghttp2
src/util.h
View file @
1e1d908c
...
...
@@ -744,6 +744,9 @@ int sha256(uint8_t *buf, const StringRef &s);
// NULL-terminated.
StringRef
extract_host
(
const
StringRef
&
hostport
);
// Returns new std::mt19937 object, seeded by |rd|.
std
::
mt19937
make_mt19937
(
std
::
random_device
&
rd
);
}
// namespace util
}
// namespace nghttp2
...
...
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