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
2764c556
Commit
2764c556
authored
Aug 20, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src: Code cleanup
parent
30d3ea7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
src/shrpx_listen_handler.cc
src/shrpx_listen_handler.cc
+8
-8
src/shrpx_worker.cc
src/shrpx_worker.cc
+5
-6
No files found.
src/shrpx_listen_handler.cc
View file @
2764c556
...
...
@@ -47,9 +47,9 @@ ListenHandler::ListenHandler(event_base *evbase, SSL_CTX *sv_ssl_ctx,
sv_ssl_ctx_
(
sv_ssl_ctx
),
cl_ssl_ctx_
(
cl_ssl_ctx
),
worker_round_robin_cnt_
(
0
),
workers_
(
0
),
workers_
(
nullptr
),
num_worker_
(
0
),
spdy_
(
0
)
spdy_
(
nullptr
)
{}
ListenHandler
::~
ListenHandler
()
...
...
@@ -61,7 +61,7 @@ void ListenHandler::create_worker_thread(size_t num)
num_worker_
=
0
;
for
(
size_t
i
=
0
;
i
<
num
;
++
i
)
{
int
rv
;
WorkerInfo
*
info
=
&
workers_
[
num_worker_
];
auto
info
=
&
workers_
[
num_worker_
];
rv
=
socketpair
(
AF_UNIX
,
SOCK_STREAM
,
0
,
info
->
sv
);
if
(
rv
==
-
1
)
{
LLOG
(
ERROR
,
this
)
<<
"socketpair() failed: errno="
<<
errno
;
...
...
@@ -80,8 +80,8 @@ void ListenHandler::create_worker_thread(size_t num)
}
continue
;
}
bufferevent
*
bev
=
bufferevent_socket_new
(
evbase_
,
info
->
sv
[
0
],
BEV_OPT_DEFER_CALLBACKS
);
auto
bev
=
bufferevent_socket_new
(
evbase_
,
info
->
sv
[
0
],
BEV_OPT_DEFER_CALLBACKS
);
info
->
bev
=
bev
;
if
(
LOG_ENABLED
(
INFO
))
{
LLOG
(
INFO
,
this
)
<<
"Created thread #"
<<
num_worker_
;
...
...
@@ -97,8 +97,8 @@ int ListenHandler::accept_connection(evutil_socket_t fd,
LLOG
(
INFO
,
this
)
<<
"Accepted connection. fd="
<<
fd
;
}
if
(
num_worker_
==
0
)
{
ClientHandler
*
client
=
ssl
::
accept_connection
(
evbase_
,
sv_ssl_ctx_
,
fd
,
addr
,
addrlen
);
auto
client
=
ssl
::
accept_connection
(
evbase_
,
sv_ssl_ctx_
,
fd
,
addr
,
addrlen
);
client
->
set_spdy_session
(
spdy_
);
}
else
{
size_t
idx
=
worker_round_robin_cnt_
%
num_worker_
;
...
...
@@ -108,7 +108,7 @@ int ListenHandler::accept_connection(evutil_socket_t fd,
wev
.
client_fd
=
fd
;
memcpy
(
&
wev
.
client_addr
,
addr
,
addrlen
);
wev
.
client_addrlen
=
addrlen
;
evbuffer
*
output
=
bufferevent_get_output
(
workers_
[
idx
].
bev
);
auto
output
=
bufferevent_get_output
(
workers_
[
idx
].
bev
);
if
(
evbuffer_add
(
output
,
&
wev
,
sizeof
(
wev
))
!=
0
)
{
LLOG
(
FATAL
,
this
)
<<
"evbuffer_add() failed"
;
return
-
1
;
...
...
src/shrpx_worker.cc
View file @
2764c556
...
...
@@ -52,7 +52,7 @@ Worker::~Worker()
namespace
{
void
readcb
(
bufferevent
*
bev
,
void
*
arg
)
{
ThreadEventReceiver
*
receiver
=
reinterpret_cast
<
ThreadEventReceiver
*>
(
arg
);
auto
receiver
=
reinterpret_cast
<
ThreadEventReceiver
*>
(
arg
);
receiver
->
on_read
(
bev
);
}
}
// namespace
...
...
@@ -71,17 +71,16 @@ void eventcb(bufferevent *bev, short events, void *arg)
void
Worker
::
run
()
{
event_base
*
evbase
=
event_base_new
();
bufferevent
*
bev
=
bufferevent_socket_new
(
evbase
,
fd_
,
BEV_OPT_DEFER_CALLBACKS
);
SpdySession
*
spdy
=
0
;
auto
evbase
=
event_base_new
();
auto
bev
=
bufferevent_socket_new
(
evbase
,
fd_
,
BEV_OPT_DEFER_CALLBACKS
);
SpdySession
*
spdy
=
nullptr
;
if
(
get_config
()
->
downstream_proto
==
PROTO_SPDY
)
{
spdy
=
new
SpdySession
(
evbase
,
cl_ssl_ctx_
);
if
(
spdy
->
init_notification
()
==
-
1
)
{
DIE
();
}
}
ThreadEventReceiver
*
receiver
=
new
ThreadEventReceiver
(
sv_ssl_ctx_
,
spdy
);
auto
receiver
=
new
ThreadEventReceiver
(
sv_ssl_ctx_
,
spdy
);
bufferevent_enable
(
bev
,
EV_READ
);
bufferevent_setcb
(
bev
,
readcb
,
0
,
eventcb
,
receiver
);
...
...
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