diff options
author | eihrul <eihrul> | 2005-05-24 06:08:30 +0000 |
---|---|---|
committer | eihrul <eihrul> | 2005-05-24 06:08:30 +0000 |
commit | 59d5c26e3811e0ebfa4878e29886d8f4aadbdd6f (patch) | |
tree | 2a9afaa8f7a13b368a5c9be587f8443dfcc01efc | |
parent | 2ef761a8d25b5e79005fd25054090ccb2777317e (diff) | |
download | enet-59d5c26e3811e0ebfa4878e29886d8f4aadbdd6f.tar.gz enet-59d5c26e3811e0ebfa4878e29886d8f4aadbdd6f.zip |
minimum and maximum timeout
-rw-r--r-- | include/enet/enet.h | 5 | ||||
-rw-r--r-- | peer.c | 1 | ||||
-rw-r--r-- | protocol.c | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/include/enet/enet.h b/include/enet/enet.h index b497409..b855018 100644 --- a/include/enet/enet.h +++ b/include/enet/enet.h @@ -167,8 +167,10 @@ enum ENET_PEER_PACKET_LOSS_INTERVAL = 10000, ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024, ENET_PEER_TIMEOUT_LIMIT = 32, + ENET_PEER_TIMEOUT_MINIMUM = 3000, + ENET_PEER_TIMEOUT_MAXIMUM = 30000, ENET_PEER_PING_INTERVAL = 500, - ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 4 * 32 + ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 4 * 32, }; typedef struct _ENetChannel @@ -206,6 +208,7 @@ typedef struct _ENetPeer enet_uint32 lastSendTime; enet_uint32 lastReceiveTime; enet_uint32 nextTimeout; + enet_uint32 earliestTimeout; enet_uint32 packetLossEpoch; enet_uint32 packetsSent; enet_uint32 packetsLost; @@ -351,6 +351,7 @@ enet_peer_reset (ENetPeer * peer) peer -> lastSendTime = 0; peer -> lastReceiveTime = 0; peer -> nextTimeout = 0; + peer -> earliestTimeout = 0; peer -> packetLossEpoch = 0; peer -> packetsSent = 0; peer -> packetsLost = 0; @@ -486,6 +486,7 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * return 0; peer -> lastReceiveTime = timeCurrent; + peer -> earliestTimeout = 0; roundTripTime = ENET_TIME_DIFFERENCE (timeCurrent, receivedSentTime); @@ -948,7 +949,14 @@ enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * even if (ENET_TIME_DIFFERENCE (timeCurrent, outgoingCommand -> sentTime) < outgoingCommand -> roundTripTimeout) continue; - if (outgoingCommand -> roundTripTimeout >= outgoingCommand -> roundTripTimeoutLimit) + if(peer -> earliestTimeout == 0 || + ENET_TIME_LESS(outgoingCommand -> sentTime, peer -> earliestTimeout)) + peer -> earliestTimeout = outgoingCommand -> sentTime; + + if (peer -> earliestTimeout != 0 && + (ENET_TIME_DIFFERENCE(timeCurrent, peer -> earliestTimeout) >= ENET_PEER_TIMEOUT_MAXIMUM || + (outgoingCommand -> roundTripTimeout >= outgoingCommand -> roundTripTimeoutLimit && + ENET_TIME_DIFFERENCE(timeCurrent, peer -> earliestTimeout) >= ENET_PEER_TIMEOUT_MINIMUM))) { event -> type = ENET_EVENT_TYPE_DISCONNECT; event -> peer = peer; |