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
f2a6b3c9
Commit
f2a6b3c9
authored
Jun 08, 2012
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set OpenSSL locking_function.
parent
1199db69
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
0 deletions
+49
-0
examples/shrpx.cc
examples/shrpx.cc
+5
-0
examples/shrpx_ssl.cc
examples/shrpx_ssl.cc
+40
-0
examples/shrpx_ssl.h
examples/shrpx_ssl.h
+4
-0
No files found.
examples/shrpx.cc
View file @
f2a6b3c9
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
#include "shrpx_config.h"
#include "shrpx_config.h"
#include "shrpx_listen_handler.h"
#include "shrpx_listen_handler.h"
#include "shrpx_ssl.h"
namespace
shrpx
{
namespace
shrpx
{
...
@@ -446,8 +447,12 @@ int main(int argc, char **argv)
...
@@ -446,8 +447,12 @@ int main(int argc, char **argv)
OpenSSL_add_all_algorithms
();
OpenSSL_add_all_algorithms
();
SSL_load_error_strings
();
SSL_load_error_strings
();
SSL_library_init
();
SSL_library_init
();
ssl
::
setup_ssl_lock
();
event_loop
();
event_loop
();
ssl
::
teardown_ssl_lock
();
return
0
;
return
0
;
}
}
...
...
examples/shrpx_ssl.cc
View file @
f2a6b3c9
...
@@ -27,6 +27,9 @@
...
@@ -27,6 +27,9 @@
#include <sys/socket.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <netinet/tcp.h>
#include <pthread.h>
#include <openssl/crypto.h>
#include <event2/bufferevent.h>
#include <event2/bufferevent.h>
#include <event2/bufferevent_ssl.h>
#include <event2/bufferevent_ssl.h>
...
@@ -146,6 +149,43 @@ ClientHandler* accept_ssl_connection(event_base *evbase, SSL_CTX *ssl_ctx,
...
@@ -146,6 +149,43 @@ ClientHandler* accept_ssl_connection(event_base *evbase, SSL_CTX *ssl_ctx,
}
}
}
}
namespace
{
pthread_mutex_t
*
ssl_locks
;
}
// namespace
namespace
{
void
ssl_locking_cb
(
int
mode
,
int
type
,
const
char
*
file
,
int
line
)
{
if
(
mode
&
CRYPTO_LOCK
)
{
pthread_mutex_lock
(
&
(
ssl_locks
[
type
]));
}
else
{
pthread_mutex_unlock
(
&
(
ssl_locks
[
type
]));
}
}
}
// namespace
void
setup_ssl_lock
()
{
ssl_locks
=
new
pthread_mutex_t
[
CRYPTO_num_locks
()];
for
(
int
i
=
0
;
i
<
CRYPTO_num_locks
();
++
i
)
{
// Always returns 0
pthread_mutex_init
(
&
(
ssl_locks
[
i
]),
0
);
}
//CRYPTO_set_id_callback(ssl_thread_id); OpenSSL manual says that if
// threadid_func is not specified using
// CRYPTO_THREADID_set_callback(), then default implementation is
// used. We use this default one.
CRYPTO_set_locking_callback
(
ssl_locking_cb
);
}
void
teardown_ssl_lock
()
{
for
(
int
i
=
0
;
i
<
CRYPTO_num_locks
();
++
i
)
{
pthread_mutex_destroy
(
&
(
ssl_locks
[
i
]));
}
delete
[]
ssl_locks
;
}
}
// namespace ssl
}
// namespace ssl
}
// namespace shrpx
}
// namespace shrpx
examples/shrpx_ssl.h
View file @
f2a6b3c9
...
@@ -44,6 +44,10 @@ ClientHandler* accept_ssl_connection(event_base *evbase, SSL_CTX *ssl_ctx,
...
@@ -44,6 +44,10 @@ ClientHandler* accept_ssl_connection(event_base *evbase, SSL_CTX *ssl_ctx,
evutil_socket_t
fd
,
evutil_socket_t
fd
,
sockaddr
*
addr
,
int
addrlen
);
sockaddr
*
addr
,
int
addrlen
);
void
setup_ssl_lock
();
void
teardown_ssl_lock
();
}
// namespace ssl
}
// namespace ssl
}
// namespace shrpx
}
// namespace shrpx
...
...
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