diff options
author | Lee Salzman <[email protected]> | 2014-04-14 21:21:21 +0300 |
---|---|---|
committer | Lee Salzman <[email protected]> | 2014-04-14 21:21:21 +0300 |
commit | 518144338dd2d55192446e5ef37bc2eb97fe9bc8 (patch) | |
tree | 28a1f3bbda28d01b9f2e18013fe2cae2116cbafc /peer.c | |
parent | 734a630bed798bc407282b54f1fb785449b55c9d (diff) | |
download | enet-518144338dd2d55192446e5ef37bc2eb97fe9bc8.tar.gz enet-518144338dd2d55192446e5ef37bc2eb97fe9bc8.zip |
fix maximumWaitingData handling to allow acknowledgements when the packet already exists
Diffstat (limited to 'peer.c')
-rw-r--r-- | peer.c | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -821,7 +821,7 @@ enet_peer_dispatch_incoming_reliable_commands (ENetPeer * peer, ENetChannel * ch } ENetIncomingCommand * -enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 fragmentCount) +enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, const void * data, size_t dataLength, enet_uint32 flags, enet_uint32 fragmentCount) { static ENetIncomingCommand dummyCommand; @@ -830,9 +830,10 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, enet_uint16 reliableWindow, currentWindow; ENetIncomingCommand * incomingCommand; ENetListIterator currentCommand; + ENetPacket * packet = NULL; if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER) - goto freePacket; + goto discardCommand; if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED) { @@ -844,7 +845,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, reliableWindow += ENET_PEER_RELIABLE_WINDOWS; if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1) - goto freePacket; + goto discardCommand; } switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK) @@ -852,7 +853,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT: case ENET_PROTOCOL_COMMAND_SEND_RELIABLE: if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber) - goto freePacket; + goto discardCommand; for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands)); currentCommand != enet_list_end (& channel -> incomingReliableCommands); @@ -874,7 +875,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber) break; - goto freePacket; + goto discardCommand; } } break; @@ -885,7 +886,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber && unreliableSequenceNumber <= channel -> incomingUnreliableSequenceNumber) - goto freePacket; + goto discardCommand; for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands)); currentCommand != enet_list_end (& channel -> incomingUnreliableCommands); @@ -916,7 +917,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, if (incomingCommand -> unreliableSequenceNumber < unreliableSequenceNumber) break; - goto freePacket; + goto discardCommand; } } break; @@ -926,9 +927,16 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, break; default: - goto freePacket; + goto discardCommand; } + if (peer -> totalWaitingData >= peer -> host -> maximumWaitingData) + goto notifyError; + + packet = enet_packet_create (data, dataLength, flags); + if (packet == NULL) + goto notifyError; + incomingCommand = (ENetIncomingCommand *) enet_malloc (sizeof (ENetIncomingCommand)); if (incomingCommand == NULL) goto notifyError; @@ -977,7 +985,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, return incomingCommand; -freePacket: +discardCommand: if (fragmentCount > 0) goto notifyError; |