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
7ec155ee
Commit
7ec155ee
authored
Nov 03, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove deadline related code in isCanceled()
parent
c96a9f59
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
18 deletions
+7
-18
controller.cpp
src/brpc/controller.cpp
+1
-4
controller.h
src/brpc/controller.h
+6
-7
brpc_grpc_protocol_unittest.cpp
test/brpc_grpc_protocol_unittest.cpp
+0
-7
No files found.
src/brpc/controller.cpp
View file @
7ec155ee
...
...
@@ -456,11 +456,8 @@ void Controller::CloseConnection(const char* reason_fmt, ...) {
}
bool
Controller
::
IsCanceled
()
const
{
if
(
_deadline_us
>=
0
&&
butil
::
gettimeofday_us
()
>=
_deadline_us
)
{
return
false
;
}
SocketUniquePtr
sock
;
return
Socket
::
Address
(
_current_call
.
peer_id
,
&
sock
)
!=
0
;
return
(
Socket
::
Address
(
_current_call
.
peer_id
,
&
sock
)
!=
0
)
;
}
class
RunOnCancelThread
{
...
...
src/brpc/controller.h
View file @
7ec155ee
...
...
@@ -309,9 +309,11 @@ public:
// undefined on the client side (may crash).
// ------------------------------------------------------------------------
// Returns true if the client canceled the RPC or the connection has broken
// or deadline has been reached, so the server may as well give up on replying
// to it. The server should still call the final "done" callback.
// Returns true if the client canceled the RPC or the connection has broken,
// so the server may as well give up on replying to it. The server should still
// call the final "done" callback.
// Note: Reaching deadline of the RPC would not affect this function, which means
// even if deadline has been reached, this function may still returns false.
bool
IsCanceled
()
const
;
// Asks that the given callback be called when the RPC is canceled or the
...
...
@@ -319,11 +321,8 @@ public:
// If the RPC completes without being canceled/broken connection, the callback
// will be called after completion. If the RPC has already been canceled/broken
// when NotifyOnCancel() is called, the callback will be called immediately.
// NotifyOnCancel() must be called no more than once per request.
//
// NOTE: If the RPC is canceled since deadline has been reached, the callback
// would not be called immediately and still be called after the completion of
// RPC.
// NotifyOnCancel() must be called no more than once per request.
void
NotifyOnCancel
(
google
::
protobuf
::
Closure
*
callback
);
// Returns the authenticated result. NULL if there is no authentication
...
...
test/brpc_grpc_protocol_unittest.cpp
View file @
7ec155ee
...
...
@@ -71,13 +71,6 @@ public:
}
else
{
EXPECT_NEAR
(
cntl
->
deadline_us
(),
butil
::
gettimeofday_us
()
+
req
->
timeout_us
(),
60
);
if
(
req
->
timeout_us
()
<
10
)
{
bthread_usleep
(
req
->
timeout_us
()
+
1
);
EXPECT_TRUE
(
cntl
->
IsCanceled
());
}
else
{
EXPECT_FALSE
(
cntl
->
IsCanceled
());
}
}
}
}
...
...
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