Re: Latch implementation that wakes on postmaster death on both win32 and Unix

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>

From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Peter Geoghegan <peter@2ndquadrant.com>
Cc: PG Hackers <pgsql-hackers@postgresql.org>
Date: 2011-06-16T14:27:26Z
Lists: 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