From 9b06a12e716b79ed09557d2d4ae6173b2ea6c3a3 Mon Sep 17 00:00:00 2001 From: "lsalzman@gmail.com" Date: Mon, 9 Mar 2015 11:54:01 -0700 Subject: [PATCH] handle case in bandwidth limit protocol where either incoming or outgoing limits are disabled, but not both --- protocol.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocol.c b/protocol.c index 3a7dd36..68ddfe8 100644 --- a/protocol.c +++ b/protocol.c @@ -764,6 +764,10 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0) peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE; + else + if (peer -> incomingBandwidth == 0 || host -> outgoingBandwidth == 0) + peer -> windowSize = (ENET_MAX (peer -> incomingBandwidth, host -> outgoingBandwidth) / + ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE; else peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) / ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;