mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 12:29:25 +02:00
* changed return value in case of failure in ThreadManager.SemaphoreInit
from nil to pointer(-1), because nil/0 is a valid return value for sem_open() on some platforms git-svn-id: trunk@26079 -
This commit is contained in:
parent
3ce0b33302
commit
cada770f9e
@ -627,7 +627,9 @@ begin
|
||||
{ the process exits }
|
||||
sem_unlink(name)
|
||||
else
|
||||
cIntSemaphoreOpen:=NIL;
|
||||
{ 0 is a valid for sem_open on some platforms; pointer(-1) shouldn't
|
||||
be valid anywhere, even for sem_init }
|
||||
cIntSemaphoreOpen:=pointer(-1);
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
@ -644,7 +646,9 @@ begin
|
||||
if sem_init(PSemaphore(cIntSemaphoreInit), 0, ord(initvalue)) <> 0 then
|
||||
begin
|
||||
FreeMem(cIntSemaphoreInit);
|
||||
cIntSemaphoreInit:=NIL;
|
||||
{ 0 is a valid for sem_open on some platforms; pointer(-1) shouldn't
|
||||
be valid anywhere, even for sem_init }
|
||||
cIntSemaphoreInit:=pointer(-1);
|
||||
end;
|
||||
{$else}
|
||||
{$ifdef has_sem_open}
|
||||
@ -658,7 +662,9 @@ begin
|
||||
if (fppipe(PFilDes(cIntSemaphoreInit)^) <> 0) then
|
||||
begin
|
||||
FreeMem(cIntSemaphoreInit);
|
||||
cIntSemaphoreInit:=nil;
|
||||
{ 0 is a valid for sem_open on some platforms; pointer(-1) shouldn't
|
||||
be valid anywhere, even for sem_init }
|
||||
cIntSemaphoreInit:=pointer(-1);
|
||||
end
|
||||
else if initvalue then
|
||||
cSemaphorePost(cIntSemaphoreInit);
|
||||
|
@ -178,7 +178,7 @@ begin
|
||||
// via BeginThread and creates the first TThread Object in there!
|
||||
InitThreads;
|
||||
FSem := CurrentTM.SemaphoreInit();
|
||||
if FSem = nil then
|
||||
if FSem = pointer(-1) then
|
||||
raise EThread.create('Semaphore init failed (possibly too many concurrent threads)');
|
||||
WRITE_DEBUG('thread ', ptruint(self), ' created semaphore ', ptruint(FSem));
|
||||
FSuspended := CreateSuspended;
|
||||
|
Loading…
Reference in New Issue
Block a user