From 4df4c0dec0026a863395e9d2e705853d650fc1dd Mon Sep 17 00:00:00 2001 From: JoshuaJB Date: Tue, 17 Dec 2013 14:57:26 +0000 Subject: [PATCH] Try to actually do the threading my previous commit said it did. This was SVN commit r14371. --- source/network/NetServer.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index b294820b4e..1cb8740539 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -214,13 +214,13 @@ bool CNetServerWorker::SetupUPnP() std::string rootDescURL = ""; CFG_GET_VAL("network.upnprootdescurl", String, rootDescURL); if (rootDescURL != "") - LOGMESSAGE(L"Net server: attempting to use cached root decripter URL: %hs", rootDescURL.c_str()); + LOGMESSAGE(L"Net server: attempting to use cached root descripter URL: %hs", rootDescURL.c_str()); // Init the return variable for UPNP_GetValidIGD to 1 so things behave when using cached URLs. int ret = 1; - // If we have a cached URL, try that first, otherwise try getting a valid UPnP device for 7 seconds. We also get our LAN address here. + // If we have a cached URL, try that first, otherwise try getting a valid UPnP device for 10 seconds. We also get our LAN address here. if (!((rootDescURL != "" && UPNP_GetIGDFromUrl(rootDescURL.c_str(), &urls, &data, internalIPAddress, sizeof(internalIPAddress))) - || ((devlist = upnpDiscover(7000, 0, 0, 0, 0, 0)) && (ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress)))))) + || ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) && (ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress)))))) { LOGMESSAGE(L"Net server: upnpDiscover failed and no working cached URL."); return false; @@ -326,10 +326,12 @@ void* CNetServerWorker::RunThread(void* data) void CNetServerWorker::Run() { + // Try to open the firewall (this could take a few seconds). + SetupUPnP(); + // To avoid the need for JS_SetContextThread, we create and use and destroy // the script interface entirely within this network thread m_ScriptInterface = new ScriptInterface("Engine", "Net server", ScriptInterface::CreateRuntime()); - while (true) { if (!RunStep()) @@ -1026,14 +1028,7 @@ CNetServer::~CNetServer() bool CNetServer::SetupConnection() { - if(m_Worker->SetupConnection()) - { - // Try to open the firewall. - m_Worker->SetupUPnP(); - return true; - } - else - return false; + return m_Worker->SetupConnection(); } void CNetServer::AssignPlayer(int playerID, const CStr& guid)