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
679a389b
Commit
679a389b
authored
Nov 26, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Code cleanup
parent
888e6f01
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
29 deletions
+27
-29
src/shrpx_client_handler.cc
src/shrpx_client_handler.cc
+8
-9
src/shrpx_downstream_connection.cc
src/shrpx_downstream_connection.cc
+1
-1
src/shrpx_downstream_queue.cc
src/shrpx_downstream_queue.cc
+6
-7
src/shrpx_http2_downstream_connection.cc
src/shrpx_http2_downstream_connection.cc
+12
-12
No files found.
src/shrpx_client_handler.cc
View file @
679a389b
...
...
@@ -46,7 +46,7 @@ namespace shrpx {
namespace
{
void
upstream_readcb
(
bufferevent
*
bev
,
void
*
arg
)
{
ClientHandler
*
handler
=
reinterpret_cast
<
ClientHandler
*>
(
arg
);
auto
handler
=
reinterpret_cast
<
ClientHandler
*>
(
arg
);
int
rv
=
handler
->
on_read
();
if
(
rv
!=
0
)
{
delete
handler
;
...
...
@@ -57,7 +57,7 @@ void upstream_readcb(bufferevent *bev, void *arg)
namespace
{
void
upstream_writecb
(
bufferevent
*
bev
,
void
*
arg
)
{
ClientHandler
*
handler
=
reinterpret_cast
<
ClientHandler
*>
(
arg
);
auto
handler
=
reinterpret_cast
<
ClientHandler
*>
(
arg
);
// We actually depend on write low-warter mark == 0.
if
(
evbuffer_get_length
(
bufferevent_get_output
(
bev
))
>
0
)
{
// Possibly because of deferred callback, we may get this callback
...
...
@@ -67,7 +67,7 @@ void upstream_writecb(bufferevent *bev, void *arg)
if
(
handler
->
get_should_close_after_write
())
{
delete
handler
;
}
else
{
Upstream
*
upstream
=
handler
->
get_upstream
();
auto
upstream
=
handler
->
get_upstream
();
int
rv
=
upstream
->
on_write
();
if
(
rv
!=
0
)
{
delete
handler
;
...
...
@@ -79,7 +79,7 @@ void upstream_writecb(bufferevent *bev, void *arg)
namespace
{
void
upstream_eventcb
(
bufferevent
*
bev
,
short
events
,
void
*
arg
)
{
ClientHandler
*
handler
=
reinterpret_cast
<
ClientHandler
*>
(
arg
);
auto
handler
=
reinterpret_cast
<
ClientHandler
*>
(
arg
);
bool
finish
=
false
;
if
(
events
&
BEV_EVENT_EOF
)
{
if
(
LOG_ENABLED
(
INFO
))
{
...
...
@@ -252,9 +252,8 @@ ClientHandler::~ClientHandler()
}
shutdown
(
fd_
,
SHUT_WR
);
close
(
fd_
);
for
(
std
::
set
<
DownstreamConnection
*>::
iterator
i
=
dconn_pool_
.
begin
();
i
!=
dconn_pool_
.
end
();
++
i
)
{
delete
*
i
;
for
(
auto
dconn
:
dconn_pool_
)
{
delete
dconn
;
}
if
(
LOG_ENABLED
(
INFO
))
{
CLOG
(
INFO
,
this
)
<<
"Deleted"
;
...
...
@@ -382,7 +381,7 @@ DownstreamConnection* ClientHandler::get_downstream_connection()
return
new
HttpDownstreamConnection
(
this
);
}
}
else
{
DownstreamConnection
*
dconn
=
*
dconn_pool_
.
begin
(
);
auto
dconn
=
*
std
::
begin
(
dconn_pool_
);
dconn_pool_
.
erase
(
dconn
);
if
(
LOG_ENABLED
(
INFO
))
{
CLOG
(
INFO
,
this
)
<<
"Reuse downstream connection DCONN:"
<<
dconn
...
...
@@ -394,7 +393,7 @@ DownstreamConnection* ClientHandler::get_downstream_connection()
size_t
ClientHandler
::
get_pending_write_length
()
{
evbuffer
*
output
=
bufferevent_get_output
(
bev_
);
auto
output
=
bufferevent_get_output
(
bev_
);
return
evbuffer_get_length
(
output
);
}
...
...
src/shrpx_downstream_connection.cc
View file @
679a389b
...
...
@@ -31,7 +31,7 @@ namespace shrpx {
DownstreamConnection
::
DownstreamConnection
(
ClientHandler
*
client_handler
)
:
client_handler_
(
client_handler
),
downstream_
(
0
)
downstream_
(
nullptr
)
{}
DownstreamConnection
::~
DownstreamConnection
()
...
...
src/shrpx_downstream_queue.cc
View file @
679a389b
...
...
@@ -35,9 +35,8 @@ DownstreamQueue::DownstreamQueue()
DownstreamQueue
::~
DownstreamQueue
()
{
for
(
std
::
map
<
int32_t
,
Downstream
*>::
iterator
i
=
downstreams_
.
begin
();
i
!=
downstreams_
.
end
();
++
i
)
{
delete
(
*
i
).
second
;
for
(
auto
&
kv
:
downstreams_
)
{
delete
kv
.
second
;
}
}
...
...
@@ -53,11 +52,11 @@ void DownstreamQueue::remove(Downstream *downstream)
Downstream
*
DownstreamQueue
::
find
(
int32_t
stream_id
)
{
std
::
map
<
int32_t
,
Downstream
*>::
iterator
i
=
downstreams_
.
find
(
stream_id
);
if
(
i
==
downstreams_
.
end
(
))
{
return
0
;
auto
kv
=
downstreams_
.
find
(
stream_id
);
if
(
kv
==
std
::
end
(
downstreams_
))
{
return
nullptr
;
}
else
{
return
(
*
i
).
second
;
return
(
*
kv
).
second
;
}
}
...
...
src/shrpx_http2_downstream_connection.cc
View file @
679a389b
...
...
@@ -50,8 +50,8 @@ Http2DownstreamConnection::Http2DownstreamConnection
(
ClientHandler
*
client_handler
)
:
DownstreamConnection
(
client_handler
),
http2session_
(
client_handler
->
get_http2_session
()),
request_body_buf_
(
0
),
sd_
(
0
)
request_body_buf_
(
nullptr
),
sd_
(
nullptr
)
{}
Http2DownstreamConnection
::~
Http2DownstreamConnection
()
...
...
@@ -71,7 +71,7 @@ Http2DownstreamConnection::~Http2DownstreamConnection()
// Downstream and DownstreamConnection may be deleted
// asynchronously.
if
(
downstream_
)
{
downstream_
->
set_downstream_connection
(
0
);
downstream_
->
set_downstream_connection
(
nullptr
);
}
if
(
LOG_ENABLED
(
INFO
))
{
DCLOG
(
INFO
,
this
)
<<
"Deleted"
;
...
...
@@ -89,10 +89,10 @@ int Http2DownstreamConnection::init_request_body_buf()
}
}
else
{
request_body_buf_
=
evbuffer_new
();
if
(
request_body_buf_
==
0
)
{
if
(
request_body_buf_
==
nullptr
)
{
return
-
1
;
}
evbuffer_setcb
(
request_body_buf_
,
0
,
this
);
evbuffer_setcb
(
request_body_buf_
,
nullptr
,
this
);
}
return
0
;
}
...
...
@@ -122,8 +122,8 @@ void Http2DownstreamConnection::detach_downstream(Downstream *downstream)
if
(
submit_rst_stream
(
downstream
)
==
0
)
{
http2session_
->
notify
();
}
downstream
->
set_downstream_connection
(
0
);
downstream_
=
0
;
downstream
->
set_downstream_connection
(
nullptr
);
downstream_
=
nullptr
;
client_handler_
->
pool_downstream_connection
(
this
);
}
...
...
@@ -195,7 +195,7 @@ ssize_t http2_data_read_callback(nghttp2_session *session,
}
// Check dconn is still alive because Upstream::resume_read()
// may delete downstream which will delete dconn.
if
(
sd
->
dconn
==
0
)
{
if
(
sd
->
dconn
==
nullptr
)
{
return
NGHTTP2_ERR_DEFERRED
;
}
if
(
evbuffer_get_length
(
body
)
==
0
)
{
...
...
@@ -498,12 +498,12 @@ void Http2DownstreamConnection::attach_stream_data(StreamData *sd)
StreamData
*
Http2DownstreamConnection
::
detach_stream_data
()
{
if
(
sd_
)
{
StreamData
*
sd
=
sd_
;
sd_
=
0
;
sd
->
dconn
=
0
;
auto
sd
=
sd_
;
sd_
=
nullptr
;
sd
->
dconn
=
nullptr
;
return
sd
;
}
else
{
return
0
;
return
nullptr
;
}
}
...
...
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