Don't spawn new instances when there are free ones
This commit is contained in:
parent
f0f819b4fd
commit
887699284b
1 changed files with 18 additions and 3 deletions
|
@ -684,15 +684,30 @@ void NetworkPluginServer::sendPing(Client *c) {
|
|||
}
|
||||
|
||||
NetworkPluginServer::Client *NetworkPluginServer::getFreeClient() {
|
||||
NetworkPluginServer::Client *c = NULL;
|
||||
bool spawnNew = false;
|
||||
for (std::list<Client *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
|
||||
if ((*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend")) {
|
||||
if ((*it)->users.size() + 1 == CONFIG_INT(m_config, "service.users_per_backend")) {
|
||||
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), CONFIG_STRING(m_config, "service.backend_host").c_str(), CONFIG_STRING(m_config, "service.backend_port").c_str(), m_config->getConfigFile().c_str());
|
||||
spawnNew = true;
|
||||
}
|
||||
if (c == NULL) {
|
||||
c = *it;
|
||||
}
|
||||
else {
|
||||
if ((*it)->users.size() + 1 != CONFIG_INT(m_config, "service.users_per_backend")) {
|
||||
spawnNew = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (*it);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
if (spawnNew) {
|
||||
exec_(CONFIG_STRING(m_config, "service.backend").c_str(), CONFIG_STRING(m_config, "service.backend_host").c_str(), CONFIG_STRING(m_config, "service.backend_port").c_str(), m_config->getConfigFile().c_str());
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue