summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2019-01-10 16:41:22 -0500
committergumi <git@gumi.ca>2019-01-10 19:06:36 -0500
commit86f28c5b69a54e630dd2a118e07cabb3d199d5b5 (patch)
treef9dc01878e194c6e98e3bbc20d12586eb9daaf86 /src/char
parentc38f0ab54c6d03f002f0be14bc5e17337f81c9a5 (diff)
downloadtmwa-86f28c5b69a54e630dd2a118e07cabb3d199d5b5.tar.gz
tmwa-86f28c5b69a54e630dd2a118e07cabb3d199d5b5.tar.bz2
tmwa-86f28c5b69a54e630dd2a118e07cabb3d199d5b5.tar.xz
tmwa-86f28c5b69a54e630dd2a118e07cabb3d199d5b5.zip
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
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.cpp32
1 files 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)
{