chenhj <chjischj@163.com> writes:
> [chenhj@node2 ~]$ export PGCONNECT_TIMEOUT=2147483647
That's a pretty darn silly setting, wouldn't you agree?
> finish_time = time(NULL) + timeout;
> if(finish_time < ((time_t) 0))
> {
> finish_time = ((time_t) -1);
> }
I don't care for this "fix" because it assumes that all current and future
time_t's are positive. On 32-bit machines that would break in 2038 ...
unless time_t is redefined as unsigned 32-bit, in which case the test
becomes useless.
It might be possible to develop a test for overflow that would work
regardless of the width or signedness of time_t, but ISTM the work would
be vastly out of proportion to the benefit. And you'd still not have
dealt with PGCONNECT_TIMEOUT > 2^31, which arguably is another "bug"
case here.
regards, tom lane