mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
libpq connection_timeout doesn't do subsecond timing, so make the code
clear on that point.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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;
|
conn->status = CONNECTION_BAD;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
remains.tv_usec = 0;
|
remains.tv_usec = 0; /* We don't use subsecond timing */
|
||||||
rp = &remains;
|
rp = &remains;
|
||||||
|
|
||||||
/* calculate the finish time based on start + timeout */
|
/* calculate the finish time based on start + timeout */
|
||||||
finish_time = time((time_t *) NULL) + remains.tv_sec;
|
finish_time = time((time_t *) NULL) + remains.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (rp == NULL || remains.tv_sec > 0 ||
|
while (rp == NULL || remains.tv_sec > 0)
|
||||||
(remains.tv_sec == 0 && remains.tv_usec > 0))
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Wait, if necessary. Note that the initial state (just after
|
* 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_sec = finish_time - current_time;
|
||||||
remains.tv_usec = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn->status = CONNECTION_BAD;
|
conn->status = CONNECTION_BAD;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -790,7 +790,6 @@ pqWaitTimed(int forRead, int forWrite, PGconn *conn, const struct timeval * time
|
|||||||
fd_set except_mask;
|
fd_set except_mask;
|
||||||
|
|
||||||
struct timeval tmp_timeout;
|
struct timeval tmp_timeout;
|
||||||
struct timeval *ptmp_timeout = NULL;
|
|
||||||
|
|
||||||
if (conn->sock < 0)
|
if (conn->sock < 0)
|
||||||
{
|
{
|
||||||
@ -823,14 +822,13 @@ retry5:
|
|||||||
if (NULL != timeout)
|
if (NULL != timeout)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* select may modify timeout argument on some platforms use
|
* select() may modify timeout argument on some platforms so
|
||||||
* copy
|
* use copy
|
||||||
*/
|
*/
|
||||||
tmp_timeout = *timeout;
|
tmp_timeout = *timeout;
|
||||||
ptmp_timeout = &tmp_timeout;
|
|
||||||
}
|
}
|
||||||
if (select(conn->sock + 1, &input_mask, &output_mask,
|
if (select(conn->sock + 1, &input_mask, &output_mask,
|
||||||
&except_mask, ptmp_timeout) < 0)
|
&except_mask, &tmp_timeout) < 0)
|
||||||
{
|
{
|
||||||
if (SOCK_ERRNO == EINTR)
|
if (SOCK_ERRNO == EINTR)
|
||||||
goto retry5;
|
goto retry5;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user