Commit c8160cf7 authored by gejun's avatar gejun

Delay HC to avoid HC-timing issues in UT

parent 79d0f866
......@@ -969,9 +969,9 @@ void Controller::IssueRPC(int64_t start_realtime_us) {
// of the backup call.
const int rc = Socket::Address(_single_server_id, &tmp_sock);
if (rc != 0 || tmp_sock->IsLogOff()) {
SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64,
endpoint2str(_remote_side).c_str(), _single_server_id);
tmp_sock.reset(); // Release ref ASAP
SetFailed(EHOSTDOWN, "Not connected to %s yet",
endpoint2str(_remote_side).c_str());
return HandleSendFailed();
}
_current_call.peer_id = _single_server_id;
......
......@@ -48,13 +48,15 @@ public:
int CheckHealth(Socket* ptr) {
if (ptr->health_check_count() == 0) {
LOG(INFO) << "Checking " << *chan;
LOG(INFO) << "Checking " << *chan << " chan=0x" << (void*)chan
<< " Fake" << *ptr;
}
return chan->CheckHealth();
}
void AfterRevived(Socket*) {
LOG(INFO) << "Revived " << *chan;
void AfterRevived(Socket* ptr) {
LOG(INFO) << "Revived " << *chan << " chan=0x" << (void*)chan
<< " Fake" << *ptr;
}
};
......
......@@ -833,10 +833,12 @@ int Socket::SetFailed(int error_code, const char* error_fmt, ...) {
// FIXME(gejun): the initial delay should be related to uncommited
// CircuitBreaker and shorter for occasional errors and longer for
// frequent errors.
// NOTE: the delay should be positive right now to avoid HC timing
// issues in UT.
if (_health_check_interval_s > 0) {
PeriodicTaskManager::StartTaskAt(
new HealthCheckTask(id()),
butil::milliseconds_from_now(0)/*FIXME*/);
butil::milliseconds_from_now(100/*NOTE*/));
}
// Wake up all threads waiting on EPOLLOUT when closing fd
_epollout_butex->fetch_add(1, butil::memory_order_relaxed);
......@@ -2613,6 +2615,7 @@ std::string Socket::description() const {
if (local_port > 0) {
butil::string_appendf(&result, "@%d", local_port);
}
butil::string_appendf(&result, " (0x%p)", this);
return result;
}
......@@ -2641,6 +2644,7 @@ ostream& operator<<(ostream& os, const brpc::Socket& sock) {
if (local_port > 0) {
os << '@' << local_port;
}
os << " (0x" << (void*)&sock << ')';
return os;
}
}
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