Optimize heartbeat response processing

If other messages are received for a long time, causing the heartbeat
packet to be delayed in being received, it will lead to a heartbeat
timeout and disconnection. However, if other data arrives, we consider
the server to be active.

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2025-07-02 17:00:36 +08:00
parent 29f3625f42
commit 42b06c8710

View File

@@ -481,6 +481,8 @@ static int parse_msg(struct rtty *rtty)
log_debug("recv msg: %s\n", msg_type_name(msgtype));
rtty->wait_heartbeat = false;
switch (msgtype) {
case MSG_TYPE_REGISTER:
if (buffer_pull_u8(rb)) {
@@ -512,7 +514,6 @@ static int parse_msg(struct rtty *rtty)
break;
case MSG_TYPE_HEARTBEAT:
rtty->wait_heartbeat = false;
ev_timer_set(&rtty->tmr, 0, rtty->heartbeat);
ev_timer_again(rtty->loop, &rtty->tmr);
break;