Przeglądaj źródła

* only return an error if locking a file fails when the file is already
locked, but not when another error occurs (such as EsysNOLCK, because
this error may always be returned if the kernel doesn't support
locking, in which case programs such as fpcmake no longer work on
such systems)

git-svn-id: trunk@14350 -

Jonas Maebe 15 lat temu
rodzic
commit
722d48c8c2
1 zmienionych plików z 8 dodań i 1 usunięć
  1. 8 1
      rtl/unix/sysutils.pp

+ 8 - 1
rtl/unix/sysutils.pp

@@ -343,6 +343,7 @@ var
   lockop: cint;
   lockop: cint;
   lockres: cint;
   lockres: cint;
   closeres: cint;
   closeres: cint;
+  lockerr: cint;
 begin
 begin
   DoFileLocking:=Handle;
   DoFileLocking:=Handle;
 {$ifdef beos}
 {$ifdef beos}
@@ -392,7 +393,13 @@ begin
         lockres:=fpflock(Handle,lockop);
         lockres:=fpflock(Handle,lockop);
       until (lockres=0) or
       until (lockres=0) or
             (fpgeterrno<>ESysEIntr);
             (fpgeterrno<>ESysEIntr);
-      if (lockres<>0) then
+      lockerr:=fpgeterrno;
+      { Only return an error if locks are working and the file was already
+        locked. Not if locks are simply unsupported (e.g., on Angstrom Linux
+        you always get ESysNOLCK in the default configuration) }
+      if (lockres<>0) and
+         ((lockerr=ESysEAGAIN) or
+          (lockerr=EsysEDEADLK)) then
         begin
         begin
           repeat
           repeat
             closeres:=FpClose(Handle);
             closeres:=FpClose(Handle);