]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
common_api: output at least something every timeout (10) seconds,
authorBram Matthys <redacted>
Sun, 16 Apr 2023 16:05:36 +0000 (18:05 +0200)
committerBram Matthys <redacted>
Sun, 16 Apr 2023 16:05:36 +0000 (18:05 +0200)
otherwise PHP may not notice when the webclient is gone.
Then the process could exist 'forever' and hang Apache after it
has gone through all it threads/processes.

api/common_api.php

index 3681d0a65ae121247600327b44b432149fc9cd6d..d94ef685532510f07f189cb3e836327b7e6dd4a2 100644 (file)
@@ -56,7 +56,14 @@ function api_log_loop($sources)
        {
                $res = $rpc->eventloop();
                if (!$res)
+               {
+                       /* Output at least something every timeout (10) seconds,
+                        * otherwise PHP may not
+                        * notice when the webclient is gone.
+                        */
+                       echo "\n";
                        continue;
+               }
                send_sse($res);
        }
 }
@@ -83,7 +90,14 @@ function api_timer_loop(int $every_msec, string $method, array|null $params = nu
        {
                $res = $rpc->eventloop();
                if (!$res)
+               {
+                       /* Output at least something every timeout (10) seconds,
+                        * otherwise PHP may not
+                        * notice when the webclient is gone.
+                        */
+                       echo "\n";
                        continue;
+               }
                send_sse($res);
        }
 }