* fixed a bunch of cases where ESysEINTR wasn't handled

git-svn-id: trunk@12924 -
This commit is contained in:
Jonas Maebe 2009-03-19 21:46:12 +00:00
parent 7fa0b94f36
commit 8b53f8c41a

View File

@ -180,6 +180,7 @@ Function DoFileLocking(Handle: Longint; Mode: Integer) : Longint;
var var
lockop: cint; lockop: cint;
lockres: cint; lockres: cint;
closeres: cint;
begin begin
DoFileLocking:=Handle; DoFileLocking:=Handle;
{$ifdef beos} {$ifdef beos}
@ -218,7 +219,9 @@ begin
(similar to fmShareDenyWrite) and exclusive access (same as (similar to fmShareDenyWrite) and exclusive access (same as
fmShareExclusive) fmShareExclusive)
} }
FpClose(Handle); repeat
closeres:=FpClose(Handle);
until (closeres<>-1) or (fpgeterrno<>ESysEINTR);
DoFileLocking:=-1; DoFileLocking:=-1;
exit; exit;
end; end;
@ -229,7 +232,9 @@ begin
(fpgeterrno<>ESysEIntr); (fpgeterrno<>ESysEIntr);
if (lockres<>0) then if (lockres<>0) then
begin begin
FpClose(Handle); repeat
closeres:=FpClose(Handle);
until (closeres<>-1) or (fpgeterrno<>ESysEINTR);
DoFileLocking:=-1; DoFileLocking:=-1;
exit; exit;
end; end;
@ -249,7 +254,10 @@ begin
fmOpenWrite : LinuxFlags:=LinuxFlags or O_WrOnly; fmOpenWrite : LinuxFlags:=LinuxFlags or O_WrOnly;
fmOpenReadWrite : LinuxFlags:=LinuxFlags or O_RdWr; fmOpenReadWrite : LinuxFlags:=LinuxFlags or O_RdWr;
end; end;
FileOpen:=fpOpen (pointer(FileName),LinuxFlags);
repeat
FileOpen:=fpOpen (pointer(FileName),LinuxFlags);
until (FileOpen<>-1) or (fpgeterrno<>ESysEINTR);
FileOpen:=DoFileLocking(FileOpen, Mode); FileOpen:=DoFileLocking(FileOpen, Mode);
end; end;
@ -258,28 +266,36 @@ end;
Function FileCreate (Const FileName : String) : Longint; Function FileCreate (Const FileName : String) : Longint;
begin begin
FileCreate:=fpOpen(pointer(FileName),O_RdWr or O_Creat or O_Trunc); repeat
FileCreate:=fpOpen(pointer(FileName),O_RdWr or O_Creat or O_Trunc);
until (FileCreate<>-1) or (fpgeterrno<>ESysEINTR);
end; end;
Function FileCreate (Const FileName : String;Mode : Longint) : Longint; Function FileCreate (Const FileName : String;Mode : Longint) : Longint;
begin begin
FileCreate:=fpOpen(pointer(FileName),O_RdWr or O_Creat or O_Trunc,Mode); repeat
FileCreate:=fpOpen(pointer(FileName),O_RdWr or O_Creat or O_Trunc,Mode);
until (FileCreate<>-1) or (fpgeterrno<>ESysEINTR);
end; end;
Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint; Function FileRead (Handle : Longint; Var Buffer; Count : longint) : Longint;
begin begin
FileRead:=fpRead (Handle,Buffer,Count); repeat
FileRead:=fpRead (Handle,Buffer,Count);
until (FileRead<>-1) or (fpgeterrno<>ESysEINTR);
end; end;
Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint; Function FileWrite (Handle : Longint; const Buffer; Count : Longint) : Longint;
begin begin
FileWrite:=fpWrite (Handle,Buffer,Count); repeat
FileWrite:=fpWrite (Handle,Buffer,Count);
until (FileWrite<>-1) or (fpgeterrno<>ESysEINTR);
end; end;
@ -297,19 +313,28 @@ end;
Procedure FileClose (Handle : Longint); Procedure FileClose (Handle : Longint);
var
res: cint;
begin begin
fpclose(Handle); repeat
res:=fpclose(Handle);
until (res<>-1) or (fpgeterrno<>ESysEINTR);
end; end;
Function FileTruncate (Handle: THandle; Size: Int64) : boolean; Function FileTruncate (Handle: THandle; Size: Int64) : boolean;
var
res: cint;
begin begin
if (SizeOf (TOff) < 8) (* fpFTruncate only supporting signed 32-bit size *) if (SizeOf (TOff) < 8) (* fpFTruncate only supporting signed 32-bit size *)
and (Size > high (longint)) then and (Size > high (longint)) then
FileTruncate := false FileTruncate := false
else else
FileTruncate:=fpftruncate(Handle,Size)>=0; begin
repeat
res:=fpftruncate(Handle,Size);
until (res<>-1) or (fpgeterrno<>ESysEINTR);
FileTruncate:=res>=0;
end;
end; end;
{$ifndef FPUNONE} {$ifndef FPUNONE}
@ -1047,11 +1072,14 @@ procedure Sleep(milliseconds: Cardinal);
Var Var
timeout,timeoutresult : TTimespec; timeout,timeoutresult : TTimespec;
res: cint;
begin begin
timeout.tv_sec:=milliseconds div 1000; timeout.tv_sec:=milliseconds div 1000;
timeout.tv_nsec:=1000*1000*(milliseconds mod 1000); timeout.tv_nsec:=1000*1000*(milliseconds mod 1000);
fpnanosleep(@timeout,@timeoutresult); repeat
res:=fpnanosleep(@timeout,@timeoutresult);
timeout:=timeoutresult;
until (res<>-1) or (fpgeterrno<>ESysEINTR);
end; end;
Function GetLastOSError : Integer; Function GetLastOSError : Integer;