Skip to content
Permalink
Browse files

🐛 Fixed 'Receive Error' on client disconnect

  • Loading branch information...
ulteq committed Feb 7, 2019
1 parent 54a9fa9 commit 77950d2dae8bf83d423954fc7d847c280e5d3721
Showing with 8 additions and 6 deletions.
  1. +8 −6 source/server/sequencer.cpp
@@ -389,7 +389,6 @@ void Sequencer::killerthreadstart() {
}

void Sequencer::disconnect(int uid, const char *errormsg, bool isError, bool doScriptCallback /*= true*/) {
MutexLocker scoped_lock(m_killer_mutex);
Client *client = this->FindClientById(static_cast<unsigned int>(uid));
if (client == nullptr) {
return;
@@ -416,20 +415,23 @@ void Sequencer::disconnect(int uid, const char *errormsg, bool isError, bool doS
//so we use a killer thread
Logger::Log(LOG_VERBOSE, "Disconnecting client ID %d: %s", uid, errormsg);
Logger::Log(LOG_DEBUG, "adding client to kill queue, size: %d", m_kill_queue.size());
m_kill_queue.push(client);
{
MutexLocker scoped_lock(m_killer_mutex);
m_kill_queue.push(client);
}
m_killer_cond.signal();

//notify the others
int pos = 0;
for (unsigned int i = 0; i < m_clients.size(); i++) {
m_clients[i]->QueueMessage(RoRnet::MSG2_USER_LEAVE, client->user.uniqueid, 0, (int) strlen(errormsg), errormsg);
if (m_clients[i]->user.uniqueid == static_cast<unsigned int>(uid)) {
pos = i;
} else {
m_clients[i]->QueueMessage(RoRnet::MSG2_USER_LEAVE, uid, 0, (int) strlen(errormsg), errormsg);
}
}
m_clients.erase(m_clients.begin() + pos);

m_killer_cond.signal();

this->connCount++;
if (isError) {
this->connCrash++;
@@ -594,7 +596,7 @@ bool Sequencer::Kick(int kuid, int modUID, const char *msg) {
Str::SanitizeUtf8(kicked_client->user.username).c_str(),
Str::SanitizeUtf8(mod_client->user.username).c_str());

disconnect(kicked_client->user.uniqueid, kickmsg);
disconnect(kicked_client->user.uniqueid, kickmsg, false);
return true;
}

0 comments on commit 77950d2

Please sign in to comment.
You can’t perform that action at this time.