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
5b3cb00f
Commit
5b3cb00f
authored
Nov 08, 2018
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Not pass errors to ProcessThriftFramedRequestNoExcept
parent
3af2422d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
32 deletions
+23
-32
thrift_protocol.cpp
src/brpc/policy/thrift_protocol.cpp
+21
-27
thrift_service.h
src/brpc/thrift_service.h
+2
-5
No files found.
src/brpc/policy/thrift_protocol.cpp
View file @
5b3cb00f
...
@@ -449,6 +449,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
...
@@ -449,6 +449,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
ScopedNonServiceError
non_service_error
(
server
);
ScopedNonServiceError
non_service_error
(
server
);
ThriftClosure
*
thrift_done
=
new
ThriftClosure
;
ThriftClosure
*
thrift_done
=
new
ThriftClosure
;
ClosureGuard
done_guard
(
thrift_done
);
Controller
*
cntl
=
&
(
thrift_done
->
_controller
);
Controller
*
cntl
=
&
(
thrift_done
->
_controller
);
ThriftFramedMessage
*
req
=
&
(
thrift_done
->
_request
);
ThriftFramedMessage
*
req
=
&
(
thrift_done
->
_request
);
ThriftFramedMessage
*
res
=
&
(
thrift_done
->
_response
);
ThriftFramedMessage
*
res
=
&
(
thrift_done
->
_response
);
...
@@ -471,8 +472,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
...
@@ -471,8 +472,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
butil
::
Status
st
=
ReadThriftMessageBegin
(
butil
::
Status
st
=
ReadThriftMessageBegin
(
&
msg
->
payload
,
&
cntl
->
_thrift_method_name
,
&
mtype
,
&
seq_id
);
&
msg
->
payload
,
&
cntl
->
_thrift_method_name
,
&
mtype
,
&
seq_id
);
if
(
!
st
.
ok
())
{
if
(
!
st
.
ok
())
{
cntl
->
SetFailed
(
EREQUEST
,
"%s"
,
st
.
error_cstr
());
return
cntl
->
SetFailed
(
EREQUEST
,
"%s"
,
st
.
error_cstr
());
return
thrift_done
->
Run
();
}
}
msg
->
payload
.
swap
(
req
->
body
);
msg
->
payload
.
swap
(
req
->
body
);
req
->
field_id
=
THRIFT_REQUEST_FID
;
req
->
field_id
=
THRIFT_REQUEST_FID
;
...
@@ -483,8 +483,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
...
@@ -483,8 +483,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
LOG_EVERY_SECOND
(
ERROR
)
LOG_EVERY_SECOND
(
ERROR
)
<<
"Received thrift request however the server does not set"
<<
"Received thrift request however the server does not set"
" ServerOptions.thrift_service, close the connection."
;
" ServerOptions.thrift_service, close the connection."
;
cntl
->
SetFailed
(
EINTERNAL
,
"ServerOptions.thrift_service is NULL"
);
return
cntl
->
SetFailed
(
EINTERNAL
,
"ServerOptions.thrift_service is NULL"
);
return
thrift_done
->
Run
();
}
}
// Switch to service-specific error.
// Switch to service-specific error.
...
@@ -492,10 +491,9 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
...
@@ -492,10 +491,9 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
MethodStatus
*
method_status
=
service
->
_status
;
MethodStatus
*
method_status
=
service
->
_status
;
if
(
method_status
)
{
if
(
method_status
)
{
if
(
!
method_status
->
OnRequested
())
{
if
(
!
method_status
->
OnRequested
())
{
cntl
->
SetFailed
(
ELIMIT
,
"Reached %s's max_concurrency=%d"
,
return
cntl
->
SetFailed
(
ELIMIT
,
"Reached %s's max_concurrency=%d"
,
cntl
->
thrift_method_name
().
c_str
(),
cntl
->
thrift_method_name
().
c_str
(),
method_status
->
MaxConcurrency
());
method_status
->
MaxConcurrency
());
return
thrift_done
->
Run
();
}
}
}
}
...
@@ -516,27 +514,21 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
...
@@ -516,27 +514,21 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
span
->
set_request_size
(
sizeof
(
thrift_head_t
)
+
req
->
body
.
size
());
span
->
set_request_size
(
sizeof
(
thrift_head_t
)
+
req
->
body
.
size
());
}
}
do
{
if
(
!
server
->
IsRunning
())
{
if
(
!
server
->
IsRunning
())
{
return
cntl
->
SetFailed
(
ELOGOFF
,
"Server is stopping"
);
cntl
->
SetFailed
(
ELOGOFF
,
"Server is stopping"
);
}
break
;
if
(
socket
->
is_overcrowded
())
{
}
return
cntl
->
SetFailed
(
EOVERCROWDED
,
"Connection to %s is overcrowded"
,
if
(
socket
->
is_overcrowded
())
{
butil
::
endpoint2str
(
socket
->
remote_side
()).
c_str
());
cntl
->
SetFailed
(
EOVERCROWDED
,
"Connection to %s is overcrowded"
,
}
butil
::
endpoint2str
(
socket
->
remote_side
()).
c_str
());
if
(
!
server_accessor
.
AddConcurrency
(
cntl
))
{
break
;
return
cntl
->
SetFailed
(
ELIMIT
,
"Reached server's max_concurrency=%d"
,
}
server
->
options
().
max_concurrency
);
if
(
!
server_accessor
.
AddConcurrency
(
cntl
))
{
}
cntl
->
SetFailed
(
ELIMIT
,
"Reached server's max_concurrency=%d"
,
if
(
FLAGS_usercode_in_pthread
&&
TooManyUserCode
())
{
server
->
options
().
max_concurrency
);
return
cntl
->
SetFailed
(
ELIMIT
,
"Too many user code to run when"
break
;
" -usercode_in_pthread is on"
);
}
}
if
(
FLAGS_usercode_in_pthread
&&
TooManyUserCode
())
{
cntl
->
SetFailed
(
ELIMIT
,
"Too many user code to run when"
" -usercode_in_pthread is on"
);
break
;
}
}
while
(
false
);
msg
.
reset
();
// optional, just release resourse ASAP
msg
.
reset
();
// optional, just release resourse ASAP
...
@@ -546,6 +538,8 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
...
@@ -546,6 +538,8 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
span
->
AsParent
();
span
->
AsParent
();
}
}
done_guard
.
release
();
if
(
!
FLAGS_usercode_in_pthread
)
{
if
(
!
FLAGS_usercode_in_pthread
)
{
return
ProcessThriftFramedRequestNoExcept
(
service
,
cntl
,
req
,
res
,
thrift_done
);
return
ProcessThriftFramedRequestNoExcept
(
service
,
cntl
,
req
,
res
,
thrift_done
);
}
}
...
...
src/brpc/thrift_service.h
View file @
5b3cb00f
...
@@ -38,12 +38,9 @@ public:
...
@@ -38,12 +38,9 @@ public:
ThriftService
();
ThriftService
();
virtual
~
ThriftService
();
virtual
~
ThriftService
();
// Implement this method to handle thrift_binary requests. Notice that this
// Implement this method to handle thrift_binary requests.
// method can be called with a failed Controller(something wrong with the
// request before calling this method), in which case the implemenetation
// shall send specific response with error information back to client.
// Parameters:
// Parameters:
// controller per-rpc settings.
// controller per-rpc settings.
controller->Failed() is always false.
// request The thrift_binary request received.
// request The thrift_binary request received.
// response The thrift_binary response that you should fill in.
// response The thrift_binary response that you should fill in.
// done You must call done->Run() to end the processing.
// done You must call done->Run() to end the processing.
...
...
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