aboutsummaryrefslogtreecommitdiffhomepage
path: root/peer.c
diff options
context:
space:
mode:
authorLee Salzman <[email protected]>2014-04-14 19:11:44 +0300
committerLee Salzman <[email protected]>2014-04-14 19:11:44 +0300
commitea8d41f65c559bf2b74c59538e340ea0023d60fe (patch)
treeaa1e720531ef71e2bdc550152411b465113f9b2c /peer.c
parent73c930881f7acabc9bea99eb698d0824cbe22c3e (diff)
downloadenet-ea8d41f65c559bf2b74c59538e340ea0023d60fe.tar.gz
enet-ea8d41f65c559bf2b74c59538e340ea0023d60fe.zip
added maximumPacketSize and maximumWaitingData fields for limiting peer buffer space
Diffstat (limited to 'peer.c')
-rw-r--r--peer.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/peer.c b/peer.c
index 2084b9b..7c6b197 100644
--- a/peer.c
+++ b/peer.c
@@ -105,7 +105,7 @@ enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet)
if (peer -> state != ENET_PEER_STATE_CONNECTED ||
channelID >= peer -> channelCount ||
- packet -> dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE)
+ packet -> dataLength > peer -> host -> maximumPacketSize)
return -1;
fragmentLength = peer -> mtu - sizeof (ENetProtocolHeader) - sizeof (ENetProtocolSendFragment);
@@ -241,6 +241,8 @@ enet_peer_receive (ENetPeer * peer, enet_uint8 * channelID)
enet_free (incomingCommand);
+ peer -> totalWaitingData -= packet -> dataLength;
+
return packet;
}
@@ -415,6 +417,7 @@ enet_peer_reset (ENetPeer * peer)
peer -> incomingUnsequencedGroup = 0;
peer -> outgoingUnsequencedGroup = 0;
peer -> eventData = 0;
+ peer -> totalWaitingData = 0;
memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow));
@@ -952,7 +955,11 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
}
if (packet != NULL)
- ++ packet -> referenceCount;
+ {
+ ++ packet -> referenceCount;
+
+ peer -> totalWaitingData += packet -> dataLength;
+ }
enet_list_insert (enet_list_next (currentCommand), incomingCommand);