From 5275eda76b5a44dbeaeeaa77a04bfe23f5730df1 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Tue, 10 Nov 2009 05:43:43 +0000 Subject: [PATCH] Only wait for 5 tries (15 seconds) for the bandwidth reply --- Src/Network.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Src/Network.cpp b/Src/Network.cpp index 7d226ce..d2fcf52 100644 --- a/Src/Network.cpp +++ b/Src/Network.cpp @@ -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();