]> granicus.if.org Git - postgresql/commitdiff
libpq connection_timeout doesn't do subsecond timing, so make the code
authorBruce Momjian <bruce@momjian.us>
Mon, 14 Oct 2002 17:15:11 +0000 (17:15 +0000)
committerBruce Momjian <bruce@momjian.us>
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 6f9ba4abddf65daf4f75d215ac36760ce36c8250..53d79f632c794a99f04f536a8445c00c4124940f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.208 2002/10/11 04:41:59 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.209 2002/10/14 17:15:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 ad41cf749d19bf42e1da6bd9aff14419ff155f69..e820ad7fc59cc5def12be1ef3d28b08ec547bb03 100644 (file)
@@ -25,7 +25,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.80 2002/10/03 17:09:42 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.81 2002/10/14 17:15:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 cdf978e5b13130aaf4889d06729954265e31c96e..e2ee2491f8a5a2c861e809cf9b94ab6d7077d844 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: libpq-int.h,v 1.58 2002/10/03 17:09:42 momjian Exp $
+ * $Id: libpq-int.h,v 1.59 2002/10/14 17:15:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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);