From f354f73238c40a356d85670f03d15b75b1d11fe9 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 5 Feb 2014 18:31:28 +0100 Subject: [PATCH] miniupnpc/connecthostport.c: handle EINPROGRESS after connect() --- miniupnpc/Changelog.txt | 5 ++++- miniupnpc/connecthostport.c | 14 ++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/miniupnpc/Changelog.txt b/miniupnpc/Changelog.txt index ccf3b91..53e9a11 100644 --- a/miniupnpc/Changelog.txt +++ b/miniupnpc/Changelog.txt @@ -1,6 +1,9 @@ -$Id: Changelog.txt,v 1.191 2014/01/31 13:18:24 nanard Exp $ +$Id: Changelog.txt,v 1.193 2014/02/05 17:26:45 nanard Exp $ miniUPnP client Changelog. +2014/02/05: + handle EINPROGRESS after connect() + 2014/02/03: minixml now handle XML comments diff --git a/miniupnpc/connecthostport.c b/miniupnpc/connecthostport.c index aabc7a6..98f7253 100644 --- a/miniupnpc/connecthostport.c +++ b/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.12 2014/02/05 17:26:46 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2010-2013 Thomas Bernard + * Copyright (c) 2010-2014 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. */ @@ -109,7 +109,10 @@ int connecthostport(const char * host, unsigned short port, 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 +206,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;