Michiel Boland wrote:
> But then can you please explain why CF tries to do a semget() with
> the IPC_EXCL flag set? And then fail and abort on a freebsd system if the
> semaphore already exists, but run completely happy on linux?
Sure, here is the code.
Suggestions on how to avoid giving FreeBSD the screwgy are welcome.
--
Tom Jordahl
Allaire Development
// Pick up and lock the registry semaphore.
if (!bInitLock) {
// We don't want to do anything if the semaphore doesn't exist.
// Try a non-creating semget here.
if ((RegSemId = semget(ftok(g_LockFile, 1), 1, REGSEM_MODE)) < 0) {
cerr << "Registry semaphore doesn't exist. Exiting." << endl;
ExitProcess(1);
}
} else if ((RegSemId = semget(ftok(g_LockFile, 1), 1,
IPC_CREAT|IPC_EXCL|REGSEM_MODE)) >= 0) {
semun.val = 1;
semctl(RegSemId, 0, SETVAL, semun);
// Set perms to allow btcats access.
semun.buf = &seminfo;
seminfo.sem_perm.uid = BtUserId;
seminfo.sem_perm.gid = BtGroupId;
seminfo.sem_perm.mode = REGSEM_MODE;
semctl(RegSemId, 0, IPC_SET, semun);
// We're expected to lock/unlock this once when first creating
// the semaphore. This allows the code on the other side of the
// else to continue when it sees the sem_otime value set.
semop(RegSemId, &SemLock, 1);
semop(RegSemId, &SemUnlock, 1);
} else if (errno == EEXIST) {
// Someone else has created; make sure it's initialized.
semun.buf = &seminfo;
RegSemId = semget(ftok(g_LockFile, 1), 1, REGSEM_MODE);
// Failure here means lack of privs.
if (RegSemId < 0) {
REGISTRY_SEMAPHORE_ERROR( errno );
_exit(1);
}
for (int i = 0; i < 10; i++) {
semctl(RegSemId, 0, IPC_STAT, semun);
if (semun.buf->sem_otime != 0)
goto init;
Sleep(250);
}
DebugMsg((DBG_FLG_ERRORS, "semget() failed1, err = %d\n",
GetLastError()));
REGISTRY_SEMAPHORE_ERROR( errno );
abort();
} else {
DebugMsg((DBG_FLG_ERRORS, "semget() failed2, err = %d\n",
GetLastError()));
REGISTRY_SEMAPHORE_ERROR( errno );
abort();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-linux%40houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_linux or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.