[ENet-discuss] ENet bug: in enet_protocol_handle_send_fragment(...)
=?ks_c_5601-1987?B?v/jFwsiv?=
weon at digitalwave.co.kr
Wed Aug 13 09:40:45 PDT 2003
Hi,
I found an error in protocol.c' enet_protocol_handle_send_fragment()
original codes are:
for (currentCommand = enet_list_previous(enet_list_end(&channel->incomingReliableCommands));
currentCommand !=enet_list_end(&channel->incomingReliableCommands);
currentCommand = enet_list_previous(currentCommand)) {
startCommand = (ENetIncomingCommand *) currentCommand;
if (startCommand->reliableSequenceNumber == startSequenceNumber) {
break;
}
The lines could not handle if the first fragment of a fragmented message is lost.
For example, consider that an user message is fragmented into more than two fragments and
the receiver lost the first fragment at first time and received the second fragment and then the first fragment which
is retransmitted by the sender.
In this case the second fragment and the first one are considered as a separate message.
User can get no more message if this situation occurs.
So, I changed the code lines as follows:
for (currentCommand = enet_list_previous(enet_list_end(&channel->incomingReliableCommands));
currentCommand !=enet_list_end(&channel->incomingReliableCommands);
currentCommand = enet_list_previous(currentCommand)) {
startCommand = (ENetIncomingCommand *) currentCommand;
if (startCommand->reliableSequenceNumber == startSequenceNumber) {
break;
/* NEWLY ADDED LINES! to handle reversly received fragments */
if (startCommand->reliableSequenceNumber > startSequenceNumber ) {
ENetProtocol *anchor = (ENetProtocol *)&startCommand->command;
/* check if the startCommand belongs to the same message */
if (anchor->sendFragment.startSequenceNumber == startSequenceNumber)
break;
}
}
The code worked fine to me.
Hope useful.
PS) Sorry. I could not add diff output because I added so many debug lines in enet. ;-)
---------------
Won
More information about the ENet-discuss
mailing list