""Magnus Hagander"" <mha@sollentuna.net> wrote
> >
> > 1. Backend crash while postmaster stays alive: postmaster
> > will get to execute the on_shmem_exit() callback after all
> > the backends are gone, and that can clean 'em up.
> >
> > 2. postmaster crashes: we'd like the semas to go away
> > automatically when the last backend goes away. If this
> > doesn't happen, then there has to be logic to recycle
> > leftover semas when the postmaster is next started.
> >
> > Most of the ugliness in sysv_sema.c is because it has to do "manual"
> > cleanup per #2.
> >
>
> For #2, yes, the semaphores will go away when the last process holding a
> HANDLE to it goes away. For #1, the code seems to handle that right?
>
I intentionally use *unnamed* semaphores to avoid these problems -- even if
the semaphores didn't go away (as Magus pointed out, if all processes can
exit gracefully, this won't happen), we won't worry about them -- Creating
semahpores will still succeed because there is no existent same named
semaphores will bother it.
Regards,
Qingqing