libpq connection_timeout doesn't do subsecond timing, so make the code
authorBruce Momjian <[email protected]>
Mon, 14 Oct 2002 17:15:11 +0000 (17:15 +0000)
committerBruce Momjian <[email protected]>
Mon, 14 Oct 2002 17:15:11 +0000 (17:15 +0000)
clear on that point.

src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/libpq-int.h

index 3539b5f183d26ef218b5044e138cfd015bae45ae..e43acebd91818898a2cb6aa20ba1b155ca64c5ca 100644 (file)
@@ -1071,15 +1071,14 @@ connectDBComplete(PGconn *conn)
                        conn->status = CONNECTION_BAD;
                        return 0;
                }
-               remains.tv_usec = 0;
+               remains.tv_usec = 0;    /* We don't use subsecond timing */
                rp = &remains;
 
                /* calculate the finish time based on start + timeout */
                finish_time = time((time_t *) NULL) + remains.tv_sec;
        }
 
-       while (rp == NULL || remains.tv_sec > 0 ||
-                  (remains.tv_sec == 0 && remains.tv_usec > 0))
+       while (rp == NULL || remains.tv_sec > 0)
        {
                /*
                 * Wait, if necessary.  Note that the initial state (just after
@@ -1133,7 +1132,6 @@ connectDBComplete(PGconn *conn)
                        }
 
                        remains.tv_sec = finish_time - current_time;
-                       remains.tv_usec = 0;
                }
        }
        conn->status = CONNECTION_BAD;
index 8c86f89882df356f22cebe4e41679ad5563a2e7d..6aa58026bbd6a79529625069e2c60660d8b063a6 100644 (file)
@@ -783,14 +783,13 @@ pqWait(int forRead, int forWrite, PGconn *conn)
 }
 
 int
-pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * timeout)
+pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval *timeout)
 {
        fd_set          input_mask;
        fd_set          output_mask;
        fd_set          except_mask;
 
        struct timeval tmp_timeout;
-       struct timeval *ptmp_timeout = NULL;
 
        if (conn->sock < 0)
        {
@@ -823,14 +822,13 @@ retry5:
                if (NULL != timeout)
                {
                        /*
-                        * select may modify timeout argument on some platforms use
-                        * copy
+                        *      select() may modify timeout argument on some platforms so
+                        *      use copy
                         */
                        tmp_timeout = *timeout;
-                       ptmp_timeout = &tmp_timeout;
                }
                if (select(conn->sock + 1, &input_mask, &output_mask,
-                                  &except_mask, ptmp_timeout) < 0)
+                                  &except_mask, &tmp_timeout) < 0)
                {
                        if (SOCK_ERRNO == EINTR)
                                goto retry5;
index 9a1a79eb8eaaee5c788c4ab81f5ec7d83e6d8980..0e46e81207cdf103019e86e45e32a7ff8c7fe991 100644 (file)
@@ -340,7 +340,7 @@ extern int  pqReadData(PGconn *conn);
 extern int     pqFlush(PGconn *conn);
 extern int     pqSendSome(PGconn *conn);
 extern int     pqWait(int forRead, int forWrite, PGconn *conn);
-extern int     pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * timeout);
+extern int     pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval *timeout);
 extern int     pqReadReady(PGconn *conn);
 extern int     pqWriteReady(PGconn *conn);