diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-29 01:49:29 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-06-29 01:49:29 -0500 |
commit | 1f8f9ca9434d9e2c0d7e7e061b7177009fd504df (patch) | |
tree | 1b793132751d6bce670bf853f70fd1f34721eecc /clients/tde | |
parent | e89735d72ae3b320c33f7ad95c3cbc9ea6d42f6c (diff) | |
download | ulab-1f8f9ca9434d9e2c0d7e7e061b7177009fd504df.tar.gz ulab-1f8f9ca9434d9e2c0d7e7e061b7177009fd504df.zip |
Convert krb server socket to stateful operation
Do the same to the server daemons and the MDI frame client
Diffstat (limited to 'clients/tde')
-rw-r--r-- | clients/tde/src/app/remotemdi.cpp | 136 | ||||
-rw-r--r-- | clients/tde/src/app/remotemdi.h | 5 | ||||
-rw-r--r-- | clients/tde/src/part/fpgaview/part.cpp | 1 |
3 files changed, 90 insertions, 52 deletions
diff --git a/clients/tde/src/app/remotemdi.cpp b/clients/tde/src/app/remotemdi.cpp index 3e5c075..e1d4236 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) + : KMdiMainFrm(0, "RemoteMDI", KMdi::ChildframeMode), m_children(0), m_rsvSvrSocket(NULL), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL) { setXMLFile("remotelabui.rc"); @@ -75,10 +75,10 @@ RemoteMDI::~RemoteMDI() } if (m_rsvSvrSocket) { + m_rsvSvrSocket->clearPendingData(); m_rsvSvrSocket->close(); - while (m_rsvSvrSocket->state() == TQSocket::Closing) { - tqApp->processEvents(); - } + delete m_rsvSvrSocket; + m_rsvSvrSocket = NULL; } } @@ -137,46 +137,54 @@ void RemoteMDI::startModule() { } } -void RemoteMDI::connectToServer() { - if (m_rsvSvrSocket) { - if (m_rsvSvrSocket->state() != TQSocket::Idle) { - printf("[DEBUG] Not connecting because the socket is still in state %d\n\r", m_rsvSvrSocket->state()); fflush(stdout); - return; - } - } - - connect_action->setEnabled(false); - disconnect_action->setEnabled(true); - - // Connect to the central reservation/control server - if (!m_rsvSvrSocket) { - m_rsvSvrSocket = new TDEKerberosClientSocket(this); - connect(m_rsvSvrSocket, SIGNAL(connectionClosed()), this, SLOT(connectionClosedHandler())); - } - m_rsvSvrSocket->setServiceName("remotefpga"); - if (m_serverHost != "") { - m_rsvSvrSocket->setServerFQDN(m_serverHost); - m_rsvSvrSocket->connectToHost(m_serverHost, 4004); - TQTimer connectionTimeout; - connectionTimeout.start(5000, TRUE); - while ((m_rsvSvrSocket->state() == TQSocket::Connecting) || (m_rsvSvrSocket->state() == TQSocket::HostLookup)) { - tqApp->processEvents(); - if (!connectionTimeout.isActive()) { +void RemoteMDI::finishConnectingToServer() { + if (connToServerConnecting) { + switch(connToServerState) { + case 0: + if (!connToServerTimeoutTimer) { + connToServerTimeoutTimer = new TQTimer; + connToServerTimeoutTimer->start(5000, TRUE); + } + if ((m_rsvSvrSocket->state() == TQSocket::Connecting) || (m_rsvSvrSocket->state() == TQSocket::HostLookup)) { + if (!connToServerTimeoutTimer->isActive()) { + connToServerState = -3; + connToServerConnecting = false; + disconnectFromServer(); + KMessageBox::error(this, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed")); + } + } + else { + if (m_rsvSvrSocket->state() == TQSocket::Connected) { + printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout); + m_rsvSvrSocket->setDataTimeout(5000); + m_rsvSvrSocket->setUsingKerberos(true); + connToServerState = 1; + } + else { + connToServerState = -1; + connToServerConnecting = false; + disconnectFromServer(); + KMessageBox::error(this, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed")); + } + } break; - } - } - connectionTimeout.stop(); - if (m_rsvSvrSocket->state() == TQSocket::Connected) { - printf("[DEBUG] Initial connection established...\n\r"); fflush(stdout); - m_rsvSvrSocket->setUsingKerberos(true); - while (m_rsvSvrSocket->kerberosStatus() == TDEKerberosClientSocket::KerberosInitializing) { - tqApp->processEvents(); - } - if (m_rsvSvrSocket->kerberosStatus() != TDEKerberosClientSocket::KerberosInUse) { - disconnectFromServer(); - KMessageBox::error(this, i18n("<qt>Unable to establish Kerberos protocol with remote server<p>Please verify that you currently hold a valid Kerberos ticket</qt>"), i18n("Connection Failed")); - } - else { + case 1: + if (m_rsvSvrSocket->kerberosStatus() == TDEKerberosClientSocket::KerberosInitializing) { + // Do nothing + } + else { + if (m_rsvSvrSocket->kerberosStatus() != TDEKerberosClientSocket::KerberosInUse) { + connToServerState = -1; + connToServerConnecting = false; + disconnectFromServer(); + KMessageBox::error(this, i18n("<qt>Unable to establish Kerberos protocol with remote server<p>Please verify that you currently hold a valid Kerberos ticket</qt>"), i18n("Connection Failed")); + } + else { + connToServerState = 2; + } + } + break; + case 2: // Connection established! // Read magic number and proto version from server TQDataStream* ds = new TQDataStream(m_rsvSvrSocket); @@ -194,19 +202,43 @@ void RemoteMDI::connectToServer() { disconnectFromServer(); KMessageBox::error(this, i18n("<qt>The remote server is not compatible with this client</qt>"), i18n("Connection Failed")); } - } + connToServerState = 3; + connToServerConnecting = false; + processLockouts(); + break; } - else { - disconnectFromServer(); - KMessageBox::error(this, i18n("<qt>Unable to establish connection to remote server</qt>"), i18n("Connection Failed")); + + TQTimer::singleShot(0, this, SLOT(finishConnectingToServer())); + } +} + +void RemoteMDI::connectToServer() { + if (m_rsvSvrSocket) { + if (m_rsvSvrSocket->state() != TQSocket::Idle) { + printf("[DEBUG] Not connecting because the socket is still in state %d\n\r", m_rsvSvrSocket->state()); fflush(stdout); + return; } } - else { - disconnectFromServer(); - KMessageBox::error(this, i18n("<qt>The address of the remote server has not been specified</qt>"), i18n("Connection Failed")); + + connect_action->setEnabled(false); + disconnect_action->setEnabled(true); + + // Connect to the central reservation/control server + if (!m_rsvSvrSocket) { + m_rsvSvrSocket = new TDEKerberosClientSocket(this); + connect(m_rsvSvrSocket, SIGNAL(connectionClosed()), this, SLOT(connectionClosedHandler())); + connect(m_rsvSvrSocket, TQT_SIGNAL(statusMessageUpdated(const TQString&)), statusBar(), TQT_SLOT(message(const TQString&) )); } + m_rsvSvrSocket->setServiceName("remotefpga"); + if (m_serverHost != "") { + m_rsvSvrSocket->setServerFQDN(m_serverHost); + m_rsvSvrSocket->connectToHost(m_serverHost, 4004); - processLockouts(); + // Finish connecting when appropriate + connToServerState = 0; + connToServerConnecting = true; + TQTimer::singleShot(0, this, SLOT(finishConnectingToServer())); + } } void RemoteMDI::promptForStationType() { @@ -290,7 +322,7 @@ void RemoteMDI::connectionClosedHandler() { void RemoteMDI::processLockouts() { bool connected = false; if (m_rsvSvrSocket) { - connected = (m_rsvSvrSocket->state() == TQSocket::Connected); + connected = ((m_rsvSvrSocket->state() == TQSocket::Connected) && (connToServerConnecting == false) && (connToServerState > 0)); } printf("[RAJA DEBUG 600.0] connected: %d\n\r", connected); fflush(stdout); diff --git a/clients/tde/src/app/remotemdi.h b/clients/tde/src/app/remotemdi.h index a7b62b2..d1a8263 100644 --- a/clients/tde/src/app/remotemdi.h +++ b/clients/tde/src/app/remotemdi.h @@ -59,6 +59,7 @@ class RemoteMDI : public KMdiMainFrm void configToolbars(); void configKeys(); void connectToServer(); + void finishConnectingToServer(); void disconnectFromServer(); void promptForStationType(); void connectionClosedHandler(); @@ -74,6 +75,10 @@ class RemoteMDI : public KMdiMainFrm TDEKerberosClientSocket* m_rsvSvrSocket; + bool connToServerConnecting; + int connToServerState; + TQTimer *connToServerTimeoutTimer; + private: KAction *connect_action; KAction *disconnect_action; diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp index 2b3cf8d..1ca9b6e 100644 --- a/clients/tde/src/part/fpgaview/part.cpp +++ b/clients/tde/src/part/fpgaview/part.cpp @@ -158,6 +158,7 @@ printf("[RAJA DEBUG 200.1] In FPGAViewPart::connectToServer TRIED TO CONNECT TWI if (m_socket->state() != TQSocket::Connected) { return -1; } + m_socket->setDataTimeout(5000); m_socket->setUsingKerberos(true); while (m_socket->kerberosStatus() == TDEKerberosClientSocket::KerberosInitializing) { tqApp->eventLoop()->processEvents(TQEventLoop::AllEvents); |