Skip to content
Snippets Groups Projects
Commit a8a92a57 authored by Logan Aerl Arias's avatar Logan Aerl Arias
Browse files

Merge branch '1200-next-cannot-load-game-when-using-srb2-launcher' into 'next'

Do not alllow error codepaths of UPnP to leave the mutex locked

Closes #1200

See merge request STJr/SRB2!2349
parents 393b46a9 15b1842a
No related branches found
No related tags found
No related merge requests found
...@@ -265,7 +265,7 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len ...@@ -265,7 +265,7 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
#ifdef HAVE_MINIUPNPC // based on old XChat patch #ifdef HAVE_MINIUPNPC // based on old XChat patch
static void I_ShutdownUPnP(void); static void I_ShutdownUPnP(void);
static void I_InitUPnP(void); static void I_InitUPnP(void);
I_mutex upnp_mutex; static I_mutex upnp_mutex;
static struct UPNPUrls urls; static struct UPNPUrls urls;
static struct IGDdatas data; static struct IGDdatas data;
static char lanaddr[64]; static char lanaddr[64];
...@@ -335,22 +335,22 @@ init_upnpc_once(struct upnpdata *upnpuserdata) ...@@ -335,22 +335,22 @@ init_upnpc_once(struct upnpdata *upnpuserdata)
I_AddExitFunc(I_ShutdownUPnP); I_AddExitFunc(I_ShutdownUPnP);
} }
freeUPNPDevlist(devlist); freeUPNPDevlist(devlist);
I_unlock_mutex(upnp_mutex);
} }
else if (upnp_error == UPNPDISCOVER_SOCKET_ERROR) else if (upnp_error == UPNPDISCOVER_SOCKET_ERROR)
{ {
I_OutputMsg(M_GetText("No UPnP devices discovered\n")); I_OutputMsg(M_GetText("No UPnP devices discovered\n"));
} }
I_unlock_mutex(upnp_mutex);
upnpuserdata->upnpc_started =1; upnpuserdata->upnpc_started =1;
} }
static inline void I_UPnP_add(const char * addr, const char *port, const char * servicetype) static inline void I_UPnP_add(const char * addr, const char *port, const char * servicetype)
{ {
if (!urls.controlURL || urls.controlURL[0] == '\0')
return;
I_lock_mutex(&upnp_mutex); I_lock_mutex(&upnp_mutex);
if (addr == NULL) if (addr == NULL)
addr = lanaddr; addr = lanaddr;
if (!urls.controlURL || urls.controlURL[0] == '\0')
return;
UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
port, port, addr, "SRB2", servicetype, NULL, NULL); port, port, addr, "SRB2", servicetype, NULL, NULL);
I_unlock_mutex(upnp_mutex); I_unlock_mutex(upnp_mutex);
...@@ -358,9 +358,9 @@ static inline void I_UPnP_add(const char * addr, const char *port, const char * ...@@ -358,9 +358,9 @@ static inline void I_UPnP_add(const char * addr, const char *port, const char *
static inline void I_UPnP_rem(const char *port, const char * servicetype) static inline void I_UPnP_rem(const char *port, const char * servicetype)
{ {
I_lock_mutex(&upnp_mutex);
if (!urls.controlURL || urls.controlURL[0] == '\0') if (!urls.controlURL || urls.controlURL[0] == '\0')
return; return;
I_lock_mutex(&upnp_mutex);
UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype,
port, servicetype, NULL); port, servicetype, NULL);
I_unlock_mutex(upnp_mutex); I_unlock_mutex(upnp_mutex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment