pg_arch.c call to sleep()

Поиск
Список
Период
Сортировка
Искать

pg_arch.c call to sleep()

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

We have the following warning on Windows:

pgarch.c:349: warning: implicit declaration of function `sleep'

To fix it we could include the right header (which appears to be 
 in the Windows/Mingw case), or we could replace the call by a 
call to pg_usleep().

I'm inclined to do the latter, on grounds of consistency, but want to be 
sure that it will get the signal handling right.

Unless I hear squawks of objection I will supply a patch for that soon.

cheers

andrew

Re: pg_arch.c call to sleep()

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> We have the following warning on Windows:
> pgarch.c:349: warning: implicit declaration of function `sleep'

> To fix it we could include the right header (which appears to be 
>  in the Windows/Mingw case), or we could replace the call by a 
> call to pg_usleep().

 is included automatically by c.h, so that surely won't fix it.

I have some recollection that we invented pg_usleep in part because we
wanted to not use sleep() at all in the backend, but I don't recall why
(and the reasoning might not apply to the archiver process, anyway).
		regards, tom lane

Re: pg_arch.c call to sleep()

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:


Tom Lane wrote:

>Andrew Dunstan  writes:
>  
>
>>We have the following warning on Windows:
>>pgarch.c:349: warning: implicit declaration of function `sleep'
>>    
>>
>
>  
>
>>To fix it we could include the right header (which appears to be 
>> in the Windows/Mingw case), or we could replace the call by a 
>>call to pg_usleep().
>>    
>>
>
> is included automatically by c.h, so that surely won't fix it.
>  
>

Now I look closer I see that it declares _sleep() rather than sleep().

>I have some recollection that we invented pg_usleep in part because we
>wanted to not use sleep() at all in the backend, but I don't recall why
>(and the reasoning might not apply to the archiver process, anyway).
>
>
>  
>

I thought we invented pg_usleep so we could remove the calls to 
select(0,NULL,NULL,NULL,timeout) which don't work on Windows.

cheers

andrew

Re: pg_arch.c call to sleep()

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Tom Lane wrote:
> Andrew Dunstan  writes:
> > We have the following warning on Windows:
> > pgarch.c:349: warning: implicit declaration of function `sleep'
> 
> > To fix it we could include the right header (which appears to be 
> >  in the Windows/Mingw case), or we could replace the call by a 
> > call to pg_usleep().
> 
>  is included automatically by c.h, so that surely won't fix it.
> 
> I have some recollection that we invented pg_usleep in part because we
> wanted to not use sleep() at all in the backend, but I don't recall why
> (and the reasoning might not apply to the archiver process, anyway).

I think usleep was so we could accept signals during the sleep.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610) 359-1001 +  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: pg_arch.c call to sleep()

От:
"Magnus Hagander" <mha@sollentuna.net>
Дата:
> > We have the following warning on Windows:
> > pgarch.c:349: warning: implicit declaration of function `sleep'
> 
> > To fix it we could include the right header (which appears to be 
> >  in the Windows/Mingw case), or we could replace 
> the call by 
> > a call to pg_usleep().
> 
>  is included automatically by c.h, so that surely 
> won't fix it.
> 
> I have some recollection that we invented pg_usleep in part 
> because we wanted to not use sleep() at all in the backend, 
> but I don't recall why (and the reasoning might not apply to 
> the archiver process, anyway).

win32 signal handling won't interrupt sleep(), just pg_usleep().

//Magnus

FAQ