MCPcopy Create free account
hub / github.com/JACoders/OpenJK / SV_CheckTimeouts

Function SV_CheckTimeouts

code/server/sv_main.cpp:363–387  ·  view source on GitHub ↗

If a packet has not been received from a client for timeout->integer seconds, drop the conneciton. Server time is used instead of realtime to avoid dropping the local client while debugging. When a client is normally dropped, the client_t goes into a zombie state for a few seconds to make sure any final reliable message gets resent if necessary

Source from the content-addressed store, hash-verified

361// When a client is normally dropped, the client_t goes into a zombie state for a few seconds to make sure any final
362// reliable message gets resent if necessary
363void SV_CheckTimeouts( void ) {
364 client_t *cl = svs.clients;
365
366 int droppoint = sv.time - 1000 * sv_timeout->integer;
367 int zombiepoint = sv.time - 1000 * sv_zombietime->integer;
368
369 // message times may be wrong across a changelevel
370 if ( cl->lastPacketTime > sv.time )
371 cl->lastPacketTime = sv.time;
372
373 if ( cl->state == CS_ZOMBIE && cl->lastPacketTime < zombiepoint ) {
374 cl->state = CS_FREE; // can now be reused
375 return;
376 }
377
378 if ( cl->state >= CS_CONNECTED && cl->lastPacketTime < droppoint ) {
379 // wait several frames so a debugger session doesn't cause a timeout
380 if ( ++cl->timeoutCount > 5 ) {
381 SV_DropClient( cl, "timed out" );
382 cl->state = CS_FREE; // don't bother with zombie state
383 }
384 }
385 else
386 cl->timeoutCount = 0;
387}
388
389/*
390==================

Callers 1

SV_FrameFunction · 0.70

Calls 1

SV_DropClientFunction · 0.70

Tested by

no test coverage detected