Remove call to pthread_cancel() in kdesktop_lock

This resolves a sporadic deadlock during kdesktop_lock termination
(cherry picked from commit e569dd46ac)
pull/182/head
Timothy Pearson 9 years ago committed by Slávek Banko
parent 1f266258df
commit 5d4afcb68f

@ -38,6 +38,6 @@ set( ${target}_SRCS
tde_add_executable( ${target} AUTOMOC tde_add_executable( ${target} AUTOMOC
SOURCES ${${target}_SRCS} SOURCES ${${target}_SRCS}
LINK kdesktopsettings-static dmctl-static tdeio-shared Xext LINK kdesktopsettings-static dmctl-static tdeio-shared Xext
${GL_LIBRARIES} "${LINKER_IMMEDIATE_BINDING_FLAGS}" pthread ${GL_LIBRARIES} "${LINKER_IMMEDIATE_BINDING_FLAGS}"
DESTINATION ${BIN_INSTALL_DIR} DESTINATION ${BIN_INSTALL_DIR}
) )

@ -81,6 +81,7 @@
#ifdef __linux__ #ifdef __linux__
#include <linux/stat.h> #include <linux/stat.h>
#include <pthread.h>
#endif #endif
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -304,7 +305,7 @@ LockProcess::LockProcess()
// //
LockProcess::~LockProcess() LockProcess::~LockProcess()
{ {
mControlPipeHandlerThread->terminate(); mControlPipeHandler->terminateThread();
mControlPipeHandlerThread->wait(); mControlPipeHandlerThread->wait();
delete mControlPipeHandler; delete mControlPipeHandler;
// delete mControlPipeHandlerThread; // delete mControlPipeHandlerThread;
@ -2828,6 +2829,9 @@ void LockProcess::saverReady() {
// //
ControlPipeHandlerObject::ControlPipeHandlerObject() : TQObject() { ControlPipeHandlerObject::ControlPipeHandlerObject() : TQObject() {
mParent = NULL; mParent = NULL;
mRunning = false;
mTerminate = false;
mThreadID = 0L;
} }
ControlPipeHandlerObject::~ControlPipeHandlerObject() { ControlPipeHandlerObject::~ControlPipeHandlerObject() {
@ -2835,10 +2839,14 @@ ControlPipeHandlerObject::~ControlPipeHandlerObject() {
} }
void ControlPipeHandlerObject::run(void) { void ControlPipeHandlerObject::run(void) {
mThreadID = pthread_self();
mRunning = true;
int display_number = atoi(TQString(XDisplayString(tqt_xdisplay())).replace(":","").ascii()); int display_number = atoi(TQString(XDisplayString(tqt_xdisplay())).replace(":","").ascii());
if (display_number < 0) { if (display_number < 0) {
printf("[kdesktop_lock] Warning: unable to create control socket. Interactive logon modules may not function properly.\n"); printf("[kdesktop_lock] Warning: unable to create control socket. Interactive logon modules may not function properly.\n");
mRunning = false;
TQApplication::eventLoop()->exit(-1); TQApplication::eventLoop()->exit(-1);
return; return;
} }
@ -2869,6 +2877,7 @@ void ControlPipeHandlerObject::run(void) {
if (!mParent->mPipeOpen) { if (!mParent->mPipeOpen) {
printf("[kdesktop_lock] Warning: unable to create control socket '%s'. Interactive logon modules may not function properly.\n", fifo_file); printf("[kdesktop_lock] Warning: unable to create control socket '%s'. Interactive logon modules may not function properly.\n", fifo_file);
mRunning = false;
TQApplication::eventLoop()->exit(-1); TQApplication::eventLoop()->exit(-1);
return; return;
} }
@ -2880,7 +2889,7 @@ void ControlPipeHandlerObject::run(void) {
FD_SET(mParent->mPipe_fd, &rfds); FD_SET(mParent->mPipe_fd, &rfds);
TQByteArray readbuf(128); TQByteArray readbuf(128);
while (mParent->mPipeOpen) { while (mParent->mPipeOpen && !mTerminate) {
TQString inputcommand = ""; TQString inputcommand = "";
// Wait for mParent->mPipe_fd to receive input // Wait for mParent->mPipe_fd to receive input
@ -2900,8 +2909,16 @@ void ControlPipeHandlerObject::run(void) {
} }
} }
mRunning = false;
TQApplication::eventLoop()->exit(0); TQApplication::eventLoop()->exit(0);
return; return;
} }
void ControlPipeHandlerObject::terminateThread() {
if (mRunning) {
mTerminate = true;
pthread_kill(mThreadID, SIGUSR1);
}
}
#include "lockprocess.moc" #include "lockprocess.moc"

@ -56,12 +56,18 @@ class ControlPipeHandlerObject : public TQObject
public slots: public slots:
void run(); void run();
void terminateThread();
signals: signals:
void processCommand(TQString); void processCommand(TQString);
public: public:
LockProcess* mParent; LockProcess* mParent;
private:
bool mRunning;
bool mTerminate;
pthread_t mThreadID;
}; };
//=========================================================================== //===========================================================================
@ -94,6 +100,9 @@ public:
void msgBox( TQMessageBox::Icon type, const TQString &txt ); void msgBox( TQMessageBox::Icon type, const TQString &txt );
int execDialog( TQDialog* dlg ); int execDialog( TQDialog* dlg );
signals:
void terminateHelperThread();
public slots: public slots:
void quitSaver(); void quitSaver();
void preparePopup(); void preparePopup();

Loading…
Cancel
Save