mirror of
https://github.com/glest/glest-source.git
synced 2025-08-31 19:51:44 +02:00
- fixed a possible infinite loop while receiving network packets on clients for network games (found by titi's stack trace dump)
This commit is contained in:
@@ -532,9 +532,11 @@ void ClientInterface::updateKeyframe(int frameCount)
|
|||||||
|
|
||||||
int waitCount = 0;
|
int waitCount = 0;
|
||||||
//make sure we read the message
|
//make sure we read the message
|
||||||
|
time_t receiveTimeElapsed = time(NULL);
|
||||||
NetworkMessageCommandList networkMessageCommandList;
|
NetworkMessageCommandList networkMessageCommandList;
|
||||||
while(receiveMessage(&networkMessageCommandList) == false &&
|
while(receiveMessage(&networkMessageCommandList) == false &&
|
||||||
isConnected() == true) {
|
isConnected() == true &&
|
||||||
|
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 1000)) {
|
||||||
//sleep(waitSleepTime);
|
//sleep(waitSleepTime);
|
||||||
sleep(0);
|
sleep(0);
|
||||||
waitCount++;
|
waitCount++;
|
||||||
@@ -582,10 +584,12 @@ void ClientInterface::updateKeyframe(int frameCount)
|
|||||||
|
|
||||||
case nmtQuit:
|
case nmtQuit:
|
||||||
{
|
{
|
||||||
|
time_t receiveTimeElapsed = time(NULL);
|
||||||
NetworkMessageQuit networkMessageQuit;
|
NetworkMessageQuit networkMessageQuit;
|
||||||
//if(receiveMessage(&networkMessageQuit)) {
|
//if(receiveMessage(&networkMessageQuit)) {
|
||||||
while(receiveMessage(&networkMessageQuit) == false &&
|
while(receiveMessage(&networkMessageQuit) == false &&
|
||||||
isConnected() == true) {
|
isConnected() == true &&
|
||||||
|
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 1000)) {
|
||||||
sleep(0);
|
sleep(0);
|
||||||
}
|
}
|
||||||
quit= true;
|
quit= true;
|
||||||
@@ -595,15 +599,14 @@ void ClientInterface::updateKeyframe(int frameCount)
|
|||||||
|
|
||||||
case nmtText:
|
case nmtText:
|
||||||
{
|
{
|
||||||
|
time_t receiveTimeElapsed = time(NULL);
|
||||||
NetworkMessageText networkMessageText;
|
NetworkMessageText networkMessageText;
|
||||||
while(receiveMessage(&networkMessageText) == false &&
|
while(receiveMessage(&networkMessageText) == false &&
|
||||||
isConnected() == true) {
|
isConnected() == true &&
|
||||||
|
difftime(time(NULL),receiveTimeElapsed) <= (messageWaitTimeout / 1000)) {
|
||||||
sleep(0);
|
sleep(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//chatText = networkMessageText.getText();
|
|
||||||
//chatSender = networkMessageText.getSender();
|
|
||||||
//chatTeamIndex = networkMessageText.getTeamIndex();
|
|
||||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex());
|
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex());
|
||||||
this->addChatInfo(msg);
|
this->addChatInfo(msg);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user