--- src/interfaces/libpq/fe-connect.c.orig Wed Oct 24 17:43:52 2001 +++ src/interfaces/libpq/fe-connect.c Wed Oct 24 17:43:54 2001 @@ -912,21 +912,35 @@ * Thus, we have to make arrangements for all eventualities. * ---------- */ + + retry_socket: if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0) { - if (SOCK_ERRNO == EINPROGRESS || SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == 0) - { - /* - * This is fine - we're in non-blocking mode, and the - * connection is in progress. - */ - conn->status = CONNECTION_STARTED; - } - else - { - /* Something's gone wrong */ - connectFailureMessage(conn, SOCK_ERRNO); - goto connect_errReturn; + switch (SOCK_ERRNO) { + case EINTR: + /* + * interrupted by signal, keep trying + */ + goto retry_socket; + break; + + case 0: + case EINPROGRESS: + case EWOULDBLOCK: + /* + * This is fine - we're in non-blocking mode, and the + * connection is in progress. + */ + conn->status = CONNECTION_STARTED; + break; + + default: + /* + * Something's gone wrong + */ + connectFailureMessage(conn, SOCK_ERRNO); + goto connect_errReturn; + break; } } else @@ -2132,8 +2146,13 @@ "PQrequestCancel() -- socket() failed: "); goto cancel_errReturn; } - if (connect(tmpsock, &conn->raddr.sa, conn->raddr_len) < 0) + while (connect(tmpsock, &conn->raddr.sa, conn->raddr_len) < 0) { + /* + * interrupted by a signal + */ + if(errno==EINTR) + continue; strcpy(conn->errorMessage.data, "PQrequestCancel() -- connect() failed: "); goto cancel_errReturn;