[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-02-27 17:30:29
Message-ID: 20050227173029.27481.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
------- Additional Comments From volker.krause rwth-aachen de 2005-02-27 18:30 \
------- CVS commit by vkrause:
Cleanly terminate network threads from within instead of using QThread::teminate(), \
which doesn't seem to work on some systems (and which shouldn't be used anyway \
according to the Qt docs). This fixes the most hated KNode bug (#77381).
Thanks to Wolfgang Scheicher <worf sbox tu-graz ac at> for helping to track this \
down.
CCBUG: 77381
M +1 -1 knnetaccess.cpp 1.39
M +27 -8 knprotocolclient.cpp 1.48
M +3 -1 knprotocolclient.h 1.15
--- kdepim/knode/knnetaccess.cpp #1.38:1.39
@ -80,5 +80,5 @ KNNetAccess::~KNNetAccess()
mSMTPProgressItem->setComplete();
- nntpClient->terminate();
+ nntpClient->terminateClient();
nntpClient->wait();
--- kdepim/knode/knprotocolclient.cpp #1.47:1.48
@ -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];
@ -90,4 +95,5 @ void KNProtocolClient::waitForWork()
while (true) {
+ int holdTime = 2 * account.hold();
if (isConnected()) { // we are connected, hold the connection for xx secs
FD_ZERO(&fdsR);
@ -96,8 +102,10 @ 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 = 500;
+ --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."); @ -105,4 +113,10 @ void KNProtocolClient::waitForWork()
closeConnection(); // nothing happend...
} else {
+ if ( mTerminate ) {
+ closeConnection();
+ return;
+ }
+ }
+ } else {
if (((selectRet > 0)&&(!FD_ISSET(fdPipeIn,&fdsR)))||(selectRet == -1)) {
#ifndef NDEBUG
@ -114,8 +128,13 @ void KNProtocolClient::waitForWork()
}
+ struct timeval timeout;
do {
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 500;
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.15
@ -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