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
83309b63
Commit
83309b63
authored
Sep 18, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Reduce epoll_ctl call
parent
23dd428d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
14 deletions
+43
-14
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+2
-2
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+4
-4
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+3
-3
src/shrpx_io_control.cc
src/shrpx_io_control.cc
+7
-3
src/shrpx_listen_handler.cc
src/shrpx_listen_handler.cc
+1
-1
src/shrpx_worker.cc
src/shrpx_worker.cc
+1
-1
src/util.cc
src/util.cc
+18
-0
src/util.h
src/util.h
+7
-0
No files found.
src/shrpx_client_handler.cc
View file @
83309b63
...
...
@@ -256,7 +256,7 @@ ClientHandler::ClientHandler(bufferevent *bev,
CLOG
(
FATAL
,
this
)
<<
"bufferevent_add_to_rate_limit_group() failed"
;
}
bufferevent_enable
(
bev_
,
EV_READ
|
EV_WRITE
);
util
::
bev_enable_unless
(
bev_
,
EV_READ
|
EV_WRITE
);
bufferevent_setwatermark
(
bev_
,
EV_READ
,
0
,
SHRPX_READ_WATERMARK
);
set_upstream_timeouts
(
&
get_config
()
->
upstream_read_timeout
,
&
get_config
()
->
upstream_write_timeout
);
...
...
@@ -298,7 +298,7 @@ ClientHandler::~ClientHandler()
bufferevent_remove_from_rate_limit_group
(
bev_
);
bufferevent_disable
(
bev_
,
EV_READ
|
EV_WRITE
);
util
::
bev_disable_unless
(
bev_
,
EV_READ
|
EV_WRITE
);
bufferevent_free
(
bev_
);
if
(
ssl_
)
{
...
...
src/shrpx_http2_session.cc
View file @
83309b63
...
...
@@ -89,7 +89,7 @@ int Http2Session::disconnect()
}
if
(
bev_
)
{
int
fd
=
bufferevent_getfd
(
bev_
);
bufferevent_disable
(
bev_
,
EV_READ
|
EV_WRITE
);
util
::
bev_disable_unless
(
bev_
,
EV_READ
|
EV_WRITE
);
bufferevent_free
(
bev_
);
bev_
=
nullptr
;
if
(
fd
!=
-
1
)
{
...
...
@@ -219,7 +219,7 @@ int Http2Session::init_notification()
close
(
sockpair
[
1
]);
return
-
1
;
}
bufferevent_enable
(
rdbev_
,
EV_READ
);
util
::
bev_enable_unless
(
rdbev_
,
EV_READ
);
bufferevent_setcb
(
rdbev_
,
notify_readcb
,
nullptr
,
notify_eventcb
,
this
);
return
0
;
}
...
...
@@ -417,7 +417,7 @@ int Http2Session::initiate_connection()
close
(
fd
);
return
SHRPX_ERR_NETWORK
;
}
bufferevent_enable
(
bev_
,
EV_READ
);
util
::
bev_enable_unless
(
bev_
,
EV_READ
);
bufferevent_set_timeouts
(
bev_
,
&
get_config
()
->
downstream_read_timeout
,
&
get_config
()
->
downstream_write_timeout
);
...
...
@@ -534,7 +534,7 @@ int Http2Session::initiate_connection()
}
bufferevent_setwatermark
(
bev_
,
EV_READ
,
0
,
SHRPX_READ_WATERMARK
);
bufferevent_enable
(
bev_
,
EV_READ
);
util
::
bev_enable_unless
(
bev_
,
EV_READ
);
bufferevent_setcb
(
bev_
,
readcb
,
writecb
,
eventcb
,
this
);
// Set timeout for HTTP2 session
reset_timeouts
();
...
...
src/shrpx_http_downstream_connection.cc
View file @
83309b63
...
...
@@ -54,7 +54,7 @@ HttpDownstreamConnection::HttpDownstreamConnection
HttpDownstreamConnection
::~
HttpDownstreamConnection
()
{
if
(
bev_
)
{
bufferevent_disable
(
bev_
,
EV_READ
|
EV_WRITE
);
util
::
bev_disable_unless
(
bev_
,
EV_READ
|
EV_WRITE
);
bufferevent_free
(
bev_
);
}
// Downstream and DownstreamConnection may be deleted
...
...
@@ -127,7 +127,7 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream)
response_htp_
.
data
=
downstream_
;
bufferevent_setwatermark
(
bev_
,
EV_READ
,
0
,
SHRPX_READ_WATERMARK
);
bufferevent_enable
(
bev_
,
EV_READ
);
util
::
bev_enable_unless
(
bev_
,
EV_READ
);
bufferevent_setcb
(
bev_
,
upstream
->
get_downstream_readcb
(),
upstream
->
get_downstream_writecb
(),
...
...
@@ -369,7 +369,7 @@ void HttpDownstreamConnection::detach_downstream(Downstream *downstream)
}
downstream_
=
nullptr
;
ioctrl_
.
force_resume_read
();
bufferevent_enable
(
bev_
,
EV_READ
);
util
::
bev_enable_unless
(
bev_
,
EV_READ
);
bufferevent_setcb
(
bev_
,
0
,
0
,
idle_eventcb
,
this
);
// On idle state, just enable read timeout. Normally idle downstream
// connection will get EOF from the downstream server and closed.
...
...
src/shrpx_io_control.cc
View file @
83309b63
...
...
@@ -26,6 +26,10 @@
#include <algorithm>
#include "util.h"
using
namespace
nghttp2
;
namespace
shrpx
{
IOControl
::
IOControl
(
bufferevent
*
bev
)
...
...
@@ -45,7 +49,7 @@ void IOControl::pause_read(IOCtrlReason reason)
{
rdbits_
|=
reason
;
if
(
bev_
)
{
bufferevent_disable
(
bev_
,
EV_READ
);
util
::
bev_disable_unless
(
bev_
,
EV_READ
);
}
}
...
...
@@ -54,7 +58,7 @@ bool IOControl::resume_read(IOCtrlReason reason)
rdbits_
&=
~
reason
;
if
(
rdbits_
==
0
)
{
if
(
bev_
)
{
bufferevent_enable
(
bev_
,
EV_READ
);
util
::
bev_enable_unless
(
bev_
,
EV_READ
);
}
return
true
;
}
else
{
...
...
@@ -66,7 +70,7 @@ void IOControl::force_resume_read()
{
rdbits_
=
0
;
if
(
bev_
)
{
bufferevent_enable
(
bev_
,
EV_READ
);
util
::
bev_enable_unless
(
bev_
,
EV_READ
);
}
}
...
...
src/shrpx_listen_handler.cc
View file @
83309b63
...
...
@@ -112,7 +112,7 @@ void worker_writecb(bufferevent *bev, void *ptr)
// Disable bev so that this won' be called accidentally in the
// future.
bufferevent_disable
(
bev
,
EV_READ
|
EV_WRITE
);
util
::
bev_disable_unless
(
bev
,
EV_READ
|
EV_WRITE
);
}
}
// namespace
#endif // NOTHREADS
...
...
src/shrpx_worker.cc
View file @
83309b63
...
...
@@ -113,7 +113,7 @@ void Worker::run()
http2session
.
get
(),
http1_connect_blocker
.
get
());
bufferevent_enable
(
bev
.
get
(),
EV_READ
);
util
::
bev_enable_unless
(
bev
.
get
(),
EV_READ
);
bufferevent_setcb
(
bev
.
get
(),
readcb
,
nullptr
,
eventcb
,
receiver
.
get
());
event_base_loop
(
evbase
.
get
(),
0
);
...
...
src/util.cc
View file @
83309b63
...
...
@@ -657,6 +657,24 @@ char* get_exec_path(int argc, char **const argv, const char *cwd)
return
path
;
}
void
bev_enable_unless
(
bufferevent
*
bev
,
int
events
)
{
if
((
bufferevent_get_enabled
(
bev
)
&
events
)
==
events
)
{
return
;
}
bufferevent_enable
(
bev
,
events
);
}
void
bev_disable_unless
(
bufferevent
*
bev
,
int
events
)
{
if
((
bufferevent_get_enabled
(
bev
)
&
events
)
==
0
)
{
return
;
}
bufferevent_disable
(
bev
,
events
);
}
}
// namespace util
}
// namespace nghttp2
src/util.h
View file @
83309b63
...
...
@@ -38,6 +38,7 @@
#include <memory>
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include "http-parser/http_parser.h"
...
...
@@ -481,6 +482,12 @@ std::string ascii_dump(const uint8_t *data, size_t len);
// it.
char
*
get_exec_path
(
int
argc
,
char
**
const
argv
,
const
char
*
cwd
);
// These functions are provided to reduce epoll_ctl syscall. Avoid
// calling bufferevent_enable/disable() unless it is required by
// sniffing current enabled events.
void
bev_enable_unless
(
bufferevent
*
bev
,
int
events
);
void
bev_disable_unless
(
bufferevent
*
bev
,
int
events
);
}
// 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