Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv18116/src/mail

Modified Files:
        MailFolderCC.cpp 
Log Message:
use MP_CONN_CLOSE_DELAY option for the network connection keep alive

Index: MailFolderCC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolderCC.cpp,v
retrieving revision 1.609
retrieving revision 1.610
diff -b -u -2 -r1.609 -r1.610
--- MailFolderCC.cpp    27 Apr 2002 20:58:11 -0000      1.609
+++ MailFolderCC.cpp    27 Apr 2002 21:48:21 -0000      1.610
@@ -133,7 +133,7 @@
 // ----------------------------------------------------------------------------
 
+extern const MOption MP_CONN_CLOSE_DELAY;
 extern const MOption MP_DEBUG_CCLIENT;
 extern const MOption MP_FOLDERPROGRESS_THRESHOLD;
-extern const MOption MP_FOLDER_CLOSE_DELAY;
 extern const MOption MP_FOLDER_FILE_DRIVER;
 extern const MOption MP_FOLDER_LOGIN;
@@ -459,4 +459,13 @@
    static ServerInfoList ms_servers;
 
+   /**
+     A small class to close the cached connections periodically.
+    */
+   static class ConnCloseTimer : public wxTimer
+   {
+   public:
+      virtual void Notify() { ServerInfoEntry::CheckTimeoutAll(); }
+   } *ms_connCloseTimer;
+
    GCC_DTOR_WARN_OFF
 };
@@ -514,9 +523,4 @@
 
 /**
-  The function called to close the connections which had timed out.
- */
-extern void CheckConnectionsTimeout() { ServerInfoEntry::CheckTimeoutAll(); }
-
-/**
    The idea behind CCEventReflector is to allow postponing some actions in
    MailFolderCC code, i.e. instead of doing something immediately after getting
@@ -2997,4 +3001,8 @@
               path.c_str(), login.c_str());
 
+   // may happen if mail system not initialized yet
+   if ( !gs_StreamList )
+      return NULL;
+
    for ( StreamConnectionList::iterator i = gs_StreamList->begin();
          i != gs_StreamList->end();
@@ -6479,4 +6487,5 @@
 
 ServerInfoEntry::ServerInfoList ServerInfoEntry::ms_servers;
+ServerInfoEntry::ConnCloseTimer *ServerInfoEntry::ms_connCloseTimer = NULL;
 
 // ----------------------------------------------------------------------------
@@ -6573,4 +6582,9 @@
 {
    ms_servers.clear();
+   if ( ms_connCloseTimer )
+   {
+      delete ms_connCloseTimer;
+      ms_connCloseTimer = NULL;
+   }
 }
 
@@ -6600,5 +6614,5 @@
    Profile_obj profile(folder->GetProfile());
    time_t t = time(NULL);
-   time_t delay = READ_CONFIG(profile, MP_FOLDER_CLOSE_DELAY);
+   time_t delay = READ_CONFIG(profile, MP_CONN_CLOSE_DELAY);
 
    wxLogTrace(TRACE_CONN_CACHE,
@@ -6607,4 +6621,16 @@
 
    m_timeouts.push_back(t + delay);
+
+   if ( !ms_connCloseTimer )
+   {
+      ms_connCloseTimer = new ConnCloseTimer;
+   }
+
+   if ( !ms_connCloseTimer->IsRunning() ||
+           (ms_connCloseTimer->GetInterval() / 1000 > delay) )
+   {
+      // we want to use a smaller interval
+      ms_connCloseTimer->Start(delay * 1000);
+   }
 }
 
@@ -6642,4 +6668,6 @@
 void ServerInfoEntry::CheckTimeoutAll()
 {
+   bool hasAnyConns = false;
+
    for ( ServerInfoList::iterator i = ms_servers.begin();
          i != ms_servers.end();
@@ -6650,5 +6678,13 @@
       {
          i->CheckTimeout();
+
+         hasAnyConns = true;
+      }
       }
+
+   if ( !hasAnyConns )
+   {
+      // timer will be restarted in KeepStream() when/if neecessary
+      ms_connCloseTimer->Stop();
    }
 }


_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to