Bläddra i källkod

gh-1332 - Reduce dafilesrv inactive client logging

A connected inactive client (>12mins), was being checked every minute
to see if was still alive and if it was "Inactice client" messages for all
files from the client were being logged.
This can be excessive in some situations.

Still want to check per minute, but add extra timeout to control frequency
of warning

Signed-off-by: Jake Smith <jake.smith@lexisnexis.com>
Jake Smith 13 år sedan
förälder
incheckning
071cc69557
1 ändrade filer med 15 tillägg och 3 borttagningar
  1. 15 3
      common/remote/sockfile.cpp

+ 15 - 3
common/remote/sockfile.cpp

@@ -202,6 +202,7 @@ bool enableDafsAuthentication(bool on)
 
 
 #define CLIENT_TIMEOUT      (1000*60*60*12)     // long timeout in case zombies
+#define CLIENT_INACTIVEWARNING_TIMEOUT (1000*60*60*12) // time between logging inactive clients
 #define SERVER_TIMEOUT      (1000*60*5)         // timeout when waiting for dafilesrv to reply after command
                                                 // (increased when waiting for large block)
 #define DAFS_CONNECT_FAIL_RETRY_TIME (1000*60*15)
@@ -2989,7 +2990,7 @@ class CRemoteFileServer : public CInterface, implements IRemoteFileServer, imple
         Owned<IDirectoryIterator> opendir;
         StringAttrArray     opennames;      // for debug
         IntArray            handles;
-        unsigned            lasttick;
+        unsigned            lasttick, lastInactiveTick;
         atomic_t            &globallasttick;
         unsigned            previdx;        // for debug
 
@@ -3171,9 +3172,20 @@ class CRemoteFileServer : public CInterface, implements IRemoteFileServer, imple
             return (msTick()-lasttick)>CLIENT_TIMEOUT;
         }
 
+        bool inactiveTimedOut()
+        {
+            unsigned ms = msTick();
+            if ((ms-lastInactiveTick)>CLIENT_INACTIVEWARNING_TIMEOUT)
+            {
+                lastInactiveTick = ms;
+                return true;
+            }
+            return false;
+        }
+
         void touch()
         {
-            lasttick = msTick();
+            lastInactiveTick = lasttick = msTick();
             atomic_set(&globallasttick,lasttick);
         }
 
@@ -4531,7 +4543,7 @@ public:
                 StringBuffer s;
                 bool ok = client.getInfo(s);    // will spot duff sockets
                 if (ok&&(client.handles.ordinality()!=0))  {
-                    if (TF_TRACE_CLIENT_CONN) 
+                    if (TF_TRACE_CLIENT_CONN && client.inactiveTimedOut())
                         WARNLOG("Inactive %s",s.str());
                 }
                 else {