Commit 7ec155ee authored by zhujiashun's avatar zhujiashun

remove deadline related code in isCanceled()

parent c96a9f59
......@@ -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 {
......
......@@ -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
......
......@@ -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());
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment