Ticket #2338: fix-trac-2338-style1.patch
File fix-trac-2338-style1.patch, 2.1 KB (added by , 10 years ago) |
---|
-
source/network/NetServer.cpp
225 225 if (!rootDescURL.empty()) 226 226 LOGMESSAGE(L"Net server: attempting to use cached root descriptor URL: %hs", rootDescURL.c_str()); 227 227 228 // Init the return variable for UPNP_GetValidIGD to 1 so things behave when using cached URLs. 229 int ret = 1; 228 // Init the return variable for UPNP_GetValidIGD to 0. 229 int ret = 0; 230 bool bAllocatedDescriptorURL = false; 230 231 231 232 // 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. 232 if (!((!rootDescURL.empty() && UPNP_GetIGDFromUrl(rootDescURL.c_str(), &urls, &data, internalIPAddress, sizeof(internalIPAddress))) 233 || ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != NULL && (ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress))) != 0))) 233 if (!rootDescURL.empty() && UPNP_GetIGDFromUrl(rootDescURL.c_str(), &urls, &data, internalIPAddress, sizeof(internalIPAddress))) 234 234 { 235 LOGMESSAGE(L"Net server: using cached IGD = %hs", urls.controlURL); 236 // Init the return variable for UPNP_GetValidIGD to 1 so things behave when using cached URLs. 237 ret = 1; 238 } 239 else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != NULL && 240 (ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress))) != 0) 241 { 242 (ret != 0) ? bAllocatedDescriptorURL = true: bAllocatedDescriptorURL = false; 243 } 244 else { 235 245 LOGMESSAGE(L"Net server: upnpDiscover failed and no working cached URL."); 236 246 return NULL; 237 247 } 238 248 239 249 switch (ret) 240 250 { 251 case 0: 252 LOGMESSAGE(L"Net server: No IGD found"); 253 break; 241 254 case 1: 242 255 LOGMESSAGE(L"Net server: found valid IGD = %hs", urls.controlURL); 243 256 break; … … 295 308 LOGMESSAGE(L"Net server: cached UPnP root descriptor URL as %hs", urls.controlURL); 296 309 297 310 // Make sure everything is properly freed. 298 FreeUPNPUrls(&urls); 311 if (bAllocatedDescriptorURL) 312 FreeUPNPUrls(&urls); 313 299 314 freeUPNPDevlist(devlist); 300 315 301 316 return NULL;