Fix improper thread support in krfb

This relates to bug 1583
pull/1/head
Timothy Pearson 11 years ago
parent a59a189a8b
commit 8dd45350db

@ -314,8 +314,14 @@ static void *
clientInput(void *data)
{
rfbClientPtr cl = (rfbClientPtr)data;
pthread_t output_thread;
pthread_create(&output_thread, NULL, clientOutput, (void *)cl);
/* Start output thread */
TQEventLoopThread* clientOutputHandlerThread = new TQEventLoopThread();
ClientOutputHandlerObject* clientOutputHandler = new ClientOutputHandlerObject();
clientOutputHandler->d = cl;
clientOutputHandler->moveToThread(clientOutputHandlerThread);
TQTimer::singleShot(0, clientOutputHandler, SLOT(run()));
clientOutputHandlerThread->start();
while (1) {
rfbProcessClientMessage(cl);
@ -325,11 +331,15 @@ clientInput(void *data)
}
}
/* Get rid of the output thread. */
/* Get rid of the output thread */
LOCK(cl->updateMutex);
TSIGNAL(cl->updateCond);
UNLOCK(cl->updateMutex);
IF_PTHREADS(pthread_join(output_thread, NULL));
clientOutputHandlerThread->wait();
delete clientOutputHandlerThread;
clientOutputHandlerThread = NULL;
delete clientOutputHandler;
clientOutputHandler = NULL;
rfbClientConnectionGone(cl);
@ -652,6 +662,21 @@ void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
}
rfbReleaseClientIterator(i);
if (mOnHoldClientHandlerThread) {
mOnHoldClientHandlerThread->exit();
delete mOnHoldClientHandlerThread;
mOnHoldClientHandlerThread = NULL;
delete mOnHoldClientHandler;
mOnHoldClientHandler = NULL;
}
if (mControlPipeHandlerThread) {
mControlPipeHandlerThread->exit();
delete mControlPipeHandlerThread;
mControlPipeHandlerThread = NULL;
delete mControlPipeHandler;
mControlPipeHandler = NULL;
}
/* TODO: hang up on all clients and free all reserved memory */
#define FREE_IF(x) if(rfbScreen->x) free(rfbScreen->x)
FREE_IF(colourMap.data.bytes);
@ -767,6 +792,9 @@ ControlPipeHandlerObject::~ControlPipeHandlerObject() {
void ControlPipeHandlerObject::run(void) {
listenerRun(d);
// Terminate thread
TQThread::exit();
}
OnHoldClientHandlerObject::OnHoldClientHandlerObject() : TQObject() {
@ -779,6 +807,24 @@ OnHoldClientHandlerObject::~OnHoldClientHandlerObject() {
void OnHoldClientHandlerObject::run(void) {
clientInput(d);
// Terminate thread
TQThread::exit();
}
ClientOutputHandlerObject::ClientOutputHandlerObject() : TQObject() {
//
}
ClientOutputHandlerObject::~ClientOutputHandlerObject() {
//
}
void ClientOutputHandlerObject::run(void) {
clientOutput(d);
// Terminate thread
TQThread::exit();
}
#include "main.moc"

@ -40,4 +40,19 @@ class OnHoldClientHandlerObject : public TQObject
rfbClientPtr d;
};
class ClientOutputHandlerObject : public TQObject
{
Q_OBJECT
public:
ClientOutputHandlerObject();
~ClientOutputHandlerObject();
public slots:
void run();
public:
rfbClientPtr d;
};
#endif // _MAIN_H
Loading…
Cancel
Save