Re: Latch implementation that wakes on postmaster death on both win32 and Unix - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Latch implementation that wakes on postmaster death on both win32 and Unix
Date
Msg-id 4DFA12CE.60305@enterprisedb.com
Whole thread Raw
In response to Re: Latch implementation that wakes on postmaster death on both win32 and Unix  (Peter Geoghegan <peter@2ndquadrant.com>)
Responses Re: Latch implementation that wakes on postmaster death on both win32 and Unix
List pgsql-hackers
Peter Geoghegan wrote:
> --- 247,277 ----
>            * do that), and the select() will return immediately.
>            */
>           drainSelfPipe();
> !         if (latch->is_set && (wakeEvents & WL_LATCH_SET))
> !          {
> !             result |= WL_LATCH_SET;
> !             found = true;
> !             /*
> !              * Leave loop immediately, avoid blocking again.
> !              * Since latch is set, no other factor could have
> !              * coincided that could make us wake up
> !              * independently of the latch being set, so no
> !              * need to worry about having missed something.
> !              */
>               break;
>           }

I don't understand that comment. Why can't e.g postmaster death happen 
at the same time as a latch is set? I think the code is fine as it is, 
we just need to document that if there are several events that would 
wake up WaitLatch(), we make no promise that we return all of them in 
the return value. I believe all the callers would be fine with that.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Patch - Debug builds without optimization
Next
From: Greg Smith
Date:
Subject: Re: procpid?