]> prime8.dev >> repos - ttyd.git/commitdiff
server: fix default keepalive not working
authorShuanglei Tao <tsl0922@gmail.com>
Sat, 20 Nov 2021 15:24:31 +0000 (23:24 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sat, 20 Nov 2021 15:24:31 +0000 (23:24 +0800)
src/server.c

index f9113afd3f39bd522218a87119788ae18da2ab2b..5b72c4e0311230622382aadc0888e98f04b8fa2f 100644 (file)
@@ -437,13 +437,12 @@ int main(int argc, char **argv) {
 #if LWS_LIBRARY_VERSION_NUMBER >= 4000000
       case 'P': {
         int interval = parse_int("ping-interval", optarg);
-        if (interval <= 0) {
+        if (interval < 0) {
           fprintf(stderr, "ttyd: invalid ping interval: %s\n", optarg);
           return -1;
         }
         retry.secs_since_valid_ping = interval;
         retry.secs_since_valid_hangup = interval + 7;
-        info.retry_and_idle_policy = &retry;
       } break;
 #endif
       case '6':
@@ -511,6 +510,8 @@ int main(int argc, char **argv) {
 
 #if LWS_LIBRARY_VERSION_NUMBER < 4000000
   info.ws_ping_pong_interval = 5;
+#else
+  info.retry_and_idle_policy = &retry;
 #endif
 
   if (strlen(iface) > 0) {