Re: [HACKERS] pg_arch.c call to sleep()
От | Andrew Dunstan |
---|---|
Тема | Re: [HACKERS] pg_arch.c call to sleep() |
Дата | |
Msg-id | 418F6F94.3080504@dunslane.net обсуждение исходный текст |
Ответы |
Re: [HACKERS] pg_arch.c call to sleep()
|
Список | pgsql-patches |
Magnus Hagander wrote: >>>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 >>><stdlib.h> in the Windows/Mingw case), or we could replace >>> >>> >>the call by >> >> >>>a call to pg_usleep(). >>> >>> >><stdlib.h> 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(). > > > > I take this as confirmation that calling pg_usleep is the Right Thing (tm). Here's the patch. cheers andrew Index: pgarch.c =================================================================== RCS file: /home/cvsmirror/pgsql/src/backend/postmaster/pgarch.c,v retrieving revision 1.9 diff -c -r1.9 pgarch.c *** pgarch.c 29 Aug 2004 05:06:46 -0000 1.9 --- pgarch.c 8 Nov 2004 12:59:49 -0000 *************** *** 338,352 **** /* * There shouldn't be anything for the archiver to do except to ! * wait for a signal, so we could use pause(3) here... ...however, ! * the archiver exists to protect our data, so she wakes up ! * occasionally to allow herself to be proactive. In particular ! * this avoids getting stuck if a signal arrives just before we ! * enter sleep(). */ if (!wakened) { ! sleep(PGARCH_AUTOWAKE_INTERVAL); curtime = time(NULL); if ((unsigned int) (curtime - last_copy_time) >= --- 338,351 ---- /* * There shouldn't be anything for the archiver to do except to ! * wait for a signal, ... however, the archiver exists to ! * protect our data, so she wakes up occasionally to allow ! * herself to be proactive. In particular this avoids getting ! * stuck if a signal arrives just before we sleep. */ if (!wakened) { ! pg_usleep(PGARCH_AUTOWAKE_INTERVAL * 1000000L); curtime = time(NULL); if ((unsigned int) (curtime - last_copy_time) >=
В списке pgsql-patches по дате отправления: