summaryrefslogtreecommitdiffstats
path: root/krfb/libvncserver/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'krfb/libvncserver/main.cc')
-rw-r--r--krfb/libvncserver/main.cc54
1 files changed, 50 insertions, 4 deletions
diff --git a/krfb/libvncserver/main.cc b/krfb/libvncserver/main.cc
index 51cfaa5d..6ecea30d 100644
--- a/krfb/libvncserver/main.cc
+++ b/krfb/libvncserver/main.cc
@@ -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" \ No newline at end of file