Skip to content
Permalink
Browse files
Merge pull request #9709 from AdmiralCurtiss/upnp-error-log
UPnP: Improve error messages on initialization failure.
  • Loading branch information
leoetlino committed Jul 6, 2021
2 parents 02309bd + c3560f0 commit 954f27c
Showing 1 changed file with 15 additions and 1 deletion.
@@ -15,6 +15,7 @@
#include <string>
#include <thread>
#include <upnpcommands.h>
#include <upnperrors.h>
#include <vector>

static UPNPUrls s_urls;
@@ -51,14 +52,23 @@ static bool InitUPnP()
#endif
if (!devlist)
{
WARN_LOG_FMT(NETPLAY, "An error occurred trying to discover UPnP devices.");
if (upnperror == UPNPDISCOVER_SUCCESS)
{
WARN_LOG_FMT(NETPLAY, "No UPnP devices could be found.");
}
else
{
WARN_LOG_FMT(NETPLAY, "An error occurred trying to discover UPnP devices: {}",
strupnperror(upnperror));
}

s_error = true;

return false;
}

// Look for the IGD
bool found_valid_igd = false;
for (UPNPDev* dev = devlist.get(); dev; dev = dev->pNext)
{
if (!std::strstr(dev->st, "InternetGatewayDevice"))
@@ -80,6 +90,7 @@ static bool InitUPnP()
parserootdesc(desc_xml.get(), desc_xml_size, &s_data);
GetUPNPUrls(&s_urls, &s_data, dev->descURL, 0);

found_valid_igd = true;
NOTICE_LOG_FMT(NETPLAY, "Got info from IGD at {}.", dev->descURL);
break;
}
@@ -89,6 +100,9 @@ static bool InitUPnP()
}
}

if (!found_valid_igd)
WARN_LOG_FMT(NETPLAY, "Could not find a valid IGD in the discovered UPnP devices.");

s_inited = true;

return true;

0 comments on commit 954f27c

Please sign in to comment.