Index: src/interfaces/libpq/fe-connect.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v retrieving revision 1.182 diff -c -r1.182 fe-connect.c *** src/interfaces/libpq/fe-connect.c 2 Mar 2002 00:49:22 -0000 1.182 --- src/interfaces/libpq/fe-connect.c 14 Apr 2002 04:40:24 -0000 *************** *** 913,920 **** --- 913,925 ---- * Thus, we have to make arrangements for all eventualities. * ---------- */ + retry1: if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0) { + if (SOCK_ERRNO == EINTR) + /* Interrupted system call - we'll just try again */ + goto retry1; + if (SOCK_ERRNO == EINPROGRESS || SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == 0) { /* *************** *** 949,957 **** --- 954,967 ---- SOCK_STRERROR(SOCK_ERRNO)); goto connect_errReturn; } + retry2: /* Now receive the postmasters response */ if (recv(conn->sock, &SSLok, 1, 0) != 1) { + if (SOCK_ERRNO == EINTR) + /* Interrupted system call - we'll just try again */ + goto retry2; + printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not receive server response to SSL negotiation packet: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); *************** *** 2132,2139 **** --- 2142,2153 ---- "PQrequestCancel() -- socket() failed: "); goto cancel_errReturn; } + retry3: if (connect(tmpsock, &conn->raddr.sa, conn->raddr_len) < 0) { + if (SOCK_ERRNO == EINTR) + /* Interrupted system call - we'll just try again */ + goto retry3; strcpy(conn->errorMessage.data, "PQrequestCancel() -- connect() failed: "); goto cancel_errReturn; *************** *** 2150,2157 **** --- 2164,2175 ---- crp.cp.backendPID = htonl(conn->be_pid); crp.cp.cancelAuthCode = htonl(conn->be_key); + retry4: if (send(tmpsock, (char *) &crp, sizeof(crp), 0) != (int) sizeof(crp)) { + if (SOCK_ERRNO == EINTR) + /* Interrupted system call - we'll just try again */ + goto retry4; strcpy(conn->errorMessage.data, "PQrequestCancel() -- send() failed: "); goto cancel_errReturn; Index: src/interfaces/libpq/fe-misc.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v retrieving revision 1.68 diff -c -r1.68 fe-misc.c *** src/interfaces/libpq/fe-misc.c 6 Mar 2002 06:10:42 -0000 1.68 --- src/interfaces/libpq/fe-misc.c 14 Apr 2002 04:40:25 -0000 *************** *** 361,367 **** if (!conn || conn->sock < 0) return -1; ! retry: FD_ZERO(&input_mask); FD_SET(conn->sock, &input_mask); timeout.tv_sec = 0; --- 361,367 ---- if (!conn || conn->sock < 0) return -1; ! retry1: FD_ZERO(&input_mask); FD_SET(conn->sock, &input_mask); timeout.tv_sec = 0; *************** *** 371,377 **** { if (SOCK_ERRNO == EINTR) /* Interrupted system call - we'll just try again */ ! goto retry; printfPQExpBuffer(&conn->errorMessage, libpq_gettext("select() failed: %s\n"), --- 371,377 ---- { if (SOCK_ERRNO == EINTR) /* Interrupted system call - we'll just try again */ ! goto retry1; printfPQExpBuffer(&conn->errorMessage, libpq_gettext("select() failed: %s\n"), *************** *** 395,401 **** if (!conn || conn->sock < 0) return -1; ! retry: FD_ZERO(&input_mask); FD_SET(conn->sock, &input_mask); timeout.tv_sec = 0; --- 395,401 ---- if (!conn || conn->sock < 0) return -1; ! retry2: FD_ZERO(&input_mask); FD_SET(conn->sock, &input_mask); timeout.tv_sec = 0; *************** *** 405,411 **** { if (SOCK_ERRNO == EINTR) /* Interrupted system call - we'll just try again */ ! goto retry; printfPQExpBuffer(&conn->errorMessage, libpq_gettext("select() failed: %s\n"), --- 405,411 ---- { if (SOCK_ERRNO == EINTR) /* Interrupted system call - we'll just try again */ ! goto retry2; printfPQExpBuffer(&conn->errorMessage, libpq_gettext("select() failed: %s\n"), *************** *** 478,484 **** } /* OK, try to read some data */ ! tryAgain: #ifdef USE_SSL if (conn->ssl) nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd, --- 478,484 ---- } /* OK, try to read some data */ ! retry3: #ifdef USE_SSL if (conn->ssl) nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd, *************** *** 490,496 **** if (nread < 0) { if (SOCK_ERRNO == EINTR) ! goto tryAgain; /* Some systems return EAGAIN/EWOULDBLOCK for no data */ #ifdef EAGAIN if (SOCK_ERRNO == EAGAIN) --- 490,496 ---- if (nread < 0) { if (SOCK_ERRNO == EINTR) ! goto retry3; /* Some systems return EAGAIN/EWOULDBLOCK for no data */ #ifdef EAGAIN if (SOCK_ERRNO == EAGAIN) *************** *** 531,537 **** (conn->inBufSize - conn->inEnd) >= 8192) { someread = 1; ! goto tryAgain; } return 1; } --- 531,537 ---- (conn->inBufSize - conn->inEnd) >= 8192) { someread = 1; ! goto retry3; } return 1; } *************** *** 564,570 **** * Still not sure that it's EOF, because some data could have just * arrived. */ ! tryAgain2: #ifdef USE_SSL if (conn->ssl) nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd, --- 564,570 ---- * Still not sure that it's EOF, because some data could have just * arrived. */ ! retry4: #ifdef USE_SSL if (conn->ssl) nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd, *************** *** 576,582 **** if (nread < 0) { if (SOCK_ERRNO == EINTR) ! goto tryAgain2; /* Some systems return EAGAIN/EWOULDBLOCK for no data */ #ifdef EAGAIN if (SOCK_ERRNO == EAGAIN) --- 576,582 ---- if (nread < 0) { if (SOCK_ERRNO == EINTR) ! goto retry4; /* Some systems return EAGAIN/EWOULDBLOCK for no data */ #ifdef EAGAIN if (SOCK_ERRNO == EAGAIN) *************** *** 804,810 **** if (forRead || forWrite) { ! retry: FD_ZERO(&input_mask); FD_ZERO(&output_mask); FD_ZERO(&except_mask); --- 804,810 ---- if (forRead || forWrite) { ! retry5: FD_ZERO(&input_mask); FD_ZERO(&output_mask); FD_ZERO(&except_mask); *************** *** 817,823 **** (struct timeval *) NULL) < 0) { if (SOCK_ERRNO == EINTR) ! goto retry; printfPQExpBuffer(&conn->errorMessage, libpq_gettext("select() failed: %s\n"), SOCK_STRERROR(SOCK_ERRNO)); --- 817,823 ---- (struct timeval *) NULL) < 0) { if (SOCK_ERRNO == EINTR) ! goto retry5; printfPQExpBuffer(&conn->errorMessage, libpq_gettext("select() failed: %s\n"), SOCK_STRERROR(SOCK_ERRNO));