Allow multiple connections to backend servers which have cleared the single instance flag

master
Timothy Pearson 12 years ago
parent 962bc5cda4
commit 26a027c939

@ -638,7 +638,7 @@ AC_DEFUN([KDE_SUBST_PROGRAMS],
if test -n "$trinity14ornewer"; then
KDE_FIND_PATH(tdeconfig_compiler, KCONFIG_COMPILER, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(tdeconfig_compiler)])
KDE_FIND_PATH(dcopidlng, DCOPIDLNG, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(dcopidlng)])
KDE_FIND_PATH(makekdewidgets, MAKEKDEWIDGETS, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(makekdewidgets)])
KDE_FIND_PATH(maketdewidgets, MAKEKDEWIDGETS, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(maketdewidgets)])
AC_SUBST(MAKEKDEWIDGETS)
fi
KDE_FIND_PATH(xmllint, XMLLINT, [${prefix}/bin ${exec_prefix}/bin], [XMLLINT=""])
@ -2319,7 +2319,7 @@ if test $kde_qtver = 4; then
AC_SUBST(LIB_KJS, "-lkjs")
AC_SUBST(LIB_SMB, "-lsmb")
AC_SUBST(LIB_KAB, "-lkab")
AC_SUBST(LIB_KABC, "-lkabc")
AC_SUBST(LIB_TDEABC, "-ltdeabc")
AC_SUBST(LIB_TDEHTML, "-ltdehtml")
AC_SUBST(LIB_KSPELL, "-ltdespell")
AC_SUBST(LIB_KPARTS, "-ltdeparts")
@ -2345,7 +2345,7 @@ elif test $kde_qtver = 3; then
AC_SUBST(LIB_KJS, "-lkjs")
AC_SUBST(LIB_SMB, "-lsmb")
AC_SUBST(LIB_KAB, "-lkab")
AC_SUBST(LIB_KABC, "-lkabc")
AC_SUBST(LIB_TDEABC, "-ltdeabc")
AC_SUBST(LIB_TDEHTML, "-ltdehtml")
AC_SUBST(LIB_KSPELL, "-ltdespell")
AC_SUBST(LIB_KPARTS, "-ltdeparts")

@ -417,6 +417,7 @@ void AuthSocket::commandLoop() {
while (m_databaseStationsCursor->next()) {
bool authorized = false;
bool in_use = false;
bool multi_use = false;
int ngroups = 0;
gid_t *groups;
@ -461,8 +462,8 @@ void AuthSocket::commandLoop() {
in_use = true;
}
}
if ((authorized) && (!in_use)) {
if (authorized) {
StationType st;
st.id = m_databaseStationsCursor->value("pk").toInt();
st.name = m_databaseStationsCursor->value("name").toString();
@ -480,6 +481,7 @@ void AuthSocket::commandLoop() {
char tempchar;
tempchar = m_databaseServiceTypesCursor->value("single_instance").toInt();
svt.singleInstance = (tempchar != 0);
if (!svt.singleInstance) multi_use = true;
}
if (svt.name == "") {
svt.name = i18n("<unknown>");
@ -489,8 +491,10 @@ void AuthSocket::commandLoop() {
}
st.services.append(svt);
}
m_slist.append(st);
if ((!in_use) || (multi_use)) {
m_slist.append(st);
}
}
}
@ -573,44 +577,78 @@ void AuthSocket::commandLoop() {
}
else {
// Find the service ID for the specified client library name
TQ_INT32 sid = -1;
TQInt32List sidList;
m_databaseServiceTypesCursor->select(TQString("client_library='%1'").arg(libname));
if (m_databaseServiceTypesCursor->next()) {
sid = m_databaseServiceTypesCursor->value("serviceid").toInt();
sidList.append(m_databaseServiceTypesCursor->value("serviceid").toInt());
}
if (sid < 0) {
if (sidList.empty()) {
ds << TQString("ERRNOSERV");
writeEndOfFrame();
}
else {
// Attempt to connect to the backend server
m_databaseServicesCursor->select(TQString("servicetype=%1 AND station=%2").arg(sid).arg(m_stationID));
if (m_databaseServicesCursor->next()) {
m_srvServiceHostName = m_databaseServicesCursor->value("hostname").toString();
m_srvServicePort = m_databaseServicesCursor->value("port").toInt();
// Update database
m_serviceID = sid;
TQSqlRecord *buffer = m_databaseActivityCursor->primeInsert();
buffer->setValue("station", m_stationID);
buffer->setValue("username", m_authenticatedUserName);
buffer->setValue("realmname", m_authenticatedRealmName);
buffer->setValue("logontime", TQDateTime::currentDateTime().toTime_t());
buffer->setValue("serverid", m_serverID);
buffer->setValue("serviceid", m_serviceID);
buffer->setValue("terminate", 0);
m_databaseActivityCursor->insert();
updateStatistics(STATISTICS_NEW_CONNECTION_EVENT);
if (!m_servClientSocket) m_servClientSocket = new TDEKerberosClientSocket;
m_servClientSocket->setServiceName("ulab");
TQ_INT32 sid = -1;
while (1) {
m_databaseServicesCursor->select(TQString("servicetype=%1 AND station=%2").arg(sidList[0]).arg(m_stationID));
if (m_databaseServicesCursor->next()) {
sid = sidList[0];
break;
}
sidList.remove(sidList.at(0));
if (sidList.isEmpty()) {
break;
}
}
if (sid != -1) {
// Enforce single instance flags
bool available = true;
m_databaseServiceTypesCursor->select(TQString("serviceid=%1").arg(sid));
if (m_databaseServiceTypesCursor->next()) {
char tempchar;
tempchar = m_databaseServiceTypesCursor->value("single_instance").toInt();
if (tempchar != 0) {
// Verify that service is not already in use
m_databaseActivityCursor->select(TQString("station=%1 AND serviceid=%2").arg(m_databaseStationsCursor->value("pk").toInt()).arg(sid));
while (m_databaseActivityCursor->next()) {
if (m_databaseActivityCursor->value("username").toString() != "") {
available = false;
}
}
}
}
if (available) {
m_srvServiceHostName = m_databaseServicesCursor->value("hostname").toString();
m_srvServicePort = m_databaseServicesCursor->value("port").toInt();
// Update database
m_serviceID = sid;
TQSqlRecord *buffer = m_databaseActivityCursor->primeInsert();
buffer->setValue("station", m_stationID);
buffer->setValue("username", m_authenticatedUserName);
buffer->setValue("realmname", m_authenticatedRealmName);
buffer->setValue("logontime", TQDateTime::currentDateTime().toTime_t());
buffer->setValue("serverid", m_serverID);
buffer->setValue("serviceid", m_serviceID);
buffer->setValue("terminate", 0);
m_databaseActivityCursor->insert();
updateStatistics(STATISTICS_NEW_CONNECTION_EVENT);
if (!m_servClientSocket) m_servClientSocket = new TDEKerberosClientSocket;
m_servClientSocket->setServiceName("ulab");
m_servClientSocket->setServerFQDN(m_srvServiceHostName);
m_servClientSocket->connectToHost(m_srvServiceHostName, m_srvServicePort);
m_servClientSocket->setServerFQDN(m_srvServiceHostName);
m_servClientSocket->connectToHost(m_srvServiceHostName, m_srvServicePort);
m_servState = 0;
m_servActive = true;
m_servState = 0;
m_servActive = true;
}
else {
ds << TQString("ERRNOSERV");
writeEndOfFrame();
}
}
else {
ds << TQString("ERRNOSERV");

Loading…
Cancel
Save