View previous topic :: View next topic |
Author |
Message |
AdamN
Joined: 22 Mar 2020 Posts: 2 Location: localhost
|
Posted: Sun Mar 22, 2020 2:45 am Post subject: Error UPNPCOMMAND_HTTP_ERROR (-3) when exiting a program |
|
|
Hi,
I've been integrating miniUPnPc static library as a class in a C++ program and it worked pretty well
But there is strange thing i'm getting while testing it, i keeps getting this UPNPCOMMAND_HTTP_ERROR (-3) error when i used UPNP_GetGenericPortMappingEntry in a destructor (to cleanup any lingering mapped ports created by that program) that gets triggered when exiting the program, Is this a normal behavior or was it a bug?
What kind of situation did cause it to get error UPNPCOMMAND_HTTP_ERROR? Did miniUPnPc library already shutted down at this point?
PS: calling UPNP_GetGenericPortMappingEntry while not exiting the program worked properly
Thanks in advance |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Sun Mar 22, 2020 10:36 pm Post subject: |
|
|
I guess the argument passed to the function UPNP_GetGenericPortMappingEntry are not valide anymore.
Can you debug and check ? _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
AdamN
Joined: 22 Mar 2020 Posts: 2 Location: localhost
|
Posted: Mon Mar 23, 2020 7:02 am Post subject: |
|
|
miniupnp wrote: | I guess the argument passed to the function UPNP_GetGenericPortMappingEntry are not valide anymore.
Can you debug and check ? |
Code: | snprintf(index, 6, "%d", i);
rHost[0] = '\0'; enabled[0] = '\0';
duration[0] = '\0'; desc[0] = '\0'; protocol[0] = '\0';
extPort[0] = '\0'; intPort[0] = '\0'; intAddr[0] = '\0';
// May gets UPNPCOMMAND_HTTP_ERROR when called while exiting (ie. used in destructor)
r = UPNP_GetGenericPortMappingEntry(urls->controlURL,
datas->first.servicetype,
index,
extPort, intAddr, intPort,
protocol, desc, enabled,
rHost, duration); |
When i put breakpoints, this are the arguments based on the watches:
When it's working properly within the program:
urls->controlURL = "http://192.168.8.1:49205/ctl/IPConn"
datas->first.servicetype = "urn:schemas-upnp-org:service:WANIPConnection:1"
index = "0"
the rest of char array args for the output initialized to '\0' before the call and filled with data correctly after the call
When it gets error -3 which called within destructor upon exiting the program:
urls->controlURL = "http://192.168.8.1:49205/ctl/IPConn"
datas->first.servicetype = "urn:schemas-upnp-org:service:WANIPConnection:1"
index = "0"
the rest of char array args for the output initialized to '\0' before the call and doesn't change after the call
Update:
After stepping into the function, it seems the difference is located at line 183 of miniupnpc\connecthostport.c
Code: | n = getaddrinfo(tmp_host, port_str, &hints, &ai);
if(n != 0) |
where n is 0 when working properly and 10093 (WSANOTINITIALISED) when it gets UPNPCOMMAND_HTTP_ERROR
Do i need to take care of WSAStartup and WSACleanup my self or miniupnc also use those function internally? since WSAStartup can be used multiple times without problem |
|
Back to top |
|
|
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1589
|
Posted: Mon Mar 23, 2020 3:40 pm Post subject: |
|
|
well only tracing the code could help you. _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
© 2007 Thomas Bernard, author of MiniUPNP.
|