pgsql/src/backend/port/darwin sem.c

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

pgsql/src/backend/port/darwin sem.c

От:
Bruce Momjian - CVS <momjian@hub.org>
Дата:
CVSROOT:	/home/projects/pgsql/cvsroot
Module name:	pgsql
Changes by:	momjian@hub.org	01/01/17 17:11:19

Modified files:
	src/backend/port/darwin: sem.c 

Log message:
	attached is a patch that makes SysV semaphore emulation
	using POSIX semaphores more robust on Darwin 1.2/Mac OS X
	Public Beta.  this is for the version of 7.1 available
	via anon cvs as of Jan 14 2001 14:00 PST.
	
	since the semaphores and shared memory created by this
	emulator are shared with the backends via fork(), their
	persistent names are not necessary.  removing their
	names with shm_unlink() and sem_unlink() after creation
	obviates the need for any "ipcclean" function.  further,
	without these changes, the shared memory (and, therefore,
	the semaphores) will not be re-initialized/re-created after
	the first execution of the postmaster, until reboot
	or until some (non-existent) ipcclean function is executed.
	
	this patch does the following:
	
	1) if the shared memory segment "SysV_Sem_Info" already
	existed, it is cleaned up.  it shouldn't be there anyways.
	
	2) the real indicator for whether the shared memory/semaphore
	emulator has been initialized is if "SemInfo" has been
	initialized.  the shared memory and semaphores must be
	initialized regardless of whether there was a garbage shared
	memory segment lying around.
	
	3) the shared memory segment "SysV_Sem_Info" is created with "O_EXCL"
	to catch the case where two postmasters might be starting
	simultaneously, so they don't both end up with the same shared
	memory (one will fail).  note that this can't be done with the
	semaphores because Darwin 1.2 has a bug where attempting to
	open an existing semaphore with "O_EXCL" set will ruin the
	semaphore until the next reboot.
	
	4) the shared memory segment "SysV_Sem_Info" is unlinked after
	it is created.  it will then exist without a name until the
	postmaster and all backend children exit.
	5) all semaphores are unlinked after they are created.  they'll
	then exist without names until the postmaster and all backend
	children exit.
	
	-michael thornburgh, zenomt@armory.com

FAQ