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
5ae86058
Commit
5ae86058
authored
Aug 20, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Use std::thread
parent
da384988
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
12 deletions
+10
-12
src/shrpx_listen_handler.cc
src/shrpx_listen_handler.cc
+8
-8
src/shrpx_worker.cc
src/shrpx_worker.cc
+1
-3
src/shrpx_worker.h
src/shrpx_worker.h
+1
-1
No files found.
src/shrpx_listen_handler.cc
View file @
5ae86058
...
@@ -25,9 +25,10 @@
...
@@ -25,9 +25,10 @@
#include "shrpx_listen_handler.h"
#include "shrpx_listen_handler.h"
#include <unistd.h>
#include <unistd.h>
#include <pthread.h>
#include <cerrno>
#include <cerrno>
#include <thread>
#include <system_error>
#include <event2/bufferevent_ssl.h>
#include <event2/bufferevent_ssl.h>
...
@@ -60,10 +61,6 @@ void ListenHandler::create_worker_thread(size_t num)
...
@@ -60,10 +61,6 @@ void ListenHandler::create_worker_thread(size_t num)
num_worker_
=
0
;
num_worker_
=
0
;
for
(
size_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
num
;
++
i
)
{
int
rv
;
int
rv
;
pthread_t
thread
;
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
WorkerInfo
*
info
=
&
workers_
[
num_worker_
];
WorkerInfo
*
info
=
&
workers_
[
num_worker_
];
rv
=
socketpair
(
AF_UNIX
,
SOCK_STREAM
,
0
,
info
->
sv
);
rv
=
socketpair
(
AF_UNIX
,
SOCK_STREAM
,
0
,
info
->
sv
);
if
(
rv
==
-
1
)
{
if
(
rv
==
-
1
)
{
...
@@ -72,9 +69,12 @@ void ListenHandler::create_worker_thread(size_t num)
...
@@ -72,9 +69,12 @@ void ListenHandler::create_worker_thread(size_t num)
}
}
info
->
sv_ssl_ctx
=
sv_ssl_ctx_
;
info
->
sv_ssl_ctx
=
sv_ssl_ctx_
;
info
->
cl_ssl_ctx
=
cl_ssl_ctx_
;
info
->
cl_ssl_ctx
=
cl_ssl_ctx_
;
rv
=
pthread_create
(
&
thread
,
&
attr
,
start_threaded_worker
,
info
);
try
{
if
(
rv
!=
0
)
{
auto
thread
=
std
::
thread
{
start_threaded_worker
,
info
};
LLOG
(
ERROR
,
this
)
<<
"pthread_create() failed: errno="
<<
rv
;
thread
.
detach
();
}
catch
(
const
std
::
system_error
&
error
)
{
LLOG
(
ERROR
,
this
)
<<
"Could not start thread: code="
<<
error
.
code
()
<<
" msg="
<<
error
.
what
();
for
(
size_t
j
=
0
;
j
<
2
;
++
j
)
{
for
(
size_t
j
=
0
;
j
<
2
;
++
j
)
{
close
(
info
->
sv
[
j
]);
close
(
info
->
sv
[
j
]);
}
}
...
...
src/shrpx_worker.cc
View file @
5ae86058
...
@@ -90,12 +90,10 @@ void Worker::run()
...
@@ -90,12 +90,10 @@ void Worker::run()
delete
receiver
;
delete
receiver
;
}
}
void
*
start_threaded_worker
(
void
*
arg
)
void
start_threaded_worker
(
WorkerInfo
*
info
)
{
{
WorkerInfo
*
info
=
reinterpret_cast
<
WorkerInfo
*>
(
arg
);
Worker
worker
(
info
);
Worker
worker
(
info
);
worker
.
run
();
worker
.
run
();
return
0
;
}
}
}
// namespace shrpx
}
// namespace shrpx
src/shrpx_worker.h
View file @
5ae86058
...
@@ -46,7 +46,7 @@ private:
...
@@ -46,7 +46,7 @@ private:
SSL_CTX
*
cl_ssl_ctx_
;
SSL_CTX
*
cl_ssl_ctx_
;
};
};
void
*
start_threaded_worker
(
void
*
arg
);
void
start_threaded_worker
(
WorkerInfo
*
info
);
}
// 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