Skip to content

Commit 9eada51

Browse files
committed
libpq connection_timeout doesn't do subsecond timing, so make the code
clear on that point.
1 parent 8f2a289 commit 9eada51

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.208 2002/10/11 04:41:59 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.209 2002/10/14 17:15:11 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1071,15 +1071,14 @@ connectDBComplete(PGconn *conn)
10711071
conn->status = CONNECTION_BAD;
10721072
return 0;
10731073
}
1074-
remains.tv_usec = 0;
1074+
remains.tv_usec = 0; /* We don't use subsecond timing */
10751075
rp = &remains;
10761076

10771077
/* calculate the finish time based on start + timeout */
10781078
finish_time = time((time_t *) NULL) + remains.tv_sec;
10791079
}
10801080

1081-
while (rp == NULL || remains.tv_sec > 0 ||
1082-
(remains.tv_sec == 0 && remains.tv_usec > 0))
1081+
while (rp == NULL || remains.tv_sec > 0)
10831082
{
10841083
/*
10851084
* Wait, if necessary. Note that the initial state (just after
@@ -1133,7 +1132,6 @@ connectDBComplete(PGconn *conn)
11331132
}
11341133

11351134
remains.tv_sec = finish_time - current_time;
1136-
remains.tv_usec = 0;
11371135
}
11381136
}
11391137
conn->status = CONNECTION_BAD;

src/interfaces/libpq/fe-misc.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
*
2727
* IDENTIFICATION
28-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.80 2002/10/03 17:09:42 momjian Exp $
28+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.81 2002/10/14 17:15:11 momjian Exp $
2929
*
3030
*-------------------------------------------------------------------------
3131
*/
@@ -783,14 +783,13 @@ pqWait(int forRead, int forWrite, PGconn *conn)
783783
}
784784

785785
int
786-
pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * timeout)
786+
pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval *timeout)
787787
{
788788
fd_set input_mask;
789789
fd_set output_mask;
790790
fd_set except_mask;
791791

792792
struct timeval tmp_timeout;
793-
struct timeval *ptmp_timeout = NULL;
794793

795794
if (conn->sock < 0)
796795
{
@@ -823,14 +822,13 @@ pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * time
823822
if (NULL != timeout)
824823
{
825824
/*
826-
* select may modify timeout argument on some platforms use
827-
* copy
825+
* select() may modify timeout argument on some platforms so
826+
* use copy
828827
*/
829828
tmp_timeout = *timeout;
830-
ptmp_timeout = &tmp_timeout;
831829
}
832830
if (select(conn->sock + 1, &input_mask, &output_mask,
833-
&except_mask, ptmp_timeout) < 0)
831+
&except_mask, &tmp_timeout) < 0)
834832
{
835833
if (SOCK_ERRNO == EINTR)
836834
goto retry5;

src/interfaces/libpq/libpq-int.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: libpq-int.h,v 1.58 2002/10/03 17:09:42 momjian Exp $
15+
* $Id: libpq-int.h,v 1.59 2002/10/14 17:15:11 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -340,7 +340,7 @@ extern int pqReadData(PGconn *conn);
340340
extern int pqFlush(PGconn *conn);
341341
extern int pqSendSome(PGconn *conn);
342342
extern int pqWait(int forRead, int forWrite, PGconn *conn);
343-
extern int pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * timeout);
343+
extern int pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval *timeout);
344344
extern int pqReadReady(PGconn *conn);
345345
extern int pqWriteReady(PGconn *conn);
346346

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy