summaryrefslogtreecommitdiffstats
path: root/servers/auth_server_lin
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-04 20:29:14 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-04 20:29:14 -0500
commitd5316f5795e3557d032af9a95ba4e5fa88191834 (patch)
treed083b877c06dc8f1e98a49c29c25ee9dbec06644 /servers/auth_server_lin
parentb5fa21be6e5c4e07494186343c9b1d7fa5d801fb (diff)
downloadulab-d5316f5795e3557d032af9a95ba4e5fa88191834.tar.gz
ulab-d5316f5795e3557d032af9a95ba4e5fa88191834.zip
Add interface mode selection
Make servers use less CPU
Diffstat (limited to 'servers/auth_server_lin')
-rw-r--r--servers/auth_server_lin/src/auth_conn.cpp40
-rw-r--r--servers/auth_server_lin/src/auth_conn.h2
2 files changed, 37 insertions, 5 deletions
diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp
index 29b8501..23d0336 100644
--- a/servers/auth_server_lin/src/auth_conn.cpp
+++ b/servers/auth_server_lin/src/auth_conn.cpp
@@ -131,7 +131,10 @@ int AuthSocket::initiateKerberosHandshake() {
}
}
-void AuthSocket::servLoop() {
+int AuthSocket::servLoop() {
+ bool transferred_data;
+
+ transferred_data = false;
if (m_servActive) {
TQString command;
TQDataStream ds(this);
@@ -159,6 +162,7 @@ void AuthSocket::servLoop() {
delete m_servClientTimeout;
m_servClientTimeout = NULL;
}
+ transferred_data = true;
m_servState = 1;
}
break;
@@ -180,6 +184,7 @@ void AuthSocket::servLoop() {
krbstat = m_servClientSocket->kerberosStatus();
if ((krbstat == TDEKerberosClientSocket::KerberosInitializing) || (krbstat == TDEKerberosClientSocket::KerberosInUse)) {
if (krbstat == TDEKerberosClientSocket::KerberosInUse) {
+ transferred_data = true;
m_servState = 3;
}
}
@@ -205,6 +210,7 @@ void AuthSocket::servLoop() {
clientDS >> server_reply;
if (server_reply == "OK") {
ds << TQString("OK");
+ transferred_data = true;
m_servState = 4;
}
else {
@@ -245,10 +251,12 @@ void AuthSocket::servLoop() {
if (canReadData()) {
reclen = readBlock(ba.data(), 8192);
m_servClientSocket->writeBlock(ba.data(), reclen);
+ transferred_data = true;
}
if (m_servClientSocket->canReadData()) {
reclen = m_servClientSocket->readBlock(ba.data(), 8192);
writeBlock(ba.data(), reclen);
+ transferred_data = true;
}
}
else {
@@ -260,21 +268,40 @@ void AuthSocket::servLoop() {
break;
}
}
+
+ if (transferred_data) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
void AuthSocket::commandLoop() {
+ bool transferred_data;
+
if (m_servActive) {
- servLoop();
- if (m_loopTimer) m_loopTimer->start(0, TRUE);
+ transferred_data = false;
+ if (servLoop() == 1) {
+ transferred_data = true;
+ }
+ if (transferred_data) {
+ if (m_loopTimer) m_loopTimer->start(0, TRUE);
+ }
+ else {
+ if (m_loopTimer) m_loopTimer->start(100, TRUE);
+ }
return;
}
m_criticalSection++;
try {
+ transferred_data = false;
if (state() == TQSocket::Connected) {
if (canReadData()) {
TQString command;
TQDataStream ds(this);
+ transferred_data = true;
ds >> command;
if (command != "") {
@@ -432,7 +459,12 @@ void AuthSocket::commandLoop() {
}
m_criticalSection--;
- if (m_loopTimer) m_loopTimer->start(0, TRUE);
+ if (transferred_data) {
+ if (m_loopTimer) m_loopTimer->start(0, TRUE);
+ }
+ else {
+ if (m_loopTimer) m_loopTimer->start(100, TRUE);
+ }
return;
}
}
diff --git a/servers/auth_server_lin/src/auth_conn.h b/servers/auth_server_lin/src/auth_conn.h
index 08f8072..ca938f6 100644
--- a/servers/auth_server_lin/src/auth_conn.h
+++ b/servers/auth_server_lin/src/auth_conn.h
@@ -58,7 +58,7 @@ class AuthSocket : public TDEKerberosServerSocket
int connectToDatabase();
void connectionClosedHandler();
void commandLoop();
- void servLoop();
+ int servLoop();
private:
int line;