1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-01 23:25:09 +02:00

terminate connections on long network timeouts

This commit is contained in:
p2r3
2025-08-31 00:01:35 +03:00
parent 7d390ed899
commit f3fbde3134
4 changed files with 22 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "globals.h"
#include "tools.h"
@@ -145,6 +146,16 @@ void handlePlayerDisconnect (int client_fd) {
}
}
void disconnectClient (int *client_fd, int cause) {
if (*client_fd == -1) return;
client_count --;
setClientState(*client_fd, STATE_NONE);
handlePlayerDisconnect(*client_fd);
close(*client_fd);
*client_fd = -1;
printf("Disconnected client %d, cause: %d, errno: %d\n\n", *client_fd, cause, errno);
}
uint8_t serverSlotToClientSlot (int window_id, uint8_t slot) {
if (window_id == 0) { // player inventory