Avoid infinite loop waiting for DNS resolution.

This commit is contained in:
Daniel Buckmaster 2014-08-08 14:31:42 +10:00
parent 77381ac494
commit e6d47c58f7

View file

@ -48,13 +48,15 @@ TEST(Net, TCPRequest)
Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer)); Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer));
EXPECT_EQ(e, Net::NoError) ASSERT_EQ(Net::NoError, e)
<< "Got an error sending our HTTP request!"; << "Got an error sending our HTTP request!";
} }
else if(state == Net::Disconnected) else
{ {
Process::requestShutdown(); Process::requestShutdown();
mSocket = NULL; mSocket = NULL;
ASSERT_EQ(Net::Disconnected, state)
<< "Ended with a network error!";
} }
} }
@ -64,10 +66,6 @@ TEST(Net, TCPRequest)
if(mSocket != sock) if(mSocket != sock)
return; return;
char buff[4096];
dMemcpy(buff, incomingData.data, incomingData.size);
buff[incomingData.size] = 0;
mDataReceived += incomingData.size; mDataReceived += incomingData.size;
} }
} handler; } handler;
@ -115,13 +113,15 @@ TEST(Net, JournalTCPRequest)
Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer)); Net::Error e = Net::sendtoSocket(mSocket, reqBuffer, sizeof(reqBuffer));
EXPECT_EQ(e, Net::NoError) ASSERT_EQ(Net::NoError, e)
<< "Got an error sending our HTTP request!"; << "Got an error sending our HTTP request!";
} }
else if(state == Net::Disconnected) else
{ {
Process::requestShutdown(); Process::requestShutdown();
mSocket = NULL; mSocket = NULL;
ASSERT_EQ(Net::Disconnected, state)
<< "Ended with a network error!";
} }
} }
@ -130,11 +130,6 @@ TEST(Net, JournalTCPRequest)
// Only consider our own socket. // Only consider our own socket.
if(mSocket != sock) if(mSocket != sock)
return; return;
char buff[4096];
dMemcpy(buff, incomingData.data, incomingData.size);
buff[incomingData.size] = 0;
mDataReceived += incomingData.size; mDataReceived += incomingData.size;
} }
@ -143,9 +138,6 @@ TEST(Net, JournalTCPRequest)
mSocket = InvalidSocket; mSocket = InvalidSocket;
mDataReceived = 0; mDataReceived = 0;
// Initialize networking - done by initLibraries currently
//test(Net::init(), "Failed to initialize networking!");
// Hook into the signals. // Hook into the signals.
Net::smConnectionNotify. notify(this, &handle::notify); Net::smConnectionNotify. notify(this, &handle::notify);
Net::smConnectionReceive.notify(this, &handle::receive); Net::smConnectionReceive.notify(this, &handle::receive);