diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-06 12:55:52 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-06 12:55:52 -0500 |
commit | 8cc7778d9f0d659318f50c78abb5b31db82399ca (patch) | |
tree | ff4e3bc956dc11f6d6e861dcfa5ac8635e7614e8 /servers/fpga_programming_server_lin | |
parent | 1382b1f0c8d40386827dc49cb8fd7eb869e755aa (diff) | |
download | ulab-8cc7778d9f0d659318f50c78abb5b31db82399ca.tar.gz ulab-8cc7778d9f0d659318f50c78abb5b31db82399ca.zip |
Get rid of processevents calls in servers
Diffstat (limited to 'servers/fpga_programming_server_lin')
-rw-r--r-- | servers/fpga_programming_server_lin/src/fpga_conn.cpp | 65 | ||||
-rw-r--r-- | servers/fpga_programming_server_lin/src/fpga_conn.h | 4 |
2 files changed, 40 insertions, 29 deletions
diff --git a/servers/fpga_programming_server_lin/src/fpga_conn.cpp b/servers/fpga_programming_server_lin/src/fpga_conn.cpp index 08c5d38..2d02964 100644 --- a/servers/fpga_programming_server_lin/src/fpga_conn.cpp +++ b/servers/fpga_programming_server_lin/src/fpga_conn.cpp @@ -59,6 +59,10 @@ struct exit_exception { FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) : TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_loopTimer(NULL), m_config(static_cast<FPGAServer*>(parent)->m_config), m_commandLoopState(0) { + // Initialize timers + m_kerberosInitTimer = new TQTimer(); + connect(m_kerberosInitTimer, SIGNAL(timeout()), this, SLOT(finishKerberosHandshake())); + setServiceName("remotefpga"); line = 0; @@ -68,6 +72,11 @@ FPGASocket::FPGASocket(int sock, TQObject *parent, const char *name) : } FPGASocket::~FPGASocket() { + if (m_kerberosInitTimer) { + m_kerberosInitTimer->stop(); + delete m_kerberosInitTimer; + m_kerberosInitTimer = NULL; + } if (m_loopTimer) { m_loopTimer->stop(); delete m_loopTimer; @@ -91,20 +100,39 @@ void FPGASocket::connectionClosedHandler() { } } -int FPGASocket::initiateKerberosHandshake() { +void FPGASocket::initiateKerberosHandshake() { setUsingKerberos(true); - while (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) { - // RAJA FIXME - tqApp->processEvents(); + m_kerberosInitTimer->start(100, TRUE); +} + +void FPGASocket::finishKerberosHandshake() { + if (kerberosStatus() == TDEKerberosServerSocket::KerberosInitializing) { + m_kerberosInitTimer->start(100, TRUE); + return; } if (kerberosStatus() == TDEKerberosServerSocket::KerberosInUse) { + m_config->setGroup("Security"); + TQString masterUser = m_config->readEntry("masteruser"); + TQString masterRealm = m_config->readEntry("masterrealm"); + if (masterRealm == "") { + masterRealm = "(NULL)"; + } + if ((m_authenticatedUserName != masterUser) || (m_authenticatedRealmName != masterRealm)) { + printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", m_remoteHost.ascii(), masterUser.ascii(), masterRealm.ascii()); + close(); + return; + } + TQDataStream ds(this); ds << TQString("OK"); - return 0; + enterCommandLoop(); + return; } else { - return -1; + printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", m_remoteHost.ascii()); fflush(stdout); + close(); + return; } } @@ -173,28 +201,9 @@ void FPGAServer::newConnection(int socket) { ABORT_SOCKET(s) return; } - if (s->initiateKerberosHandshake() != 0) { - printf("[DEBUG] Connection from %s closed due to Kerberos failure\n\r", s->m_remoteHost.ascii()); - ABORT_SOCKET(s) - return; - } - m_config->setGroup("Security"); - TQString masterUser = m_config->readEntry("masteruser"); - TQString masterRealm = m_config->readEntry("masterrealm"); - if (masterRealm == "") { - masterRealm = "(NULL)"; - } - if ((s->m_authenticatedUserName != masterUser) || (s->m_authenticatedRealmName != masterRealm)) { - printf("[DEBUG] Connection from %s closed due to authentication failure (attempted connection as user %s@%s)\n\r", s->m_remoteHost.ascii(), masterUser.ascii(), masterRealm.ascii()); - ABORT_SOCKET(s) - return; - } - else { - m_numberOfConnections++; - connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater())); - emit newConnect(s); - s->enterCommandLoop(); - } + connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater())); + s->initiateKerberosHandshake(); + emit newConnect(s); } void FPGAServer::remoteConnectionClosed() { diff --git a/servers/fpga_programming_server_lin/src/fpga_conn.h b/servers/fpga_programming_server_lin/src/fpga_conn.h index 69c7c73..c9b109b 100644 --- a/servers/fpga_programming_server_lin/src/fpga_conn.h +++ b/servers/fpga_programming_server_lin/src/fpga_conn.h @@ -48,10 +48,11 @@ class FPGASocket : public TDEKerberosServerSocket public: void close(); - int initiateKerberosHandshake(); + void initiateKerberosHandshake(); int enterCommandLoop(); private slots: + void finishKerberosHandshake(); void connectionClosedHandler(); void commandLoop(); @@ -60,6 +61,7 @@ class FPGASocket : public TDEKerberosServerSocket int m_criticalSection; TQString m_remoteHost; + TQTimer* m_kerberosInitTimer; TQTimer* m_loopTimer; KSimpleConfig* m_config; |