diff options
author | Tobias Markmann <tm@ayena.de> | 2017-05-16 14:59:08 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-05-17 06:36:48 (GMT) |
commit | edf519a67a28f9acb61af6d442d94f1aa43df688 (patch) | |
tree | 802269050d3db7c13c763550269f663172938b96 /3rdParty/LibMiniUPnPc/src/miniupnpc/connecthostport.c | |
parent | 6644c207c879f33dac40c02ab6787a0c4184728d (diff) | |
download | swift-edf519a67a28f9acb61af6d442d94f1aa43df688.zip swift-edf519a67a28f9acb61af6d442d94f1aa43df688.tar.bz2 |
Update 3rdParty/LibMiniUPnPc to miniupnpc-2.0.20170509
Test-Information:
Builds on macOS 10.12.5 with Qt 5.4.2 and all unit and
integration tests pass.
Change-Id: I491c0f78bf8773056feb3825d21989d6c7a2aeab
Diffstat (limited to '3rdParty/LibMiniUPnPc/src/miniupnpc/connecthostport.c')
-rw-r--r-- | 3rdParty/LibMiniUPnPc/src/miniupnpc/connecthostport.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/3rdParty/LibMiniUPnPc/src/miniupnpc/connecthostport.c b/3rdParty/LibMiniUPnPc/src/miniupnpc/connecthostport.c index aabc7a6..aed62c7 100644 --- a/3rdParty/LibMiniUPnPc/src/miniupnpc/connecthostport.c +++ b/3rdParty/LibMiniUPnPc/src/miniupnpc/connecthostport.c @@ -1,7 +1,7 @@ -/* $Id: connecthostport.c,v 1.11 2013/08/01 21:21:25 nanard Exp $ */ +/* $Id: connecthostport.c,v 1.17 2017/04/21 09:58:30 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2010-2013 Thomas Bernard + * Copyright (c) 2010-2017 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. */ @@ -23,6 +23,10 @@ #define socklen_t int #else /* #ifdef _WIN32 */ #include <unistd.h> +#include <sys/types.h> +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT +#include <sys/time.h> +#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ #include <sys/param.h> #include <sys/select.h> #include <errno.h> @@ -32,15 +36,13 @@ /* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions * during the connect() call */ #define MINIUPNPC_IGNORE_EINTR -#ifndef USE_GETHOSTBYNAME -#include <sys/types.h> #include <sys/socket.h> -#endif /* #ifndef USE_GETHOSTBYNAME */ +#include <sys/select.h> #endif /* #else _WIN32 */ /* definition of PRINT_SOCKET_ERROR */ #ifdef _WIN32 -#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError()); +#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError()); #else #define PRINT_SOCKET_ERROR(x) perror(x) #endif @@ -96,20 +98,23 @@ int connecthostport(const char * host, unsigned short port, timeout.tv_usec = 0; if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0) { - PRINT_SOCKET_ERROR("setsockopt"); + PRINT_SOCKET_ERROR("setsockopt SO_RCVTIMEO"); } timeout.tv_sec = 3; timeout.tv_usec = 0; if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0) { - PRINT_SOCKET_ERROR("setsockopt"); + PRINT_SOCKET_ERROR("setsockopt SO_SNDTIMEO"); } #endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ dest.sin_family = AF_INET; dest.sin_port = htons(port); n = connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr_in)); #ifdef MINIUPNPC_IGNORE_EINTR - while(n < 0 && errno == EINTR) + /* EINTR The system call was interrupted by a signal that was caught + * EINPROGRESS The socket is nonblocking and the connection cannot + * be completed immediately. */ + while(n < 0 && (errno == EINTR || errno == EINPROGRESS)) { socklen_t len; fd_set wset; @@ -203,7 +208,10 @@ int connecthostport(const char * host, unsigned short port, #endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ n = connect(s, p->ai_addr, p->ai_addrlen); #ifdef MINIUPNPC_IGNORE_EINTR - while(n < 0 && errno == EINTR) + /* EINTR The system call was interrupted by a signal that was caught + * EINPROGRESS The socket is nonblocking and the connection cannot + * be completed immediately. */ + while(n < 0 && (errno == EINTR || errno == EINPROGRESS)) { socklen_t len; fd_set wset; |