Fix connect() socket error trace on Windows
closesocket() clobbers the Winsock last error value, so we must only call it after tracing.
This commit is contained in:
parent
619a386006
commit
3d4661635e
|
@ -193,6 +193,8 @@ SOCKET connecthostport(const char * host, unsigned short port,
|
||||||
s = INVALID_SOCKET;
|
s = INVALID_SOCKET;
|
||||||
for(p = ai; p; p = p->ai_next)
|
for(p = ai; p; p = p->ai_next)
|
||||||
{
|
{
|
||||||
|
if(!ISINVALID(s))
|
||||||
|
closesocket(s);
|
||||||
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
|
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
|
||||||
if(ISINVALID(s))
|
if(ISINVALID(s))
|
||||||
continue;
|
continue;
|
||||||
|
@ -260,7 +262,6 @@ SOCKET connecthostport(const char * host, unsigned short port,
|
||||||
#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */
|
#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */
|
||||||
if(n < 0)
|
if(n < 0)
|
||||||
{
|
{
|
||||||
closesocket(s);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -277,6 +278,7 @@ SOCKET connecthostport(const char * host, unsigned short port,
|
||||||
if(n < 0)
|
if(n < 0)
|
||||||
{
|
{
|
||||||
PRINT_SOCKET_ERROR("connect");
|
PRINT_SOCKET_ERROR("connect");
|
||||||
|
closesocket(s);
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
#endif /* #ifdef USE_GETHOSTBYNAME */
|
#endif /* #ifdef USE_GETHOSTBYNAME */
|
||||||
|
|
Loading…
Reference in New Issue