Only wait for 5 tries (15 seconds) for the bandwidth reply

This commit is contained in:
simon.kagstrom 2009-11-10 05:43:43 +00:00
parent de583835c3
commit 5275eda76b

View File

@ -1147,8 +1147,10 @@ bool Network::ConnectToPeer()
network_connection_error_t Network::WaitForBandWidthReply()
{
unsigned cnt;
/* Wait until we've got an ack */
while (1) {
for (cnt = 0; cnt < 5; cnt++) {
struct timeval tv;
tv.tv_sec = 3;
@ -1174,7 +1176,14 @@ network_connection_error_t Network::WaitForBandWidthReply()
break;
else /* Everything else is an error */
return SERVER_GARBAGE_ERROR;
cnt++;
}
if (cnt == 5) {
printf("Timeout. Setting default kbps (160)\n");
this->target_kbps = 160000;
return OK;
}
/* We got a bandwidth ACK */
uint32 now = SDL_GetTicks();