From 4eed1a6da8afed6edec2c3c78ec701063020b1e3 Mon Sep 17 00:00:00 2001 From: matyhtf Date: Wed, 26 May 2021 17:42:56 +0800 Subject: [PATCH] Optimize code for setting heartbeat_idle_time --- ext-src/swoole_server.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext-src/swoole_server.cc b/ext-src/swoole_server.cc index 8986b0887a8..68e8dedf0b5 100644 --- a/ext-src/swoole_server.cc +++ b/ext-src/swoole_server.cc @@ -2390,7 +2390,8 @@ static PHP_METHOD(swoole_server, set) { php_swoole_fatal_error(E_WARNING, "heartbeat_idle_time must be greater than heartbeat_check_interval"); serv->heartbeat_check_interval = serv->heartbeat_idle_time / 2; } - } else if (serv->heartbeat_check_interval > 0) { + } + if (serv->heartbeat_idle_time == 0 && serv->heartbeat_check_interval > 0) { serv->heartbeat_idle_time = serv->heartbeat_check_interval * 2; } // max_request