From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Denis A Ustimenko <denis(at)oldham(dot)ru> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c |
Date: | 2002-10-16 15:02:10 |
Message-ID: | 200210161502.g9GF2Ac25831@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I will keep this in case we need it later. I think we worked around
this problem by having timeout == 1 set equal to 2 so we get at least
one second for the connection.
---------------------------------------------------------------------------
Denis A Ustimenko wrote:
> On Mon, Oct 14, 2002 at 01:00:07AM -0400, Bruce Momjian wrote:
> > Denis A Ustimenko wrote:
> > > On Sun, Oct 13, 2002 at 09:02:55PM -0700, Joe Conway wrote:
> > > > Denis A Ustimenko wrote:
> > > > >>Bruce, why have all precise time calculations been droped out in 1.206?
> > > > >>If there is no
> > > > >>gettimeofday in win32?
> > > >
> > > > gettimeofday was not portable to win32 (at least not that I could find) and
> > > > hence broke the win32 build of the clients.
> > > >
> > >
> > > GetSystemTimeAsFileTime should help.
> > >
> > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemtimeasfiletime.asp
> >
> > It's not clear to me how we could get this into something we can deal
> > with like gettimeofday.
> >
> > I looked at the Apache APR project, and they have a routine that returns
> > the microseconds since 1970 for Unix:
> >
>
> Here is my version of gettimeofday for win32. It was tested with Watcom C 11.0c. I think it can be used. I still belive that fine time calculation is the right way.
>
> #include<stdio.h>
> #ifdef _WIN32
> #include<winsock.h>
> #else
> #include<sys/time.h>
> #endif
>
> main()
> {
> struct timeval t;
> if (gettimeofday(&t,NULL)) {
> printf("error\n\r");
> } else {
> printf("the time is %ld.%ld\n\r", t.tv_sec, t.tv_usec);
> }
> fflush(stdout);
> }
>
> #ifdef _WIN32
> int gettimeofday(struct timeval *tp, void *tzp)
> {
> FILETIME time;
> __int64 tmp;
>
> if ( NULL == tp) return -1;
>
> GetSystemTimeAsFileTime(&time);
>
> tmp = time.dwHighDateTime;
> tmp <<= 32;
> tmp |= time.dwLowDateTime;
> tmp /= 10; // it was in 100 nanosecond periods
> tp->tv_sec = tmp / 1000000 - 11644473600L; // Windows Epoch begins at 12:00 AM 01.01.1601
> tp->tv_usec = tmp % 1000000;
> return 0;
> }
> #endif
>
>
>
> --
> Regards
> Denis
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-10-16 15:05:40 | Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c |
Previous Message | Tom Lane | 2002-10-16 15:02:05 | Re: droped out precise time calculations in src/interfaces/libpq/fe-connect.c |