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
ed3133e1
Commit
ed3133e1
authored
Oct 30, 2018
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix an issue that thrift_done->Run() does nothing
parent
3afac97f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
thrift_protocol.cpp
src/brpc/policy/thrift_protocol.cpp
+14
-8
No files found.
src/brpc/policy/thrift_protocol.cpp
View file @
ed3133e1
...
...
@@ -187,8 +187,9 @@ public:
// [Required] Call this to send response back to the client.
void
Run
()
override
;
// Run() is suspended before this method is called.
void
AllowToRun
();
// Suspend/resume calling DoRun().
void
SuspendRunning
();
void
ResumeRunning
();
private
:
void
DoRun
();
...
...
@@ -202,21 +203,25 @@ friend void ProcessThriftRequest(InputMessageBase* msg_base);
};
inline
ThriftClosure
::
ThriftClosure
()
:
_run_counter
(
0
),
_received_us
(
0
)
{
:
_run_counter
(
1
),
_received_us
(
0
)
{
}
ThriftClosure
::~
ThriftClosure
()
{
LogErrorTextAndDelete
(
false
)(
&
_controller
);
}
inline
void
ThriftClosure
::
AllowToRun
()
{
if
(
_run_counter
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
)
==
1
)
{
inline
void
ThriftClosure
::
SuspendRunning
()
{
_run_counter
.
fetch_add
(
1
,
butil
::
memory_order_relaxed
);
}
inline
void
ThriftClosure
::
ResumeRunning
()
{
if
(
_run_counter
.
fetch_sub
(
1
,
butil
::
memory_order_relaxed
)
==
1
)
{
DoRun
();
}
}
void
ThriftClosure
::
Run
()
{
if
(
_run_counter
.
fetch_
add
(
1
,
butil
::
memory_order_relaxed
)
==
1
)
{
if
(
_run_counter
.
fetch_
sub
(
1
,
butil
::
memory_order_relaxed
)
==
1
)
{
DoRun
();
}
}
...
...
@@ -385,8 +390,9 @@ inline void ProcessThriftFramedRequestNoExcept(ThriftService* service,
ThriftFramedMessage
*
req
,
ThriftFramedMessage
*
res
,
ThriftClosure
*
done
)
{
// NOTE: done is not actually run before
AllowToRun
() is called so that
// NOTE: done is not actually run before
ResumeRunning
() is called so that
// we can still set `cntl' in the catch branch.
done
->
SuspendRunning
();
try
{
service
->
ProcessThriftFramedRequest
(
cntl
,
req
,
res
,
done
);
}
catch
(
std
::
exception
&
e
)
{
...
...
@@ -398,7 +404,7 @@ inline void ProcessThriftFramedRequestNoExcept(ThriftService* service,
}
catch
(...)
{
cntl
->
SetFailed
(
EINTERNAL
,
"Catched unknown exception"
);
}
done
->
AllowToRun
();
done
->
ResumeRunning
();
}
struct
CallMethodInBackupThreadArgs
{
...
...
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