We're still seeing some crashes (a lot less than before) on iOS devices. When we disconnect from SmartFox, occasionally we'll get some crashes because SmartFox still attempts to read or write something back to the closed socket.
To try to alleviate this, we've used the same mechanism used elsewhere to allow the SmartFox socket to finish any "callbacksInProgress" before fully closing it down. We also added a call to shutdown the TCP socket as it seems that should be done first prior to closing it to avoid other data from coming in.
Can you take a look at the code snippet of changes we made below and let us know your thoughts on their feasibility?
Code: Select all
void TCPClient::Shutdown()
{
// Cancel all asynchronous operations associated with the socket
boostTcpSocket.shutdown(boost::asio::socket_base::shutdown_both);
boostTcpSocket.close();
//boostIoService.stop();
}
void TCPSocketLayer::Disconnect()
{
if (State() != States_Connected)
{
boost::shared_ptr<string> message (new string("Calling disconnect when the socket is not connected"));
LogWarn(message);
return;
}
isDisconnecting = true;
while (this->connection->CallbackCallInProgress() == true)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
}
try
{
connection->Shutdown();
}
catch (...)
{
}
HandleDisconnection();
isDisconnecting = false;
}
void TCPSocketLayer::Kill()
{
isDisconnecting = true;
while (this->connection->CallbackCallInProgress() == true)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
}
try
{
connection->Shutdown();
}
catch (...)
{
}
HandleDisconnection();
isDisconnecting = false;
}