mirror of
https://github.com/postgres/postgres.git
synced 2025-05-31 00:01:57 -04:00
Cleanup of libpq connection timeout code.
This commit is contained in:
parent
78a693c430
commit
4e723e6717
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.194 2002/08/18 01:35:39 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.195 2002/08/27 14:49:52 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1078,7 +1078,6 @@ connectDBComplete(PGconn *conn)
|
|||||||
rp = &remains;
|
rp = &remains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (rp == NULL || remains.tv_sec > 0 || (remains.tv_sec == 0 && remains.tv_usec > 0))
|
while (rp == NULL || remains.tv_sec > 0 || (remains.tv_sec == 0 && remains.tv_usec > 0))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -1133,18 +1132,19 @@ connectDBComplete(PGconn *conn)
|
|||||||
/*
|
/*
|
||||||
* If connecting timeout is set, calculate remain time.
|
* If connecting timeout is set, calculate remain time.
|
||||||
*/
|
*/
|
||||||
if (NULL != rp) {
|
if (NULL != rp)
|
||||||
if (-1 == gettimeofday(&finish_time, NULL))
|
{
|
||||||
|
if (gettimeofday(&finish_time, NULL) == -1)
|
||||||
{
|
{
|
||||||
conn->status = CONNECTION_BAD;
|
conn->status = CONNECTION_BAD;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (0 > (finish_time.tv_usec -= start_time.tv_usec))
|
if ((finish_time.tv_usec -= start_time.tv_usec) < 0 )
|
||||||
{
|
{
|
||||||
remains.tv_sec++;
|
remains.tv_sec++;
|
||||||
finish_time.tv_usec += 1000000;
|
finish_time.tv_usec += 1000000;
|
||||||
}
|
}
|
||||||
if (0 > (remains.tv_usec -= finish_time.tv_usec))
|
if ((remains.tv_usec -= finish_time.tv_usec) < 0 )
|
||||||
{
|
{
|
||||||
remains.tv_sec--;
|
remains.tv_sec--;
|
||||||
remains.tv_usec += 1000000;
|
remains.tv_usec += 1000000;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user