Thanks for the tip Hooman.
I used the debugger to step through the detach process for op2ext and found the problem. When op2ext calls the DestroyMod function on NetHelper, it just hangs for a long time. Sometimes it is only maybe 3-5 seconds. Other times it just seems to hang a really long time. After the interval, op2ext finishes closing out and everything is fine.
If I do not add the NetHelper module to Outpost 2, then everything exits correctly.
Looking through NetHelper's code, DestroyMod contains the following line:
WaitForSingleObject(hFwdThread, INFINITE);
I don't know for sure, but I'm wondering if this is what is causing NetHelper to not close out on my computer for a variable long length of time. I'm not really sure what this line does or why it is passed INFINITE for the wait time. Below is the entire DestroyMod function for context, but checking it out in the repo is easy enough.
It is probably incorrect that NetHelper can force Outpost 2 to not close out for such a long time. However, when closing out of version 1.3.6 on my computer, Outpost 2 seems to close just fine. It will transfer from the active applications to a background application for maybe 1-2 seconds at most and then disappear, which seems reasonable behavior. So, I don't know what is different between 1.3.6 and the new version that is causing the hang. Perhaps there is still some underlying problem that I added to op2ext.
extern "C" __declspec(dllexport) bool DestroyMod() {
bool result = true;
if (!SetBindPatches(false)) {
result = false;
}
if (mode != noForward) {
if (!SetGetIPPatch(false)) {
result = false;
}
if (hFwdThread) {
shuttingDown = true;
WaitForSingleObject(hFwdThread, INFINITE);
}
PortForwarder forwarder(mode == pmpOrUpnp || mode == upnpOnly,
mode == pmpOrUpnp || mode == pmpOnly);
for (int i = startPort; i <= endPort; ++i) {
forwarder.Unforward(true, i);
}
}
return result;
}
I tried compiling NetHelper so I could step debug through it and verify that line is called and is the culprit, but I cannot get it to compile. I'm getting a lot of LINKER errors associated with miniupnpcd.lib.
Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol __imp__fprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(upnpreplyparse.obj) 1
Error LNK2001 unresolved external symbol __imp__fprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(minissdpc.obj) 1
Error LNK2001 unresolved external symbol __imp__fprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(connecthostport.obj) 1
Error LNK2001 unresolved external symbol __imp__fprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(miniwget.obj) 1
Error LNK2001 unresolved external symbol __imp__fprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(portlistingparse.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(minisoap.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(miniwget.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(igd_desc_parse.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(miniupnpc.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(receivedata.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(upnpreplyparse.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(minissdpc.obj) 1
Error LNK2001 unresolved external symbol __imp__printf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(connecthostport.obj) 1
Error LNK2019 unresolved external symbol __imp__sscanf referenced in function _UPNP_GetStatusInfo NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(upnpcommands.obj) 1
Error LNK2001 unresolved external symbol __imp___snprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(connecthostport.obj) 1
Error LNK2001 unresolved external symbol __imp___snprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(minisoap.obj) 1
Error LNK2001 unresolved external symbol __imp___snprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(miniwget.obj) 1
Error LNK2001 unresolved external symbol __imp___snprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(miniupnpc.obj) 1
Error LNK2001 unresolved external symbol __imp___snprintf NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(minissdpc.obj) 1
Error LNK2001 unresolved external symbol __imp____iob_func NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(upnpreplyparse.obj) 1
Error LNK2001 unresolved external symbol __imp____iob_func NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(minissdpc.obj) 1
Error LNK2001 unresolved external symbol __imp____iob_func NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(connecthostport.obj) 1
Error LNK2001 unresolved external symbol __imp____iob_func NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(miniwget.obj) 1
Error LNK2001 unresolved external symbol __imp____iob_func NetHelper C:\Users\Brett\Documents\OutpostUniverseGitHub\NetHelper\src\miniupnpcd.lib(portlistingparse.obj) 1
I tried playing with adding the folder with the miniupnp header files to the C++ include list and the 2 miniupnp lib files to the linker list, but it didn't seem to matter. Although I find getting these files to register in Visual Studio can be very finicky.
If I had the PDB file for either NetHelper or op2ext that is bundled with Outpost 2 1.3.6, I could step debug and see a little more what is going on.
-Brett