summaryrefslogtreecommitdiff
path: root/src/server.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-02 16:57:36 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-05-02 16:57:36 +0000
commit9058b5c0bfc9a05c9004cfbbcdd3bb85d80ed6fc (patch)
treeacf351bdd648594639005f71e7e7d8921bb70fcb /src/server.c
parent29173b3199ea526b6f9de13ee9255db3900f3f42 (diff)
- o obsluhu odstaneni streli pri vybuchu sa stara server
- server sa _nemusi_ restartovat kazdych 49 dni - uptime sa rata v sekundach, v statuse je aj nazov areny - drobne upravy v kode ( vymazanie mensej duplicity kodu ) git-svn-id: http://opensvn.csie.org/tuxanci_ng@49 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/server.c')
-rw-r--r--src/server.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/server.c b/src/server.c
index 37f38eb..26867a8 100644
--- a/src/server.c
+++ b/src/server.c
@@ -41,9 +41,19 @@ static sock_sdl_udp_t *sock_server_sdl_udp;
static list_t *listClient;
static list_t *listServerTimer;
-static my_time_t lastSyncClient;
+static time_t timeUpdate;
static int maxClients;
+static void startUpdateServer()
+{
+ timeUpdate = time(NULL);
+}
+
+time_t getUpdateServer()
+{
+ return time(NULL) - timeUpdate;
+}
+
static void delZombieCLient(void *p_nothink)
{
client_t *thisClient;
@@ -121,6 +131,7 @@ static void eventPeriodicSyncClient(void *p_nothink)
}
}
+/*
static void eventPeriodicSyncSelfClient(void *p_nothink)
{
client_t *thisClient;
@@ -136,24 +147,38 @@ static void eventPeriodicSyncSelfClient(void *p_nothink)
}
}
}
+*/
static void eventSendPingClients(void *p_nothink)
{
proto_send_ping_server(PROTO_SEND_ALL, NULL);
}
-void static initServer()
+
+static void setServerTimer()
{
- listClient = newList();
- lastSyncClient = getMyTime();
- setServerMaxClients(SERVER_MAX_CLIENTS);
+ if( listServerTimer != NULL )
+ {
+ destroyTimer(listServerTimer);
+ }
+ restartTimer();
listServerTimer = newTimer();
addTaskToTimer(listServerTimer, TIMER_PERIODIC, delZombieCLient, NULL, SERVER_TIMEOUT);
addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncClient, NULL, SERVER_TIME_SYNC);
//addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventPeriodicSyncSelfClient, NULL, 5000);
addTaskToTimer(listServerTimer, TIMER_PERIODIC, eventSendPingClients, NULL, SERVER_TIME_PING);
+
+}
+
+void static initServer()
+{
+ startUpdateServer();
+ listServerTimer = NULL;
+ listClient = newList();
+ setServerMaxClients(SERVER_MAX_CLIENTS);
+ setServerTimer();
}
#ifdef SUPPORT_NET_UNIX_UDP
@@ -554,7 +579,7 @@ void selectServerUdpSocket()
if( listClient->count == 0 )
{
ret = select(max_fd+1, &readfds, (fd_set *)NULL, (fd_set *)NULL, NULL);
- //restartTimer();
+ setServerTimer();
}
else
{