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
4bd44b9c
Commit
4bd44b9c
authored
Oct 17, 2018
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Convert dispatch state to enum class
parent
1b42110d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
26 deletions
+26
-26
src/shrpx_downstream.cc
src/shrpx_downstream.cc
+3
-3
src/shrpx_downstream.h
src/shrpx_downstream.h
+11
-11
src/shrpx_downstream_queue.cc
src/shrpx_downstream_queue.cc
+5
-5
src/shrpx_downstream_queue.h
src/shrpx_downstream_queue.h
+4
-4
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+3
-3
No files found.
src/shrpx_downstream.cc
View file @
4bd44b9c
...
...
@@ -135,7 +135,7 @@ Downstream::Downstream(Upstream *upstream, MemchunkPool *mcpool,
affinity_cookie_
(
0
),
request_state_
(
DownstreamState
::
INITIAL
),
response_state_
(
DownstreamState
::
INITIAL
),
dispatch_state_
(
D
ISPATCH_
NONE
),
dispatch_state_
(
D
ispatchState
::
NONE
),
upgraded_
(
false
),
chunked_request_
(
false
),
chunked_response_
(
false
),
...
...
@@ -1067,9 +1067,9 @@ bool Downstream::request_submission_ready() const {
response_state_
==
DownstreamState
::
INITIAL
;
}
int
Downstream
::
get_dispatch_state
()
const
{
return
dispatch_state_
;
}
DispatchState
Downstream
::
get_dispatch_state
()
const
{
return
dispatch_state_
;
}
void
Downstream
::
set_dispatch_state
(
int
s
)
{
dispatch_state_
=
s
;
}
void
Downstream
::
set_dispatch_state
(
DispatchState
s
)
{
dispatch_state_
=
s
;
}
void
Downstream
::
attach_blocked_link
(
BlockedLink
*
l
)
{
assert
(
!
blocked_link_
);
...
...
src/shrpx_downstream.h
View file @
4bd44b9c
...
...
@@ -292,6 +292,14 @@ enum class DownstreamState {
HTTP1_REQUEST_HEADER_TOO_LARGE
,
};
enum
class
DispatchState
{
NONE
,
PENDING
,
BLOCKED
,
ACTIVE
,
FAILURE
,
};
class
Downstream
{
public:
Downstream
(
Upstream
*
upstream
,
MemchunkPool
*
mcpool
,
int32_t
stream_id
);
...
...
@@ -448,8 +456,8 @@ public:
// true if retry attempt should not be done.
bool
no_more_retry
()
const
;
int
get_dispatch_state
()
const
;
void
set_dispatch_state
(
int
s
);
DispatchState
get_dispatch_state
()
const
;
void
set_dispatch_state
(
DispatchState
s
);
void
attach_blocked_link
(
BlockedLink
*
l
);
BlockedLink
*
detach_blocked_link
();
...
...
@@ -490,14 +498,6 @@ public:
EVENT_TIMEOUT
=
0x2
,
};
enum
{
DISPATCH_NONE
,
DISPATCH_PENDING
,
DISPATCH_BLOCKED
,
DISPATCH_ACTIVE
,
DISPATCH_FAILURE
,
};
Downstream
*
dlnext
,
*
dlprev
;
// the length of response body sent to upstream client
...
...
@@ -561,7 +561,7 @@ private:
// response state
DownstreamState
response_state_
;
// only used by HTTP/2 upstream
int
dispatch_state_
;
DispatchState
dispatch_state_
;
// true if the connection is upgraded (HTTP Upgrade or CONNECT),
// excluding upgrade to HTTP/2.
bool
upgraded_
;
...
...
src/shrpx_downstream_queue.cc
View file @
4bd44b9c
...
...
@@ -49,12 +49,12 @@ DownstreamQueue::~DownstreamQueue() {
}
void
DownstreamQueue
::
add_pending
(
std
::
unique_ptr
<
Downstream
>
downstream
)
{
downstream
->
set_dispatch_state
(
D
ownstream
::
DISPATCH_
PENDING
);
downstream
->
set_dispatch_state
(
D
ispatchState
::
PENDING
);
downstreams_
.
append
(
downstream
.
release
());
}
void
DownstreamQueue
::
mark_failure
(
Downstream
*
downstream
)
{
downstream
->
set_dispatch_state
(
D
ownstream
::
DISPATCH_
FAILURE
);
downstream
->
set_dispatch_state
(
D
ispatchState
::
FAILURE
);
}
DownstreamQueue
::
HostEntry
&
...
...
@@ -87,13 +87,13 @@ void DownstreamQueue::mark_active(Downstream *downstream) {
auto
&
ent
=
find_host_entry
(
make_host_key
(
downstream
));
++
ent
.
num_active
;
downstream
->
set_dispatch_state
(
D
ownstream
::
DISPATCH_
ACTIVE
);
downstream
->
set_dispatch_state
(
D
ispatchState
::
ACTIVE
);
}
void
DownstreamQueue
::
mark_blocked
(
Downstream
*
downstream
)
{
auto
&
ent
=
find_host_entry
(
make_host_key
(
downstream
));
downstream
->
set_dispatch_state
(
D
ownstream
::
DISPATCH_
BLOCKED
);
downstream
->
set_dispatch_state
(
D
ispatchState
::
BLOCKED
);
auto
link
=
new
BlockedLink
{};
downstream
->
attach_blocked_link
(
link
);
...
...
@@ -131,7 +131,7 @@ Downstream *DownstreamQueue::remove_and_get_blocked(Downstream *downstream,
auto
host
=
make_host_key
(
downstream
);
auto
&
ent
=
find_host_entry
(
host
);
if
(
downstream
->
get_dispatch_state
()
==
D
ownstream
::
DISPATCH_
ACTIVE
)
{
if
(
downstream
->
get_dispatch_state
()
==
D
ispatchState
::
ACTIVE
)
{
--
ent
.
num_active
;
}
else
{
// For those downstreams deleted while in blocked state
...
...
src/shrpx_downstream_queue.h
View file @
4bd44b9c
...
...
@@ -88,10 +88,10 @@ public:
// |host|.
bool
can_activate
(
const
StringRef
&
host
)
const
;
// Removes and frees |downstream| object. If |downstream| is in
// D
ownstream::DISPATCH_ACTIVE, and |next_blocked| is true, this
//
function may return Downstream object with the same target host
//
in Downstream::DISPATCH_BLOCKED if its connection is now not
//
blocked by
conn_max_per_host_ limit.
// D
ispatchState::ACTIVE, and |next_blocked| is true, this function
//
may return Downstream object with the same target host in
//
DispatchState::BLOCKED if its connection is now not blocked by
// conn_max_per_host_ limit.
Downstream
*
remove_and_get_blocked
(
Downstream
*
downstream
,
bool
next_blocked
=
true
);
Downstream
*
get_downstreams
()
const
;
...
...
src/shrpx_http2_upstream.cc
View file @
4bd44b9c
...
...
@@ -2025,7 +2025,7 @@ int Http2Upstream::on_timeout(Downstream *downstream) {
void
Http2Upstream
::
on_handler_delete
()
{
for
(
auto
d
=
downstream_queue_
.
get_downstreams
();
d
;
d
=
d
->
dlnext
)
{
if
(
d
->
get_dispatch_state
()
==
D
ownstream
::
DISPATCH_
ACTIVE
&&
if
(
d
->
get_dispatch_state
()
==
D
ispatchState
::
ACTIVE
&&
d
->
accesslog_ready
())
{
handler_
->
write_accesslog
(
d
);
}
...
...
@@ -2035,10 +2035,10 @@ void Http2Upstream::on_handler_delete() {
int
Http2Upstream
::
on_downstream_reset
(
Downstream
*
downstream
,
bool
no_retry
)
{
int
rv
;
if
(
downstream
->
get_dispatch_state
()
!=
D
ownstream
::
DISPATCH_
ACTIVE
)
{
if
(
downstream
->
get_dispatch_state
()
!=
D
ispatchState
::
ACTIVE
)
{
// This is error condition when we failed push_request_headers()
// in initiate_downstream(). Otherwise, we have
// D
ownstream::DISPATCH_
ACTIVE state, or we did not set
// D
ispatchState::
ACTIVE state, or we did not set
// DownstreamConnection.
downstream
->
pop_downstream_connection
();
handler_
->
signal_write
();
...
...
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