UserManager::UserManager()
: clientlist(new user_hash)
, uuidlist(new user_hash)
- , unregistered_count(0), local_count(0)
+ , unregistered_count(0)
{
}
}
UserIOHandler* eh = &New->eh;
- /* Give each of the modules an attempt to hook the user for I/O */
- FOREACH_MOD(OnHookIO, (eh, via));
-
- if (eh->GetIOHook())
- {
- try
- {
- eh->GetIOHook()->OnStreamSocketAccept(eh, client, server);
- }
- catch (CoreException& modexcept)
- {
- ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "%s threw an exception: %s", modexcept.GetSource().c_str(), modexcept.GetReason().c_str());
- }
- }
+ // If this listener has an IO hook provider set then tell it about the connection
+ if (via->iohookprov)
+ via->iohookprov->OnAccept(eh, client, server);
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "New user fd: %d", socket);
ServerInstance->Users->AddLocalClone(New);
ServerInstance->Users->AddGlobalClone(New);
- New->localuseriter = this->local_users.insert(local_users.end(), New);
- local_count++;
+ this->local_users.push_front(New);
- if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)ServerInstance->SE->GetMaxFds()))
+ if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)SocketEngine::GetMaxFds()))
{
ServerInstance->SNO->WriteToSnoMask('a', "Warning: softlimit value has been reached: %d clients", ServerInstance->Config->SoftLimit);
this->QuitUser(New,"No more connections allowed");
}
}
- if (!ServerInstance->SE->AddFd(eh, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE))
+ if (!SocketEngine::AddFd(eh, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE))
{
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "Internal error on new connection");
this->QuitUser(New, "Internal error handling connection");
ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: Nick not found in clientlist, cannot remove: " + user->nick);
uuidlist->erase(user->uuid);
+ user->PurgeEmptyChannels();
}
void UserManager::AddLocalClone(User *user)
if (!curr->lastping)
{
time_t time = ServerInstance->Time() - (curr->nping - curr->MyClass->GetPingTime());
- const std::string message = "Ping timeout: " + ConvToStr(time) + (time == 1 ? " seconds" : " second");
+ const std::string message = "Ping timeout: " + ConvToStr(time) + (time != 1 ? " seconds" : " second");
this->QuitUser(curr, message);
continue;
}