Commit 4e723e67 authored by Bruce Momjian's avatar Bruce Momjian

Cleanup of libpq connection timeout code.

parent 78a693c4
......@@ -8,7 +8,7 @@
*
*
* 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;
}
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 (NULL != rp) {
if (-1 == gettimeofday(&finish_time, NULL))
if (NULL != rp)
{
if (gettimeofday(&finish_time, NULL) == -1)
{
conn->status = CONNECTION_BAD;
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++;
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_usec += 1000000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment