From 963501ff41849e6bbcaa7a5c12c6e04b37a8a130 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 1 Jul 2012 20:43:39 -0500 Subject: [PATCH] Fix crashes in servers Start work on FPGA client --- clients/tde/src/app/remotemdi.cpp | 8 +- clients/tde/src/app/remotemdi.h | 1 + clients/tde/src/part/fpgaview/layout.ui | 165 +++++++++++++++++++++- clients/tde/src/part/fpgaview/part.cpp | 139 +++++++++++++++++- clients/tde/src/part/fpgaview/part.h | 27 ++++ lib/libtdekrb/src/tdekrbclientsocket.cpp | 20 ++- lib/libtdekrb/src/tdekrbclientsocket.h | 1 + lib/libtdekrb/src/tdekrbserversocket.cpp | 29 +++- lib/libtdekrb/src/tdekrbserversocket.h | 1 + servers/auth_server_lin/src/auth_conn.cpp | 17 ++- servers/auth_server_lin/src/auth_conn.h | 2 + servers/fpga_server_lin/src/fpga_conn.cpp | 16 ++- servers/fpga_server_lin/src/fpga_conn.h | 2 + 13 files changed, 404 insertions(+), 24 deletions(-) diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp index 163699f..3c3c436 100644 --- a/clients/tde/src/app/remotemdi.cpp +++ b/clients/tde/src/app/remotemdi.cpp @@ -30,7 +30,7 @@ using namespace std; #include "dialogs/selectserverdlg.h" RemoteMDI::RemoteMDI() - : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) + : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_instrumentActionListPlugged(false), m_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) { setXMLFile("remotelabui.rc"); @@ -420,9 +420,13 @@ void RemoteMDI::currentChanged(KMdiChildView *current) { RemoteLab::InstrumentView* view = dynamic_cast(current); // Plug/unpug menus - unplugActionList("selectedInstrument_actionlist"); + if (m_instrumentActionListPlugged) { + unplugActionList("selectedInstrument_actionlist"); + m_instrumentActionListPlugged = false; + } if (view) { plugActionList("selectedInstrument_actionlist", view->menuActionList()); + m_instrumentActionListPlugged = true; } // Update status bar and list box diff --git a/clients/tde/src/app/remotemdi.h b/clients/tde/src/app/remotemdi.h index d6dea6c..1502b62 100644 --- a/clients/tde/src/app/remotemdi.h +++ b/clients/tde/src/app/remotemdi.h @@ -77,6 +77,7 @@ class RemoteMDI : public KMdiMainFrm private: TQString m_mainStatusBarMessage; TQString m_windowStatusBarMessage; + bool m_instrumentActionListPlugged; unsigned m_children; TQString m_serverHost; diff --git a/clients/tde/src/part/fpgaview/layout.ui b/clients/tde/src/part/fpgaview/layout.ui index ce29018..a983687 100644 --- a/clients/tde/src/part/fpgaview/layout.ui +++ b/clients/tde/src/part/fpgaview/layout.ui @@ -47,15 +47,175 @@ - group8Bit + group8BitInput - 8-Bit Input Values + unnamed + + + group8BitInputLED7 + + + + + group8BitInputLED6 + + + + + group8BitInputLED5 + + + + + group8BitInputLED4 + + + + + group8BitInputLED3 + + + + + group8BitInputLED2 + + + + + group8BitInputLED1 + + + + + group8BitInputLED0 + + + + + group8BitInputValueText + + + + + + + group8BitOutput + + + 8-Bit Output Values + + + + unnamed + + + + group8BitOutputLED7 + + + + + group8BitOutputLED6 + + + + + group8BitOutputLED5 + + + + + group8BitOutputLED4 + + + + + group8BitOutputLED3 + + + + + group8BitOutputLED2 + + + + + group8BitOutputLED1 + + + + + group8BitOutputLED0 + + + + + group8BitOutputValueText + + + + + + + group16BitIO + + + 16-Bit I/O + + + + unnamed + + + + unnamed + + + Input: + + + + + group16BitInputValue + + + 0x + + + 0 + + + 0 + + + 65535 + + + 16 + + + + + unnamed + + + Output: + + + + + group16BitOutputValue + + + + + @@ -71,6 +231,7 @@ tracewidget.h floatspinbox.h + part.h diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp index 6161562..269c05e 100644 --- a/clients/tde/src/part/fpgaview/part.cpp +++ b/clients/tde/src/part/fpgaview/part.cpp @@ -37,24 +37,52 @@ #include #include #include +#include #include //access() #include - - #include "tracewidget.h" #include "floatspinbox.h" #include "layout.h" +#define SERVER_TIMEOUT_MS 10000 + +FPGALed::FPGALed(TQWidget *parent, const char *name) + : KLed(parent, name), m_clickable(true) +{ + connect(this, SIGNAL(clicked()), this, SLOT(toggle())); + + setColor(green); + setOffColor(TQApplication::palette(this).active().base().dark(200)); +} + +void FPGALed::setClickable(bool clickable) { + if ((!clickable) && (m_clickable)) { + disconnect(this, SIGNAL(clicked()), this, SLOT(toggle())); + } + else if ((clickable) && (!m_clickable)) { + connect(this, SIGNAL(clicked()), this, SLOT(toggle())); + } + m_clickable = clickable; +} + +void FPGALed::mouseReleaseEvent(TQMouseEvent *e) { + if (e->button() == TQMouseEvent::LeftButton) { + emit(clicked()); + } +} + namespace RemoteLab { typedef KParts::GenericFactory Factory; #define CLIENT_LIBRARY "libremotelab_fpgaviewer" K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory) +#define LED_SIZE 20,20 FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&) - : RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL), m_interfaceMode(BasicInterfaceMode) + : RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL), m_interfaceMode(BasicInterfaceMode), + remoteInputModeEnabled(false), m_8bitInputValue(0), m_8bitOutputValue(0) { // Initialize mutex m_connectionMutex = new TQMutex(false); @@ -82,7 +110,60 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_modeAdvancedEnabled = new KToggleAction(i18n("Advanced"), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(switchToAdvancedMode()), ac, "mode_advanced_enabled"); m_modeSubMenu->insert(m_modeAdvancedEnabled); - processLockouts(); + // Initialize widgets + m_base->group8BitInputLED7->setFixedSize(LED_SIZE); + m_base->group8BitInputLED6->setFixedSize(LED_SIZE); + m_base->group8BitInputLED5->setFixedSize(LED_SIZE); + m_base->group8BitInputLED4->setFixedSize(LED_SIZE); + m_base->group8BitInputLED3->setFixedSize(LED_SIZE); + m_base->group8BitInputLED2->setFixedSize(LED_SIZE); + m_base->group8BitInputLED1->setFixedSize(LED_SIZE); + m_base->group8BitInputLED0->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED7->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED6->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED5->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED4->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED3->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED2->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED1->setFixedSize(LED_SIZE); + m_base->group8BitOutputLED0->setFixedSize(LED_SIZE); + + m_base->group8BitInputLED7->setState(KLed::Off); + m_base->group8BitInputLED6->setState(KLed::Off); + m_base->group8BitInputLED5->setState(KLed::Off); + m_base->group8BitInputLED4->setState(KLed::Off); + m_base->group8BitInputLED3->setState(KLed::Off); + m_base->group8BitInputLED2->setState(KLed::Off); + m_base->group8BitInputLED1->setState(KLed::Off); + m_base->group8BitInputLED0->setState(KLed::Off); + m_base->group8BitOutputLED7->setState(KLed::Off); + m_base->group8BitOutputLED6->setState(KLed::Off); + m_base->group8BitOutputLED5->setState(KLed::Off); + m_base->group8BitOutputLED4->setState(KLed::Off); + m_base->group8BitOutputLED3->setState(KLed::Off); + m_base->group8BitOutputLED2->setState(KLed::Off); + m_base->group8BitOutputLED1->setState(KLed::Off); + m_base->group8BitOutputLED0->setState(KLed::Off); + + m_base->group8BitOutputLED7->setClickable(false); + m_base->group8BitOutputLED6->setClickable(false); + m_base->group8BitOutputLED5->setClickable(false); + m_base->group8BitOutputLED4->setClickable(false); + m_base->group8BitOutputLED3->setClickable(false); + m_base->group8BitOutputLED2->setClickable(false); + m_base->group8BitOutputLED1->setClickable(false); + m_base->group8BitOutputLED0->setClickable(false); + + connect(m_base->group8BitInputLED7, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED6, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED5, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED4, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED3, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED2, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED1, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group8BitInputLED0, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + + processAllGraphicsUpdates(); TQTimer::singleShot(0, this, TQT_SLOT(postInit())); } @@ -96,6 +177,52 @@ FPGAViewPart::~FPGAViewPart() { delete m_connectionMutex; } +void FPGAViewPart::processAllGraphicsUpdates() { + // This is an expensive operation + // Use it sparingly! + + process8BitInputChanges(); + process8BitOutputChanges(); + + processLockouts(); +} + +void FPGAViewPart::process8BitInputChanges() { + // Read LED status into m_8bitInputValue + m_8bitInputValue = 0; + if (m_base->group8BitInputLED7->state() == KLed::On) m_8bitInputValue |= 0x80; + if (m_base->group8BitInputLED6->state() == KLed::On) m_8bitInputValue |= 0x40; + if (m_base->group8BitInputLED5->state() == KLed::On) m_8bitInputValue |= 0x20; + if (m_base->group8BitInputLED4->state() == KLed::On) m_8bitInputValue |= 0x10; + if (m_base->group8BitInputLED3->state() == KLed::On) m_8bitInputValue |= 0x08; + if (m_base->group8BitInputLED2->state() == KLed::On) m_8bitInputValue |= 0x04; + if (m_base->group8BitInputLED1->state() == KLed::On) m_8bitInputValue |= 0x02; + if (m_base->group8BitInputLED0->state() == KLed::On) m_8bitInputValue |= 0x01; + + m_base->group8BitInputValueText->setText(TQString("0x%1").arg(m_8bitInputValue, 0, 16)); + + if (remoteInputModeEnabled) { + m_base->group8BitInput->setTitle(i18n("8-Bit Input Values") + " [" + i18n("Remote Input Mode") + "]"); + } + else { + m_base->group8BitInput->setTitle(i18n("8-Bit Input Values") + " [" + i18n("Local Input Mode") + "]"); + } +} + +void FPGAViewPart::process8BitOutputChanges() { + // Write m_8bitOutputValue to LEDs + m_base->group8BitOutputLED7->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED6->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED5->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED4->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED3->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED2->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED1->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + m_base->group8BitOutputLED0->setState((m_8bitInputValue & 0x80)?KLed::On:KLed::Off); + + m_base->group8BitOutputValueText->setText(TQString("0x%1").arg(m_8bitOutputValue, 0, 16)); +} + void FPGAViewPart::processLockouts() { TQWidget* mainWidget = widget(); if (mainWidget) { @@ -183,7 +310,7 @@ void FPGAViewPart::finishConnectingToServer() { case 0: if (!connToServerTimeoutTimer) { connToServerTimeoutTimer = new TQTimer; - connToServerTimeoutTimer->start(5000, TRUE); + connToServerTimeoutTimer->start(SERVER_TIMEOUT_MS, TRUE); } if ((m_socket->state() == TQSocket::Connecting) || (m_socket->state() == TQSocket::HostLookup)) { if (!connToServerTimeoutTimer->isActive()) { @@ -196,7 +323,7 @@ void FPGAViewPart::finishConnectingToServer() { else { if (m_socket->state() == TQSocket::Connected) { printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout); - m_socket->setDataTimeout(5000); + m_socket->setDataTimeout(SERVER_TIMEOUT_MS); m_socket->setUsingKerberos(true); connToServerState = 1; } diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h index 3e8ac07..65c03bd 100644 --- a/clients/tde/src/part/fpgaview/part.h +++ b/clients/tde/src/part/fpgaview/part.h @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -40,6 +41,24 @@ class TQTimer; class TQMutex; class FPGAViewBase; +class FPGALed : public KLed +{ + Q_OBJECT + + public: + FPGALed(TQWidget *parent=0, const char *name=0); + void setClickable(bool clickable); + + protected: + virtual void mouseReleaseEvent(TQMouseEvent *); + + signals: + void clicked(); + + private: + bool m_clickable; +}; + namespace RemoteLab { class FPGAViewPart : public KParts::RemoteInstrumentPart @@ -76,6 +95,10 @@ namespace RemoteLab void switchToBasicMode(); void switchToIntermediateMode(); void switchToAdvancedMode(); + void processAllGraphicsUpdates(); + + void process8BitInputChanges(); + void process8BitOutputChanges(); private: TDEKerberosClientSocket* m_socket; @@ -94,6 +117,10 @@ namespace RemoteLab KToggleAction* m_modeAdvancedEnabled; InterfaceMode m_interfaceMode; + + bool remoteInputModeEnabled; + unsigned char m_8bitInputValue; + unsigned char m_8bitOutputValue; }; } diff --git a/lib/libtdekrb/src/tdekrbclientsocket.cpp b/lib/libtdekrb/src/tdekrbclientsocket.cpp index 6ba35e5..952f28d 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.cpp +++ b/lib/libtdekrb/src/tdekrbclientsocket.cpp @@ -97,7 +97,7 @@ static int logSASLMessages(void *context __attribute__((unused)), int priority, return SASL_OK; } -TDEKerberosClientSocket::TDEKerberosClientSocket(TQObject *parent, const char *name) : TQSocket(parent, name), m_kerberosRequested(false), m_criticalSection(0), m_bufferLength(0), m_krbInitRunning(false), m_krbInitState(-1), m_dataTimeout(-1), m_canary(NULL), m_negotiatedMaxBufferSize(NET_SEC_BUF_SIZE) { +TDEKerberosClientSocket::TDEKerberosClientSocket(TQObject *parent, const char *name) : TQSocket(parent, name), m_kerberosRequested(false), m_criticalSection(0), m_bufferLength(0), m_krbInitRunning(false), m_krbInitState(-1), m_dataTimeout(-1), kerberosInitLoopTimer(NULL), m_canary(NULL), m_negotiatedMaxBufferSize(NET_SEC_BUF_SIZE) { saslData = new SASLDataPrivate; saslData->m_krbConnection = NULL; m_buffer = new TQBuffer(); @@ -108,6 +108,11 @@ TDEKerberosClientSocket::~TDEKerberosClientSocket() { if (m_canary) { *m_canary = true; } + if (kerberosInitLoopTimer) { + kerberosInitLoopTimer->stop(); + delete kerberosInitLoopTimer; + kerberosInitLoopTimer = NULL; + } m_buffer->close(); delete m_buffer; delete saslData; @@ -795,6 +800,11 @@ void TDEKerberosClientSocket::continueKerberosInitialization() { m_negotiatedMaxBufferSize = NET_SEC_BUF_SIZE; } else { + // For some reason m_negotiatedMaxBufferSize can be set negative under certain circumstances + // Prevent that from happening! + if (m_negotiatedMaxBufferSize < NET_SEC_BUF_SIZE) { + m_negotiatedMaxBufferSize = NET_SEC_BUF_SIZE; + } printf("[DEBUG] Maximum buffer size: %d\n", m_negotiatedMaxBufferSize); } m_krbInitState = 3; @@ -810,7 +820,7 @@ void TDEKerberosClientSocket::continueKerberosInitialization() { } break; } - TQTimer::singleShot(0, this, SLOT(continueKerberosInitialization())); + if (kerberosInitLoopTimer) kerberosInitLoopTimer->start(0, TRUE); } } @@ -869,7 +879,11 @@ int TDEKerberosClientSocket::initializeKerberosInterface() { m_krbInitRunning = true; m_krbInitState = 0; - TQTimer::singleShot(0, this, SLOT(continueKerberosInitialization())); + if (!kerberosInitLoopTimer) { + kerberosInitLoopTimer = new TQTimer(); + connect(kerberosInitLoopTimer, SIGNAL(timeout()), this, SLOT(continueKerberosInitialization())); + } + if (kerberosInitLoopTimer) kerberosInitLoopTimer->start(0, TRUE); return 0; } \ No newline at end of file diff --git a/lib/libtdekrb/src/tdekrbclientsocket.h b/lib/libtdekrb/src/tdekrbclientsocket.h index f058220..fc7da95 100644 --- a/lib/libtdekrb/src/tdekrbclientsocket.h +++ b/lib/libtdekrb/src/tdekrbclientsocket.h @@ -95,6 +95,7 @@ class TDEKerberosClientSocket : public TQSocket int m_krbInitState; TQString m_prevStatusMessage; int m_dataTimeout; + TQTimer* kerberosInitLoopTimer; bool* m_canary; private: diff --git a/lib/libtdekrb/src/tdekrbserversocket.cpp b/lib/libtdekrb/src/tdekrbserversocket.cpp index 3134738..d395936 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.cpp +++ b/lib/libtdekrb/src/tdekrbserversocket.cpp @@ -97,7 +97,7 @@ static int logSASLMessages(void *context __attribute__((unused)), int priority, return SASL_OK; } -TDEKerberosServerSocket::TDEKerberosServerSocket(TQObject *parent, const char *name) : TQSocket(parent, name), m_kerberosRequested(false), m_criticalSection(0), m_bufferLength(0), m_krbInitRunning(false), m_krbInitState(-1), m_dataTimeout(-1), m_canary(NULL), m_negotiatedMaxBufferSize(NET_SEC_BUF_SIZE) { +TDEKerberosServerSocket::TDEKerberosServerSocket(TQObject *parent, const char *name) : TQSocket(parent, name), m_kerberosRequested(false), m_criticalSection(0), m_bufferLength(0), m_krbInitRunning(false), m_krbInitState(-1), m_dataTimeout(-1), kerberosInitLoopTimer(NULL), m_canary(NULL), m_negotiatedMaxBufferSize(NET_SEC_BUF_SIZE) { saslData = new SASLDataPrivate; saslData->m_krbConnection = NULL; m_buffer = new TQBuffer(); @@ -108,6 +108,11 @@ TDEKerberosServerSocket::~TDEKerberosServerSocket() { if (m_canary) { *m_canary = true; } + if (kerberosInitLoopTimer) { + kerberosInitLoopTimer->stop(); + delete kerberosInitLoopTimer; + kerberosInitLoopTimer = NULL; + } m_buffer->close(); delete m_buffer; delete saslData; @@ -794,6 +799,20 @@ void TDEKerberosServerSocket::continueKerberosInitialization() { else { printf("[DEBUG] Authenticated SSF: %d\n", *ssf); } + + m_krbInitResult = sasl_getprop(saslData->m_krbConnection, SASL_MAXOUTBUF, (const void **)&m_negotiatedMaxBufferSize); + if (m_krbInitResult != SASL_OK) { + printf("[WARNING] Unable to determine maximum buffer size!\n\r"); + m_negotiatedMaxBufferSize = NET_SEC_BUF_SIZE; + } + else { + // For some reason m_negotiatedMaxBufferSize can be set negative under certain circumstances + // Prevent that from happening! + if (m_negotiatedMaxBufferSize < NET_SEC_BUF_SIZE) { + m_negotiatedMaxBufferSize = NET_SEC_BUF_SIZE; + } + printf("[DEBUG] Maximum buffer size: %d\n", m_negotiatedMaxBufferSize); + } m_krbInitState = 4; m_krbInitRunning = false; setStatusMessage(i18n("Kerberos connection established")); @@ -807,7 +826,7 @@ void TDEKerberosServerSocket::continueKerberosInitialization() { } break; } - TQTimer::singleShot(0, this, SLOT(continueKerberosInitialization())); + if (kerberosInitLoopTimer) kerberosInitLoopTimer->start(0, TRUE); } } @@ -884,7 +903,11 @@ int TDEKerberosServerSocket::initializeKerberosInterface() { m_krbInitRunning = true; m_krbInitState = 0; - TQTimer::singleShot(0, this, SLOT(continueKerberosInitialization())); + if (!kerberosInitLoopTimer) { + kerberosInitLoopTimer = new TQTimer(); + connect(kerberosInitLoopTimer, SIGNAL(timeout()), this, SLOT(continueKerberosInitialization())); + } + if (kerberosInitLoopTimer) kerberosInitLoopTimer->start(0, TRUE); return 0; } \ No newline at end of file diff --git a/lib/libtdekrb/src/tdekrbserversocket.h b/lib/libtdekrb/src/tdekrbserversocket.h index 6276358..42f3a2d 100644 --- a/lib/libtdekrb/src/tdekrbserversocket.h +++ b/lib/libtdekrb/src/tdekrbserversocket.h @@ -99,6 +99,7 @@ class TDEKerberosServerSocket : public TQSocket int m_krbInitState; TQString m_prevStatusMessage; int m_dataTimeout; + TQTimer* kerberosInitLoopTimer; bool* m_canary; private: diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp index 177a0e3..29b8501 100644 --- a/servers/auth_server_lin/src/auth_conn.cpp +++ b/servers/auth_server_lin/src/auth_conn.cpp @@ -45,7 +45,7 @@ struct exit_exception { instance of this class. */ AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) : - TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_servActive(false), m_servState(0), m_servClientSocket(NULL), m_servClientTimeout(NULL), m_config(static_cast(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL), + TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_servActive(false), m_servState(0), m_servClientSocket(NULL), m_servClientTimeout(NULL), m_loopTimer(NULL), m_config(static_cast(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL), m_databaseServicesCursor(NULL), m_databaseServiceTypesCursor(NULL), m_databasePermissionsCursor(NULL), m_databaseActivityCursor(NULL) { @@ -61,6 +61,11 @@ AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) : } AuthSocket::~AuthSocket() { + if (m_loopTimer) { + m_loopTimer->stop(); + delete m_loopTimer; + m_loopTimer = NULL; + } if (m_databaseStationsCursor) { delete m_databaseStationsCursor; } @@ -260,7 +265,7 @@ void AuthSocket::servLoop() { void AuthSocket::commandLoop() { if (m_servActive) { servLoop(); - TQTimer::singleShot(0, this, SLOT(commandLoop())); + if (m_loopTimer) m_loopTimer->start(0, TRUE); return; } @@ -427,7 +432,7 @@ void AuthSocket::commandLoop() { } m_criticalSection--; - TQTimer::singleShot(0, this, SLOT(commandLoop())); + if (m_loopTimer) m_loopTimer->start(0, TRUE); return; } } @@ -438,7 +443,11 @@ void AuthSocket::commandLoop() { } int AuthSocket::enterCommandLoop() { - TQTimer::singleShot(0, this, SLOT(commandLoop())); + if (!m_loopTimer) { + m_loopTimer = new TQTimer(); + connect(m_loopTimer, SIGNAL(timeout()), this, SLOT(commandLoop())); + } + if (m_loopTimer) m_loopTimer->start(0, TRUE); return 0; } diff --git a/servers/auth_server_lin/src/auth_conn.h b/servers/auth_server_lin/src/auth_conn.h index f1b3295..08f8072 100644 --- a/servers/auth_server_lin/src/auth_conn.h +++ b/servers/auth_server_lin/src/auth_conn.h @@ -74,6 +74,8 @@ class AuthSocket : public TDEKerberosServerSocket TQString m_srvServiceHostName; int m_srvServicePort; + TQTimer* m_loopTimer; + KSimpleConfig* m_config; TQSqlDatabase* m_database; TQSqlCursor* m_databaseStationsCursor; diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp index f0ab39d..6f4cecf 100644 --- a/servers/fpga_server_lin/src/fpga_conn.cpp +++ b/servers/fpga_server_lin/src/fpga_conn.cpp @@ -57,7 +57,7 @@ struct exit_exception { instance of this class. */ FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) : - TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_config(static_cast(parent)->m_config) { + TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_loopTimer(NULL), m_config(static_cast(parent)->m_config) { setServiceName("remotefpga"); @@ -68,7 +68,11 @@ FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) : } FPGASocket::~FPGASocket() { - // + if (m_loopTimer) { + m_loopTimer->stop(); + delete m_loopTimer; + m_loopTimer = NULL; + } } void FPGASocket::close() { @@ -177,7 +181,7 @@ void FPGASocket::commandLoop() { } } m_criticalSection--; - TQTimer::singleShot(0, this, SLOT(commandLoop())); + if (m_loopTimer) m_loopTimer->start(0, TRUE); return; } catch (...) { @@ -187,7 +191,11 @@ void FPGASocket::commandLoop() { } int FPGASocket::enterCommandLoop() { - TQTimer::singleShot(0, this, SLOT(commandLoop())); + if (!m_loopTimer) { + m_loopTimer = new TQTimer(); + connect(m_loopTimer, SIGNAL(timeout()), this, SLOT(commandLoop())); + } + if (m_loopTimer) m_loopTimer->start(0, TRUE); return 0; } diff --git a/servers/fpga_server_lin/src/fpga_conn.h b/servers/fpga_server_lin/src/fpga_conn.h index 8c99794..717a35b 100644 --- a/servers/fpga_server_lin/src/fpga_conn.h +++ b/servers/fpga_server_lin/src/fpga_conn.h @@ -62,6 +62,8 @@ class FPGASocket : public TDEKerberosServerSocket TQString m_remoteHost; int m_fd_tty; + TQTimer* m_loopTimer; + KSimpleConfig* m_config; friend class FPGAServer;