diff options
-rw-r--r-- | database/mysql/remotelab.sql | 11 | ||||
-rw-r--r-- | servers/auth_server_lin/src/auth_conn.cpp | 23 | ||||
-rw-r--r-- | servers/auth_server_lin/src/auth_conn.h | 1 |
3 files changed, 32 insertions, 3 deletions
diff --git a/database/mysql/remotelab.sql b/database/mysql/remotelab.sql index e93173d..9bafda7 100644 --- a/database/mysql/remotelab.sql +++ b/database/mysql/remotelab.sql @@ -103,6 +103,17 @@ CREATE TABLE `statistics` ( PRIMARY KEY (`pk`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
+/*Table structure for table `status` */
+
+DROP TABLE IF EXISTS `status`;
+
+CREATE TABLE `status` (
+ `pk` bigint(20) NOT NULL AUTO_INCREMENT,
+ `hostname` text NOT NULL,
+ `online` tinyint(4) NOT NULL,
+ PRIMARY KEY (`pk`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp index d9794ad..72e8240 100644 --- a/servers/auth_server_lin/src/auth_conn.cpp +++ b/servers/auth_server_lin/src/auth_conn.cpp @@ -50,7 +50,7 @@ struct exit_exception { */ AuthSocket::AuthSocket(int sock, int serverID, TQObject *parent, const char *name) : TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_serviceID(0), m_serverID(serverID), m_terminationStamp(0), m_servActive(false), m_servState(0), m_servClientSocket(NULL), m_servClientTimeout(NULL), m_loopTimer(NULL), m_pollTimer(NULL), m_config(static_cast<AuthServer*>(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL), - m_databaseServicesCursor(NULL), m_databaseServiceTypesCursor(NULL), m_databasePermissionsCursor(NULL), m_databaseActivityCursor(NULL), m_databaseStatisticsCursor(NULL) + m_databaseServicesCursor(NULL), m_databaseServiceTypesCursor(NULL), m_databasePermissionsCursor(NULL), m_databaseActivityCursor(NULL), m_databaseStatisticsCursor(NULL), m_databaseStatusCursor(NULL) { // Initialize timers @@ -107,6 +107,9 @@ AuthSocket::~AuthSocket() { if (m_databaseStatisticsCursor) { delete m_databaseStatisticsCursor; } + if (m_databaseStatusCursor) { + delete m_databaseStatusCursor; + } if (m_servClientSocket) { delete m_servClientSocket; } @@ -519,8 +522,21 @@ void AuthSocket::commandLoop() { if (activeID < 0) { for (StationList::Iterator it(m_slist.begin()); it != m_slist.end(); ++it) { if ((*it).services == st.services) { - m_stationID = (*it).id; - break; + // Verify that all services provided by this candidate workspace are online before allocating the workspace to a user + bool online = true; + m_databaseServicesCursor->select(TQString("station=%1").arg((*it).id)); + while (m_databaseServicesCursor->next()) { + m_databaseStatusCursor->select(TQString("serviceid=%1").arg(m_databaseServicesCursor->value("hostname").toString())); + if (m_databaseStatusCursor->next()) { + if (m_databaseStatusCursor->value("online").toInt() == 0) { + online = false; + } + } + } + if (online) { + m_stationID = (*it).id; + break; + } } } @@ -713,6 +729,7 @@ int AuthSocket::connectToDatabase() { m_databasePermissionsCursor = new TQSqlCursor("permissions", TRUE, m_database); m_databaseActivityCursor = new TQSqlCursor("activity", TRUE, m_database); m_databaseStatisticsCursor = new TQSqlCursor("statistics", TRUE, m_database); + m_databaseStatusCursor = new TQSqlCursor("status", TRUE, m_database); return 0; } diff --git a/servers/auth_server_lin/src/auth_conn.h b/servers/auth_server_lin/src/auth_conn.h index b4f8b23..612b671 100644 --- a/servers/auth_server_lin/src/auth_conn.h +++ b/servers/auth_server_lin/src/auth_conn.h @@ -95,6 +95,7 @@ class AuthSocket : public TDEKerberosServerSocket TQSqlCursor* m_databasePermissionsCursor; TQSqlCursor* m_databaseActivityCursor; TQSqlCursor* m_databaseStatisticsCursor; + TQSqlCursor* m_databaseStatusCursor; StationList m_slist; |