Commit 77566c87 authored by zhujiashun's avatar zhujiashun

health_check_using_rpc: fix leak & change the time of setting _health_check_using_rpc

parent 95b8f54f
...@@ -987,7 +987,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) { ...@@ -987,7 +987,7 @@ void Controller::IssueRPC(int64_t start_realtime_us) {
// of the backup call. // of the backup call.
const int rc = Socket::Address(_single_server_id, &tmp_sock); const int rc = Socket::Address(_single_server_id, &tmp_sock);
if (rc != 0 || tmp_sock->IsLogOff() || if (rc != 0 || tmp_sock->IsLogOff() ||
(!has_flag(FLAGS_HEALTH_CHECK_CALL) && tmp_sock->IsHealthCheckingUsingRPC())) { (!is_health_check_call() && tmp_sock->IsHealthCheckingUsingRPC())) {
SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64, SetFailed(EHOSTDOWN, "Not connected to %s yet, server_id=%" PRIu64,
endpoint2str(_remote_side).c_str(), _single_server_id); endpoint2str(_remote_side).c_str(), _single_server_id);
tmp_sock.reset(); // Release ref ASAP tmp_sock.reset(); // Release ref ASAP
......
...@@ -589,7 +589,7 @@ private: ...@@ -589,7 +589,7 @@ private:
// Tell RPC that this particular call is used to do health check. // Tell RPC that this particular call is used to do health check.
void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); } void set_health_check_call(bool f) { set_flag(FLAGS_HEALTH_CHECK_CALL, f); }
bool has_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); } bool is_health_check_call() const { return has_flag(FLAGS_HEALTH_CHECK_CALL); }
public: public:
CallId current_id() const { CallId current_id() const {
......
...@@ -758,7 +758,11 @@ int Socket::WaitAndReset(int32_t expected_nref) { ...@@ -758,7 +758,11 @@ int Socket::WaitAndReset(int32_t expected_nref) {
_pipeline_q->clear(); _pipeline_q->clear();
} }
} }
_health_checking_using_rpc.store(false, butil::memory_order_relaxed); if (!FLAGS_health_check_path.empty()) {
_health_checking_using_rpc.store(true, butil::memory_order_relaxed);
} else {
_health_checking_using_rpc.store(false, butil::memory_order_relaxed);
}
return 0; return 0;
} }
...@@ -793,9 +797,6 @@ void Socket::Revive() { ...@@ -793,9 +797,6 @@ void Socket::Revive() {
} else { } else {
LOG(INFO) << "Revived " << *this; LOG(INFO) << "Revived " << *this;
} }
if (!FLAGS_health_check_path.empty()) {
_health_checking_using_rpc.store(true, butil::memory_order_relaxed);
}
return; return;
} }
} }
...@@ -1070,6 +1071,7 @@ public: ...@@ -1070,6 +1071,7 @@ public:
if (done->channel.Init(id, &options) != 0) { if (done->channel.Init(id, &options) != 0) {
LOG(WARNING) << "Fail to init health check channel to SocketId=" << id; LOG(WARNING) << "Fail to init health check channel to SocketId=" << id;
ptr->ResetHealthCheckingUsingRPC(); ptr->ResetHealthCheckingUsingRPC();
delete done;
return; return;
} }
done->cntl.http_request().uri() = FLAGS_health_check_path; done->cntl.http_request().uri() = FLAGS_health_check_path;
......
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