From 65ea633f475c7ab2b524dc1ffb369f6607df3e6b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 28 Jun 2012 18:28:19 -0500 Subject: Convert servers to cooperative multitasking --- servers/fpga_server_lin/src/fpga_conn.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'servers/fpga_server_lin/src/fpga_conn.cpp') diff --git a/servers/fpga_server_lin/src/fpga_conn.cpp b/servers/fpga_server_lin/src/fpga_conn.cpp index ddd430a..4c6f65e 100644 --- a/servers/fpga_server_lin/src/fpga_conn.cpp +++ b/servers/fpga_server_lin/src/fpga_conn.cpp @@ -41,10 +41,6 @@ #include "fpga_conn.h" #define ABORT_SOCKET(s) s->close(); \ - tqApp->processEvents(); \ - while (s->state() == TQSocket::Closing) { \ - tqApp->processEvents(); \ - } \ s->disconnect(); \ delete s; \ s = NULL; @@ -153,13 +149,13 @@ int FPGASocket::setupSerial() { return 0; } -int FPGASocket::enterCommandLoop() { +void FPGASocket::commandLoop() { int cc; char buffer[10000]; m_criticalSection++; try { - while (state() == TQSocket::Connected) { + if (state() == TQSocket::Connected) { cc = read(m_fd_tty, buffer, 10000); if (cc > 0) { writeBlock(buffer, cc); @@ -175,16 +171,21 @@ int FPGASocket::enterCommandLoop() { } } } - m_criticalSection--; - return 0; + TQTimer::singleShot(0, this, SLOT(commandLoop())); + return; } catch (...) { m_criticalSection--; - return -1; + return; } } +int FPGASocket::enterCommandLoop() { + TQTimer::singleShot(0, this, SLOT(commandLoop())); + return 0; +} + /* The FPGAServer class handles new connections to the server. For every client that connects, it creates a new FPGASocket -- that instance is now -- cgit v1.2.3