From 86f28c5b69a54e630dd2a118e07cabb3d199d5b5 Mon Sep 17 00:00:00 2001 From: gumi Date: Thu, 10 Jan 2019 16:41:22 -0500 Subject: avoid filling the fifo queue in char server for new authentications There can only be one connection per account id at any given time, so we can safely recycle old fifo entries with the same id --- src/char/char.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/char/char.cpp b/src/char/char.cpp index 81b2ab7..417b0d3 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -1266,16 +1266,28 @@ void parse_tologin(Session *ls) if (rv != RecvResult::Complete) break; - if (auth_fifo_iter == auth_fifo.end()) - auth_fifo_iter = auth_fifo.begin(); - auth_fifo_iter->account_id = fixed.account_id; - auth_fifo_iter->char_id = CharId(); - auth_fifo_iter->login_id1 = fixed.login_id1; - auth_fifo_iter->login_id2 = fixed.login_id2; - auth_fifo_iter->delflag = 2; - auth_fifo_iter->ip = fixed.ip; - auth_fifo_iter->client_version = fixed.client_protocol_version; - auth_fifo_iter++; + // re-use any previous fifo entry instead of flooding the queue + AuthFifoEntry *found = nullptr; + for (AuthFifoEntry& afi : auth_fifo) + if (afi.account_id == fixed.account_id) + found = &afi; // found: update entry + + // not found: add new entry + if (found == nullptr) + { + if (auth_fifo_iter == auth_fifo.end()) + auth_fifo_iter = auth_fifo.begin(); + found = auth_fifo_iter; + auth_fifo_iter++; + } + + found->account_id = fixed.account_id; + found->char_id = CharId(); + found->login_id1 = fixed.login_id1; + found->login_id2 = fixed.login_id2; + found->delflag = 2; + found->ip = fixed.ip; + found->client_version = fixed.client_protocol_version; if (login_session) { -- cgit v1.2.3-60-g2f50