mirror of
https://github.com/zhaojh329/rtty.git
synced 2026-02-27 09:53:17 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user