fixed horrible UPNP bugs related to timing, where ports would be either NOT properly opened or not closed due to thread timing and no thread protection.

This commit is contained in:
Mark Vejvoda
2011-10-23 00:55:34 +00:00
parent 6863876359
commit 2cecb2c3a0
6 changed files with 75 additions and 24 deletions

View File

@@ -223,7 +223,6 @@ protected:
static int externalPort;
static int ftpServerPort;
SDL_Thread *upnpdiscoverThread;
static int maxPlayerCount;
@@ -262,6 +261,9 @@ public:
void NETdiscoverUPnPDevices();
static void setMaxPlayerCount(int value) { maxPlayerCount=value; }
static Mutex mutexUpnpdiscoverThread;
static SDL_Thread *upnpdiscoverThread;
};
// =====================================================
@@ -276,10 +278,10 @@ public:
static int upnp_init(void *param);
static bool upnp_add_redirect(int ports[2]);
static bool upnp_add_redirect(int ports[2],bool mutexLock=true);
static void upnp_rem_redirect(int ext_port);
static void NETaddRedirects(std::vector<int> UPNPPortForwardList);
static void NETaddRedirects(std::vector<int> UPNPPortForwardList, bool mutexLock=true);
static void NETremRedirects(int ext_port);
static void AddUPNPPortForward(int internalPort, int externalPort);