Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
7bee77b3
Commit
7bee77b3
authored
Feb 01, 2018
by
Zhangyi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail the RPC ASSP if the sending socket is overcrowded
parent
d28ae56f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
0 deletions
+32
-0
baidu_rpc_protocol.cpp
src/brpc/policy/baidu_rpc_protocol.cpp
+7
-0
http_rpc_protocol.cpp
src/brpc/policy/http_rpc_protocol.cpp
+5
-0
hulu_pbrpc_protocol.cpp
src/brpc/policy/hulu_pbrpc_protocol.cpp
+6
-0
nshead_protocol.cpp
src/brpc/policy/nshead_protocol.cpp
+5
-0
sofa_pbrpc_protocol.cpp
src/brpc/policy/sofa_pbrpc_protocol.cpp
+6
-0
socket.h
src/brpc/socket.h
+3
-0
No files found.
src/brpc/policy/baidu_rpc_protocol.cpp
View file @
7bee77b3
...
...
@@ -386,12 +386,19 @@ void ProcessRpcRequest(InputMessageBase* msg_base) {
cntl
->
SetFailed
(
ELOGOFF
,
"Server is stopping"
);
break
;
}
if
(
socket
->
is_overcrowded
())
{
cntl
->
SetFailed
(
EOVERCROWDED
,
"Connection to %s is overcrowded"
,
butil
::
endpoint2str
(
socket
->
remote_side
()).
c_str
());
break
;
}
if
(
!
server_accessor
.
AddConcurrency
(
cntl
.
get
()))
{
cntl
->
SetFailed
(
ELIMIT
,
"Reached server's max_concurrency=%d"
,
server
->
options
().
max_concurrency
);
break
;
}
if
(
FLAGS_usercode_in_pthread
&&
TooManyUserCode
())
{
cntl
->
SetFailed
(
ELIMIT
,
"Too many user code to run when"
" -usercode_in_pthread is on"
);
...
...
src/brpc/policy/http_rpc_protocol.cpp
View file @
7bee77b3
...
...
@@ -1183,6 +1183,11 @@ void ProcessHttpRequest(InputMessageBase *msg) {
// NOTE: accesses to builtin services are not counted as part of
// concurrency, therefore are not limited by ServerOptions.max_concurrency.
if
(
!
sp
->
is_builtin_service
&&
!
sp
->
params
.
is_tabbed
)
{
if
(
socket
->
is_overcrowded
())
{
cntl
->
SetFailed
(
EOVERCROWDED
,
"Connection to %s is overcrowded"
,
butil
::
endpoint2str
(
socket
->
remote_side
()).
c_str
());
return
SendHttpResponse
(
cntl
.
release
(),
server
,
method_status
);
}
if
(
!
server_accessor
.
AddConcurrency
(
cntl
.
get
()))
{
cntl
->
SetFailed
(
ELIMIT
,
"Reached server's max_concurrency=%d"
,
server
->
options
().
max_concurrency
);
...
...
src/brpc/policy/hulu_pbrpc_protocol.cpp
View file @
7bee77b3
...
...
@@ -418,6 +418,12 @@ void ProcessHuluRequest(InputMessageBase* msg_base) {
break
;
}
if
(
socket
->
is_overcrowded
())
{
cntl
->
SetFailed
(
EOVERCROWDED
,
"Connection to %s is overcrowded"
,
butil
::
endpoint2str
(
socket
->
remote_side
()).
c_str
());
break
;
}
if
(
!
server_accessor
.
AddConcurrency
(
cntl
.
get
()))
{
cntl
->
SetFailed
(
ELIMIT
,
"Reached server's max_concurrency=%d"
,
server
->
options
().
max_concurrency
);
...
...
src/brpc/policy/nshead_protocol.cpp
View file @
7bee77b3
...
...
@@ -290,6 +290,11 @@ void ProcessNsheadRequest(InputMessageBase* msg_base) {
cntl
->
SetFailed
(
ELOGOFF
,
"Server is stopping"
);
break
;
}
if
(
socket
->
is_overcrowded
())
{
cntl
->
SetFailed
(
EOVERCROWDED
,
"Connection to %s is overcrowded"
,
butil
::
endpoint2str
(
socket
->
remote_side
()).
c_str
());
break
;
}
if
(
!
server_accessor
.
AddConcurrency
(
cntl
))
{
cntl
->
SetFailed
(
ELIMIT
,
"Reached server's max_concurrency=%d"
,
server
->
options
().
max_concurrency
);
...
...
src/brpc/policy/sofa_pbrpc_protocol.cpp
View file @
7bee77b3
...
...
@@ -382,6 +382,12 @@ void ProcessSofaRequest(InputMessageBase* msg_base) {
break
;
}
if
(
socket
->
is_overcrowded
())
{
cntl
->
SetFailed
(
EOVERCROWDED
,
"Connection to %s is overcrowded"
,
butil
::
endpoint2str
(
socket
->
remote_side
()).
c_str
());
break
;
}
if
(
!
server_accessor
.
AddConcurrency
(
cntl
.
get
()))
{
cntl
->
SetFailed
(
ELIMIT
,
"Reached server's max_concurrency=%d"
,
server
->
options
().
max_concurrency
);
...
...
src/brpc/socket.h
View file @
7bee77b3
...
...
@@ -452,6 +452,9 @@ public:
// A brief description of this socket, consistent with os << *this
std
::
string
description
()
const
;
// Returns true if the remote side is overcrowded.
bool
is_overcrowded
()
const
{
return
_overcrowded
;
}
private
:
DISALLOW_COPY_AND_ASSIGN
(
Socket
);
...
...
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