Fix the ability for IPData refcount to go negative

This commit is contained in:
modeco80
2024-07-10 18:32:05 -04:00
parent a2f450b374
commit bee25b5381
3 changed files with 3 additions and 6 deletions

View File

@@ -170,9 +170,6 @@ export default class CollabVMServer {
this.sendVoteUpdate();
}
// Unreference the IP data.
user.IP.Unref();
if (this.indefiniteTurn === user) this.indefiniteTurn = null;
this.clients.splice(clientIndex, 1);

View File

@@ -16,7 +16,7 @@ export class IPData {
// Call when a connection is closed to "release" the ip data
Unref() {
if (this.refCount - 1 < 0) this.refCount = 0;
this.refCount--;
else this.refCount--;
}
}
@@ -64,7 +64,7 @@ export class IPDataManager {
setInterval(() => {
for (let tuple of IPDataManager.ipDatas) {
if (tuple[1].refCount == 0) {
IPDataManager.logger.Info('Deleted ipdata for IP {0}', tuple[0]);
IPDataManager.logger.Info('Deleted IPData for IP {0}', tuple[0]);
IPDataManager.ipDatas.delete(tuple[0]);
}
}