This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gokdrive.

commit c31000fc25d9d822ddd24731ab4c0fbe62b81a28
Author: Mihai Moldovan <io...@ionic.de>
Date:   Thu Feb 29 23:32:19 2024 +0100

    x2gokdriveremote.{c,h}: use a client keepalive timeout of 120 seconds for 
the web client, keep other clients on 30 seconds.
    
    Web browsers throttle JavaScript timers of background tabs for energy
    saving reasons.
    
    Even though Chrome and Firefox refrain from aggressive throttling when
    tabs use WebSocket connections, this might not always work correctly.
    
    Since timers typically coalesce at one-minute intervals, a two-minutes
    timeout should be fine.
---
 debian/changelog   | 10 ++++++++++
 x2gokdriveremote.c | 21 +++++++++++++++++----
 x2gokdriveremote.h |  3 ++-
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 19a255e..622c377 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,16 @@ x2gokdrive (0.0.0.3-0x2go1) UNRELEASED; urgency=medium
     + Add semi-auto-detection of latest available patchset and fallback to that
       if we don't have a patchset for an exact xorg-server version.
 
+  [ Mihai Moldovan ]
+  * New upstream version (0.0.0.3):
+    - x2gokdriveremote.{c,h}: use a client keepalive timeout of 120 seconds
+      for the web client, keep other clients on 30 seconds. Web browsers
+      throttle JavaScript timers of background tabs for energy saving reasons.
+      Even though Chrome and Firefox refrain from aggressive throttling when
+      tabs use WebSocket connections, this might not always work correctly.
+      Since timers typically coalesce at one-minute intervals, a two-minutes
+      timeout should be fine.
+
  -- X2Go Release Manager <git-ad...@x2go.org>  Tue, 12 Sep 2023 22:28:20 +0200
 
 x2gokdrive (0.0.0.2-0x2go1) unstable; urgency=medium
diff --git a/x2gokdriveremote.c b/x2gokdriveremote.c
index fdbf662..6f3934e 100644
--- a/x2gokdriveremote.c
+++ b/x2gokdriveremote.c
@@ -105,6 +105,18 @@ static struct _remoteHostVars remoteVars = {0};
 
 static BOOL remoteInitialized=FALSE;
 
+static
+CARD32 get_keepalive(const uint16_t os)
+{
+    CARD32 ret = CLIENTALIVE_TIMEOUT_GENERIC;
+
+    if (WEB == os)
+    {
+        ret = CLIENTALIVE_TIMEOUT_WEB;
+    }
+
+    return ret;
+}
 
 void remote_selection_init(void)
 {
@@ -2474,7 +2486,7 @@ BOOL remote_process_client_event ( char* buff , int 
length)
     remoteVars.last_client_keepalive_time=time(NULL);
     if(remoteVars.client_version>=3 && remoteVars.checkKeepAliveTimer)
     {
-        
remoteVars.checkKeepAliveTimer=TimerSet(remoteVars.checkKeepAliveTimer,0,CLIENTALIVE_TIMEOUT,
 checkClientAlive, NULL);
+        
remoteVars.checkKeepAliveTimer=TimerSet(remoteVars.checkKeepAliveTimer,0,get_keepalive
 (remoteVars.client_os), checkClientAlive, NULL);
     }
 
     pthread_mutex_unlock(&remoteVars.sendqueue_mutex);
@@ -2946,7 +2958,7 @@ void set_client_version(uint16_t ver, uint16_t os)
     {
         //start timer for checking if client alive
         pthread_mutex_lock(&remoteVars.sendqueue_mutex);
-        remoteVars.checkKeepAliveTimer=TimerSet(0,0,CLIENTALIVE_TIMEOUT, 
checkClientAlive, NULL);
+        remoteVars.checkKeepAliveTimer=TimerSet(0,0,get_keepalive 
(remoteVars.client_os), checkClientAlive, NULL);
         pthread_mutex_unlock(&remoteVars.sendqueue_mutex);
     }
 }
@@ -5266,17 +5278,18 @@ unsigned int
 checkClientAlive(OsTimerPtr timer, CARD32 time_card, void* args)
 {
     time_t time_diff;
+    CARD32 timeout = get_keepalive(remoteVars.client_os);
     pthread_mutex_lock(&remoteVars.sendqueue_mutex);
     time_diff=time(NULL)-remoteVars.last_client_keepalive_time;
     pthread_mutex_unlock(&remoteVars.sendqueue_mutex);
 
-    if(time_diff>=CLIENTALIVE_TIMEOUT/1000)
+    if(time_diff>=timeout/1000)
     {
         EPHYR_DBG("no data from client since %d seconds, disconnecting...", 
(int)time_diff);
         disconnect_client();
         return 0;
     }
-    return CLIENTALIVE_TIMEOUT;
+    return timeout;
 }
 
 void
diff --git a/x2gokdriveremote.h b/x2gokdriveremote.h
index 0b9c57c..9d30690 100644
--- a/x2gokdriveremote.h
+++ b/x2gokdriveremote.h
@@ -114,7 +114,8 @@
 #define DEFAULT_PORT 15000
 
 #define ACCEPT_TIMEOUT 30000 //msec
-#define CLIENTALIVE_TIMEOUT 30000 //msec
+#define CLIENTALIVE_TIMEOUT_GENERIC 30000 //msec
+#define CLIENTALIVE_TIMEOUT_WEB 120000 //msec
 #define SERVERALIVE_TIMEOUT 10 //sec
 
 //if true, will save compressed jpg in file

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on 
/srv/git/code.x2go.org/x2gokdrive.git
_______________________________________________
x2go-commits mailing list
x2go-commits@lists.x2go.org
https://lists.x2go.org/listinfo/x2go-commits

Reply via email to