perf: Limit the heartbeat interval to no more than 255.

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2025-06-12 11:46:16 +08:00
parent 682ce33cd2
commit b6bb4e69ca
2 changed files with 9 additions and 3 deletions

View File

@@ -147,11 +147,17 @@ int main(int argc, char **argv)
rtty.devid = optarg;
break;
case 'i':
rtty.heartbeat = atof(optarg);
rtty.heartbeat = atoi(optarg);
if (rtty.heartbeat < 5) {
rtty.heartbeat = 5.0;
rtty.heartbeat = 5;
log_warn("Heartbeat interval too short, set to 5s\n");
}
if (rtty.heartbeat > 255) {
rtty.heartbeat = 255;
log_warn("Heartbeat interval too long, set to 255s\n");
}
break;
case 'h':
rtty.host = optarg;

View File

@@ -95,7 +95,7 @@ struct rtty {
struct ev_io ior;
struct ev_timer tmr;
struct ev_loop *loop;
ev_tstamp heartbeat;
int heartbeat;
bool wait_heartbeat;
bool registered;
bool reconnect;