Commit 05af6714 authored by zhujiashun's avatar zhujiashun

add _deadline_us impl to Controller::IsCanceled

parent 5c707561
......@@ -457,7 +457,8 @@ void Controller::CloseConnection(const char* reason_fmt, ...) {
bool Controller::IsCanceled() const {
SocketUniquePtr sock;
return (Socket::Address(_current_call.peer_id, &sock) != 0);
return (Socket::Address(_current_call.peer_id, &sock) != 0) ||
(_deadline_us >= 0 && butil::gettimeofday_us() >= _deadline_us);
}
class RunOnCancelThread {
......
......@@ -71,6 +71,13 @@ public:
} else {
EXPECT_NEAR(cntl->deadline_us(),
butil::gettimeofday_us() + req->timeout_us(), 30);
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