summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/part/fpgaview
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-28 18:28:19 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-06-28 18:28:19 -0500
commit65ea633f475c7ab2b524dc1ffb369f6607df3e6b (patch)
tree8fac782af0723eba4e3110cafe59cb521444eaa2 /clients/tde/src/part/fpgaview
parent8392c611054a5bb058cd778163a7aa4ef8311c94 (diff)
downloadulab-65ea633f475c7ab2b524dc1ffb369f6607df3e6b.tar.gz
ulab-65ea633f475c7ab2b524dc1ffb369f6607df3e6b.zip
Convert servers to cooperative multitasking
Diffstat (limited to 'clients/tde/src/part/fpgaview')
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp119
1 files changed, 62 insertions, 57 deletions
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index 4eae27d..52a1d92 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -46,12 +46,6 @@
#include "floatspinbox.h"
#include "layout.h"
-/* exception handling */
-struct exit_exception {
- int c;
- exit_exception(int c):c(c) { }
-};
-
namespace RemoteLab {
typedef KParts::GenericFactory<RemoteLab::FPGAViewPart> Factory;
@@ -82,7 +76,7 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj
FPGAViewPart::~FPGAViewPart() {
if (m_connectionMutex->locked()) {
- throw exit_exception(-1);
+ printf("[WARNING] Exiting when data transfer still in progress!\n\r"); fflush(stdout);
}
if (m_socket) {
@@ -95,11 +89,14 @@ FPGAViewPart::~FPGAViewPart() {
}
void FPGAViewPart::processLockouts() {
- if ((m_socket) && (m_socket->state() == TQSocket::Connected)) {
- widget()->setEnabled(true);
- }
- else {
- widget()->setEnabled(false);
+ TQWidget* mainWidget = widget();
+ if (mainWidget) {
+ if ((m_socket) && (m_socket->state() == TQSocket::Connected)) {
+ mainWidget->setEnabled(true);
+ }
+ else {
+ mainWidget->setEnabled(false);
+ }
}
}
@@ -114,22 +111,27 @@ void FPGAViewPart::postInit() {
bool FPGAViewPart::openURL(const KURL &url) {
int ret;
ret = connectToServer(url.url());
+ // RAJA FIXME
+ // Need canary?
processLockouts();
return (ret != 0);
}
bool FPGAViewPart::closeURL() {
- if (m_connectionMutex->locked()) {
- throw exit_exception(-1);
- }
-
+printf("[RAJA DEBUG 710.0] In FPGAViewPart::closeURL\n\r"); fflush(stdout);
+printf("[RAJA DEBUG 710.1] In FPGAViewPart::closeURL\n\r"); fflush(stdout);
if (m_socket) {
m_socket->clearPendingData();
+printf("[RAJA DEBUG 710.2] In FPGAViewPart::closeURL\n\r"); fflush(stdout);
m_socket->close();
- delete m_socket;
+printf("[RAJA DEBUG 710.3] In FPGAViewPart::closeURL\n\r"); fflush(stdout);
+ m_socket->deleteLater();
+printf("[RAJA DEBUG 710.4] In FPGAViewPart::closeURL\n\r"); fflush(stdout);
m_socket = NULL;
+printf("[RAJA DEBUG 710.5] In FPGAViewPart::closeURL\n\r"); fflush(stdout);
}
+printf("[RAJA DEBUG 710.6] In FPGAViewPart::closeURL\n\r"); fflush(stdout);
processLockouts();
m_url = KURL();
@@ -138,6 +140,11 @@ bool FPGAViewPart::closeURL() {
}
int FPGAViewPart::connectToServer(TQString server) {
+printf("[RAJA DEBUG 200.0] In FPGAViewPart::connectToServer\n\r"); fflush(stdout);
+ if (m_socket) {
+printf("[RAJA DEBUG 200.1] In FPGAViewPart::connectToServer TRIED TO CONNECT TWICE!!!\n\r"); fflush(stdout);
+ return -1;
+ }
if (!m_socket) {
m_socket = new TDEKerberosClientSocket(this);
}
@@ -146,63 +153,61 @@ int FPGAViewPart::connectToServer(TQString server) {
m_socket->connectToHost(server, 4004);
while ((m_socket->state() != TQSocket::Connected) && (m_socket->state() != TQSocket::Idle)) {
tqApp->eventLoop()->processEvents(TQEventLoop::AllEvents);
+ if (!m_socket) return -1; // Any entry into the event loop could end up deleting the socket object depending on user interaction
}
if (m_socket->state() != TQSocket::Connected) {
return -1;
}
if (m_socket->setUsingKerberos(true) != 0) {
+ if (!m_socket) return -1; // Any entry into the event loop could end up deleting the socket object depending on user interaction
m_socket->close();
KMessageBox::error(0, 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"));
return -1;
}
connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(connectionClosed()));
- try {
- m_connectionMutex->lock();
- TQString response;
- TQDataStream ds(m_socket);
- // Read magic number and proto version from server
- TQ_UINT32 magicnum;
- TQ_UINT32 protover;
- ds >> magicnum;
- ds >> protover;
- printf("[DEBUG] Got magic number %d and protocol version %d\n\r", magicnum, protover); fflush(stdout);
- // Request connection to backend server
- ds << TQString("SERV");
- ds << TQString(CLIENT_LIBRARY);
- ds >> response;
-printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); fflush(stdout);
- if (response == "OK") {
- m_connectionMutex->unlock();
- return 0;
- }
- else if (response == "ERRNOCONN") {
- KMessageBox::error(0, i18n("<qt>Unable to establish connection with backend server<p>Please verify that you are currently connected to a workspace</qt>"), i18n("Connection Failed"));
- m_connectionMutex->unlock();
- return -1;
- }
- else if (response == "ERRNOTAVL") {
- KMessageBox::error(0, i18n("<qt>The backend server is not available at this time<p>Please try a different workspace, or try again later</qt>"), i18n("Connection Failed"));
- m_connectionMutex->unlock();
- return -1;
- }
- else if (response == "ERRNOSERV") {
- KMessageBox::error(0, i18n("<qt>The active laboratory workspace does not support the requested service</qt>"), i18n("Service Unavailable"));
- m_connectionMutex->unlock();
- return -1;
- }
- else {
- KMessageBox::error(0, i18n("<qt>Unable to establish connection with remote server</qt>"), i18n("Connection Failed"));
- m_connectionMutex->unlock();
- return -1;
- }
+ // Kerberos connection established!
+ m_connectionMutex->lock();
+ TQString response;
+ TQDataStream ds(m_socket);
+ // Read magic number and proto version from server
+ TQ_UINT32 magicnum;
+ TQ_UINT32 protover;
+ ds >> magicnum;
+ ds >> protover;
+ printf("[DEBUG] Got magic number %d and protocol version %d\n\r", magicnum, protover); fflush(stdout);
+ // Request connection to backend server
+ ds << TQString("SERV");
+ ds << TQString(CLIENT_LIBRARY);
+ ds >> response;
+printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); fflush(stdout);
+ if (response == "OK") {
m_connectionMutex->unlock();
return 0;
}
- catch (exit_exception& e) {
+ else if (response == "ERRNOCONN") {
+ KMessageBox::error(0, i18n("<qt>Unable to establish connection with backend server<p>Please verify that you are currently connected to a workspace</qt>"), i18n("Connection Failed"));
+ m_connectionMutex->unlock();
+ return -1;
+ }
+ else if (response == "ERRNOTAVL") {
+ KMessageBox::error(0, i18n("<qt>The backend server is not available at this time<p>Please try a different workspace, or try again later</qt>"), i18n("Connection Failed"));
m_connectionMutex->unlock();
return -1;
}
+ else if (response == "ERRNOSERV") {
+ KMessageBox::error(0, i18n("<qt>The active laboratory workspace does not support the requested service</qt>"), i18n("Service Unavailable"));
+ m_connectionMutex->unlock();
+ return -1;
+ }
+ else {
+ KMessageBox::error(0, i18n("<qt>Unable to establish connection with remote server</qt>"), i18n("Connection Failed"));
+ m_connectionMutex->unlock();
+ return -1;
+ }
+
+ m_connectionMutex->unlock();
+ return 0;
}
void FPGAViewPart::updateDisplay() {