Fixed too early release of objects, and some state changes in finite state machine.
This commit is contained in:
@@ -83,6 +83,7 @@ void ConnectToPeer::asynchronousUpdate()
|
||||
// The GetPeerAddress protocol will change the state and
|
||||
// unpause this protocol
|
||||
ProtocolManager::getInstance()->pauseProtocol(this);
|
||||
m_state = RECEIVED_PEER_ADDRESS;
|
||||
break;
|
||||
}
|
||||
case RECEIVED_PEER_ADDRESS:
|
||||
@@ -99,7 +100,8 @@ void ConnectToPeer::asynchronousUpdate()
|
||||
// the Ping protocol to keep the port available.
|
||||
if (m_peer_address.getIP() != STKHost::get()->getPublicAddress().getIP())
|
||||
{
|
||||
m_current_protocol = new PingProtocol(m_peer_address, 2.0);
|
||||
m_current_protocol = new PingProtocol(m_peer_address,
|
||||
/*time-between-ping*/2.0);
|
||||
ProtocolManager::getInstance()->requestStart(m_current_protocol);
|
||||
m_state = CONNECTING;
|
||||
break;
|
||||
|
||||
@@ -146,6 +146,7 @@ void ConnectToServer::asynchronousUpdate()
|
||||
delete m_current_protocol;
|
||||
m_current_protocol = NULL;
|
||||
Log::info("ConnectToServer", "Server's address known");
|
||||
|
||||
// we're in the same lan (same public ip address) !!
|
||||
if (m_server_address.getIP() ==
|
||||
STKHost::get()->getPublicAddress().getIP())
|
||||
@@ -284,7 +285,6 @@ void ConnectToServer::registerWithSTKServer()
|
||||
request->executeNow();
|
||||
|
||||
const XMLNode * result = request->getXMLData();
|
||||
delete request;
|
||||
|
||||
std::string success;
|
||||
if(result->get("success", &success) && success == "yes")
|
||||
@@ -295,6 +295,7 @@ void ConnectToServer::registerWithSTKServer()
|
||||
{
|
||||
Log::error("ConnectToServer", "Failed to register address.");
|
||||
}
|
||||
delete request;
|
||||
|
||||
} // registerWithSTKServer
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include "online/request_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
GetPeerAddress::GetPeerAddress(uint32_t peer_id, CallbackObject* callback_object)
|
||||
GetPeerAddress::GetPeerAddress(uint32_t peer_id,
|
||||
CallbackObject* callback_object)
|
||||
: Protocol(PROTOCOL_SILENT, callback_object)
|
||||
{
|
||||
m_peer_id = peer_id;
|
||||
@@ -55,8 +56,6 @@ void GetPeerAddress::asynchronousUpdate()
|
||||
if (m_request->isDone())
|
||||
{
|
||||
const XMLNode * result = m_request->getXMLData();
|
||||
delete m_request;
|
||||
m_request = NULL;
|
||||
|
||||
std::string success;
|
||||
if(result->get("success", &success) && success == "yes")
|
||||
@@ -79,6 +78,9 @@ void GetPeerAddress::asynchronousUpdate()
|
||||
Log::error("GetPeerAddress", "Failed to get peer address.");
|
||||
}
|
||||
requestTerminate();
|
||||
|
||||
delete m_request;
|
||||
m_request = NULL;
|
||||
}
|
||||
} // asynchronousUpdate
|
||||
|
||||
|
||||
Reference in New Issue
Block a user