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
bab70ab0
Commit
bab70ab0
authored
Jul 12, 2018
by
wangxuefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update as comments.
parent
e634500c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
24 deletions
+32
-24
server.cpp
example/thrift_extension_c++/server.cpp
+1
-2
controller.h
src/brpc/controller.h
+1
-1
thrift_protocol.cpp
src/brpc/policy/thrift_protocol.cpp
+30
-21
No files found.
example/thrift_extension_c++/server.cpp
View file @
bab70ab0
...
...
@@ -80,8 +80,7 @@ public:
res
->
data
=
req
->
data
+
" (processed directly)"
;
}
LOG
(
INFO
)
<<
"Process success in server side for thrift_method_name: "
<<
cntl
->
thrift_method_name
();
}
private
:
...
...
src/brpc/controller.h
View file @
bab70ab0
...
...
@@ -454,7 +454,7 @@ public:
void
set_thrift_method_name
(
const
std
::
string
&
method_name
)
{
_thrift_method_name
=
method_name
;
}
std
::
string
thrift_method_name
()
{
return
_thrift_method_name
;
}
const
std
::
string
&
thrift_method_name
()
{
return
_thrift_method_name
;
}
private
:
struct
CompletionInfo
{
...
...
src/brpc/policy/thrift_protocol.cpp
View file @
bab70ab0
...
...
@@ -47,12 +47,12 @@
#endif
extern
"C"
{
void
bthread_assign_data
(
void
*
data
);
void
bthread_assign_data
(
void
*
data
)
__THROW
;
}
namespace
brpc
{
int32_t
get
_thrift_method_name
(
const
butil
::
IOBuf
&
body
,
std
::
string
*
method_name
)
{
static
int32_t
parse
_thrift_method_name
(
const
butil
::
IOBuf
&
body
,
std
::
string
*
method_name
)
{
// Thrift protocol format:
// Version + Message type + Length + Method + Sequence Id
...
...
@@ -144,7 +144,7 @@ void ThriftClosure::Run() {
_response
.
head
=
_request
.
head
;
if
(
_response
.
thrift_raw_instance
)
{
std
::
string
method_name
=
_controller
.
thrift_method_name
();
const
std
::
string
&
method_name
=
_controller
.
thrift_method_name
();
if
(
method_name
==
""
||
method_name
.
length
()
<
1
||
method_name
[
0
]
==
' '
)
{
...
...
@@ -282,8 +282,8 @@ static void CallMethodInBackupThread(void* void_args) {
CallMethodInBackupThreadArgs
*
args
=
(
CallMethodInBackupThreadArgs
*
)
void_args
;
std
::
string
method_name
;
if
(
get
_thrift_method_name
(
args
->
request
->
body
,
&
method_name
)
<
0
)
{
LOG
(
FATAL
)
<<
"Fail to get thrift method name"
;
if
(
parse
_thrift_method_name
(
args
->
request
->
body
,
&
method_name
)
<
0
)
{
LOG
(
ERROR
)
<<
"Fail to get thrift method name"
;
delete
args
;
return
;
}
...
...
@@ -421,28 +421,37 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
span
->
AsParent
();
}
try
{
std
::
string
method_name
;
if
(
get_thrift_method_name
(
req
->
body
,
&
method_name
)
<
0
)
{
cntl
->
SetFailed
(
EREQUEST
,
"Fail to get thrift method name!"
)
;
}
cntl
->
set_thrift_method_name
(
method_name
);
std
::
string
method_name
;
if
(
parse_thrift_method_name
(
req
->
body
,
&
method_name
)
<
0
)
{
cntl
->
SetFailed
(
EREQUEST
,
"Fail to get thrift method name!"
);
return
;
}
cntl
->
set_thrift_method_name
(
method_name
);
if
(
!
FLAGS_usercode_in_pthread
)
{
if
(
!
FLAGS_usercode_in_pthread
)
{
try
{
return
service
->
ProcessThriftFramedRequest
(
*
server
,
cntl
,
req
,
res
,
thrift_done
);
}
catch
(
::
apache
::
thrift
::
TException
&
e
)
{
cntl
->
SetFailed
(
EREQUEST
,
"Invalid request data, reason: %s"
,
e
.
what
());
}
catch
(...)
{
cntl
->
SetFailed
(
EINTERNAL
,
"Internal server error!"
);
}
if
(
BeginRunningUserCode
())
{
}
if
(
BeginRunningUserCode
())
{
try
{
service
->
ProcessThriftFramedRequest
(
*
server
,
cntl
,
req
,
res
,
thrift_done
);
return
EndRunningUserCodeInPlace
();
}
else
{
return
EndRunningCallMethodInPool
(
service
,
*
server
,
cntl
,
req
,
res
,
thrift_done
);
}
catch
(
::
apache
::
thrift
::
TException
&
e
)
{
cntl
->
SetFailed
(
EREQUEST
,
"Invalid request data, reason: %s"
,
e
.
what
());
}
catch
(...)
{
cntl
->
SetFailed
(
EINTERNAL
,
"Internal server error!"
);
}
}
catch
(
::
apache
::
thrift
::
TException
&
e
)
{
cntl
->
SetFailed
(
EREQUEST
,
"Invalid request data, reason: %s"
,
e
.
what
());
}
catch
(...)
{
cntl
->
SetFailed
(
EINTERNAL
,
"Internal server error!"
);
return
EndRunningUserCodeInPlace
();
}
else
{
return
EndRunningCallMethodInPool
(
service
,
*
server
,
cntl
,
req
,
res
,
thrift_done
);
}
}
...
...
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