[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [Bug 77381] cannot quit knode (window disappears,
From:       Volker Krause <volker.krause () rwth-aachen ! de>
Date:       2005-03-28 14:44:49
Message-ID: 20050328144449.16717.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
         
http://bugs.kde.org/show_bug.cgi?id=77381         
volker.krause rwth-aachen de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From volker.krause rwth-aachen de  2005-03-28 16:44 -------
CVS commit by vkrause: 

Backport fix for #77381 (Cleanly terminate network threads).

BUG: 77381


  M +2 -2      knnetaccess.cpp   1.37.2.1
  M +29 -8     knprotocolclient.cpp   1.47.2.1
  M +3 -1      knprotocolclient.h   1.14.14.1


--- kdepim/knode/knnetaccess.cpp  #1.37:1.37.2.1
 @ -90,7 +90,7  @ KNNetAccess::~KNNetAccess()
     mSMTPProgressItem->setComplete();
 
-  nntpClient->terminate();
+  nntpClient->terminateClient();
   nntpClient->wait();
-  smtpClient->terminate();
+  smtpClient->terminateClient();
   smtpClient->wait();
 

--- kdepim/knode/knprotocolclient.cpp  #1.47:1.47.2.1
 @ -35,6 +35,11  @
 
 
-KNProtocolClient::KNProtocolClient(int NfdPipeIn, int NfdPipeOut)
-:  job(0L), inputSize(10000), fdPipeIn(NfdPipeIn), fdPipeOut(NfdPipeOut), tcpSocket(-1)
+KNProtocolClient::KNProtocolClient(int NfdPipeIn, int NfdPipeOut) :
+  job( 0 ),
+  inputSize( 10000 ),
+  fdPipeIn( NfdPipeIn ),
+  fdPipeOut( NfdPipeOut ),
+  tcpSocket( -1 ),
+  mTerminate( false )
 {
   input = new char[inputSize];
 @ -89,4 +94,5  @ void KNProtocolClient::waitForWork()
   int selectRet;
 
+  int holdTime = 1000 * account.hold();
   while (true) {
     if (isConnected()) {  // we are connected, hold the connection for xx secs
 @ -96,12 +102,22  @ void KNProtocolClient::waitForWork()
       FD_ZERO(&fdsE);
       FD_SET(tcpSocket, &fdsE);
-      tv.tv_sec = account.hold();
-      tv.tv_usec = 0;
+      tv.tv_sec = 0;
+      tv.tv_usec = 1000;
+      --holdTime;
       selectRet = KSocks::self()->select(FD_SETSIZE, &fdsR, NULL, &fdsE, &tv);
       if (selectRet == 0) {
+        if (holdTime <= 0) {
 #ifndef NDEBUG
         qDebug("knode: KNProtocolClient::waitForWork(): hold time elapsed, closing connection.");
 #endif
         closeConnection();               // nothing happend...
+          holdTime = 1000 * account.hold();
+        } else {
+          if ( mTerminate ) {
+            closeConnection();
+            return;
+          }
+          continue;
+        }
       } else {
         if (((selectRet > 0)&&(!FD_ISSET(fdPipeIn,&fdsR)))||(selectRet == -1)) {
 @ -114,8 +130,13  @ void KNProtocolClient::waitForWork()
     }
 
+    struct timeval timeout;
     do {
+      timeout.tv_sec = 0;
+      timeout.tv_usec = 1000;
       FD_ZERO(&fdsR);
       FD_SET(fdPipeIn, &fdsR);
-    } while (select(FD_SETSIZE, &fdsR, NULL, NULL, NULL)<0);  // don't get tricked by signals
+      if (mTerminate)
+        return;
+    } while (select(FD_SETSIZE, &fdsR, NULL, NULL, &timeout) <= 0);  // don't get tricked by signals
     
     clearPipe();      // remove start signal

--- kdepim/knode/knprotocolclient.h  #1.14:1.14.14.1
 @ -52,4 +52,5  @ class KNProtocolClient : public QThread 
     bool isInByteCountMode() const { return byteCountMode; };
   
+    void terminateClient() { mTerminate = true; }
   protected:
 
 @ -115,4 +116,5  @ class KNProtocolClient : public QThread 
     int byteCount;
     QTime timer;
+    bool mTerminate;
 
 };
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic