Tom Lane wrote:
> Bruce Momjian <[EMAIL PROTECTED]> writes:
> > That whole remains structure should be a time_t variable, and then we
> > _know_ we can't assume it is signed. The use of timeval should
> > happen only in pqWaitTimed because it has to use select().
>
> I think it's fine to use struct timeval as the parameter type for
> pqWaitTimed. This particular caller of pqWaitTimed has no need for
> sub-second wait precision, but that doesn't mean we might not want it
> for other purposes later.
That was a question: whether pqWaitTimed() was something exported by
libpq and therefore something that has an API that shouldn't change. I
see it in libpq-int.h, which I think means it isn't exported, but yes,
there could be later cases where we need subsecond stuff.
I have applied the following patch to get us a little closer to sanity.
--
Bruce Momjian | http://candle.pha.pa.us
[EMAIL PROTECTED] | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.208
diff -c -c -r1.208 fe-connect.c
*** src/interfaces/libpq/fe-connect.c 11 Oct 2002 04:41:59 -0000 1.208
--- src/interfaces/libpq/fe-connect.c 14 Oct 2002 17:10:19 -0000
***************
*** 1071,1085 ****
conn->status = CONNECTION_BAD;
return 0;
}
! remains.tv_usec = 0;
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))
{
/*
* Wait, if necessary. Note that the initial state (just after
--- 1071,1084 ----
conn->status = CONNECTION_BAD;
return 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)
{
/*
* Wait, if necessary. Note that the initial state (just after
***************
*** 1133,1139 ****
}
remains.tv_sec = finish_time - current_time;
- remains.tv_usec = 0;
}
}
conn->status = CONNECTION_BAD;
--- 1132,1137 ----
Index: src/interfaces/libpq/fe-misc.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-misc.c,v
retrieving revision 1.80
diff -c -c -r1.80 fe-misc.c
*** src/interfaces/libpq/fe-misc.c 3 Oct 2002 17:09:42 -0000 1.80
--- src/interfaces/libpq/fe-misc.c 14 Oct 2002 17:10:22 -0000
***************
*** 783,796 ****
}
int
! 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)
{
--- 783,795 ----
}
int
! 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;
if (conn->sock < 0)
{
***************
*** 823,836 ****
if (NULL != timeout)
{
/*
! * select may modify timeout argument on some platforms use
! * copy
*/
tmp_timeout = *timeout;
- ptmp_timeout = &tmp_timeout;
}
if (select(conn->sock + 1, &input_mask, &output_mask,
! &except_mask, ptmp_timeout) < 0)
{
if (SOCK_ERRNO == EINTR)
goto retry5;
--- 822,834 ----
if (NULL != timeout)
{
/*
! * select() may modify timeout argument on some platforms
so
! * use copy
*/
tmp_timeout = *timeout;
}
if (select(conn->sock + 1, &input_mask, &output_mask,
! &except_mask, &tmp_timeout) < 0)
{
if (SOCK_ERRNO == EINTR)
goto retry5;
Index: src/interfaces/libpq/libpq-int.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/libpq-int.h,v
retrieving revision 1.58
diff -c -c -r1.58 libpq-int.h
*** src/interfaces/libpq/libpq-int.h 3 Oct 2002 17:09:42 -0000 1.58
--- src/interfaces/libpq/libpq-int.h 14 Oct 2002 17:10:24 -0000
***************
*** 340,346 ****
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 pqReadReady(PGconn *conn);
extern int pqWriteReady(PGconn *conn);
--- 340,346 ----
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 pqReadReady(PGconn *conn);
extern int pqWriteReady(PGconn *conn);
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])