Avoid exit hang in wan server for GUI server

This commit is contained in:
Benau 2020-02-28 22:49:21 +08:00
parent ee22c0f714
commit e31bd30f1f
2 changed files with 2 additions and 8 deletions

View File

@ -263,7 +263,8 @@ ServerLobby::~ServerLobby()
if (NetworkConfig::get()->isNetworking() && if (NetworkConfig::get()->isNetworking() &&
NetworkConfig::get()->isWAN()) NetworkConfig::get()->isWAN())
{ {
unregisterServer(true/*now*/); // For child process the request manager will keep on running
unregisterServer(m_process_type == PT_MAIN ? true : false/*now*/);
} }
delete m_result_ns; delete m_result_ns;
delete m_items_complete_state; delete m_items_complete_state;
@ -2190,9 +2191,6 @@ void ServerLobby::update(int ticks)
*/ */
bool ServerLobby::registerServer(bool now) bool ServerLobby::registerServer(bool now)
{ {
while (now && !m_server_unregistered.expired())
StkTime::sleep(1);
// ======================================================================== // ========================================================================
class RegisterServerRequest : public Online::XMLRequest class RegisterServerRequest : public Online::XMLRequest
{ {
@ -2299,7 +2297,6 @@ void ServerLobby::unregisterServer(bool now)
{ {
int priority = Online::RequestManager::HTTP_MAX_PRIORITY; int priority = Online::RequestManager::HTTP_MAX_PRIORITY;
auto request = std::make_shared<Online::XMLRequest>(priority); auto request = std::make_shared<Online::XMLRequest>(priority);
m_server_unregistered = request;
NetworkConfig::get()->setServerDetails(request, "stop"); NetworkConfig::get()->setServerDetails(request, "stop");
const SocketAddress& addr = STKHost::get()->getPublicAddress(); const SocketAddress& addr = STKHost::get()->getPublicAddress();

View File

@ -167,9 +167,6 @@ private:
std::map<std::weak_ptr<STKPeer>, bool, std::map<std::weak_ptr<STKPeer>, bool,
std::owner_less<std::weak_ptr<STKPeer> > > m_peers_ready; std::owner_less<std::weak_ptr<STKPeer> > > m_peers_ready;
/** It indicates if this server is unregistered with the stk server. */
std::weak_ptr<Online::Request> m_server_unregistered;
std::weak_ptr<Online::Request> m_server_recovering; std::weak_ptr<Online::Request> m_server_recovering;
/** Timeout counter for various state. */ /** Timeout counter for various state. */