Преглед изворни кода

* if no locking is specified, also request an exclusive lock for solaris
in case the file is opened as read/write (instead of only if opened as
write-only)

git-svn-id: trunk@12685 -

Jonas Maebe пре 16 година
родитељ
комит
6f12cb03db
1 измењених фајлова са 9 додато и 5 уклоњено
  1. 9 5
      rtl/unix/sysutils.pp

+ 9 - 5
rtl/unix/sysutils.pp

@@ -188,15 +188,19 @@ begin
 {$ifdef solaris}
 {$ifdef solaris}
       { Solaris' flock is based on top of fcntl, which does not allow
       { Solaris' flock is based on top of fcntl, which does not allow
         exclusive locks for files only opened for reading nor shared
         exclusive locks for files only opened for reading nor shared
-        locks for files opened only for writing
+        locks for files opened only for writing.
+        
+        If no locking is specified, we normally need an exclusive lock.
+        So create an exclusive lock for fmOpenWrite and fmOpenReadWrite,
+        but only a shared lock for fmOpenRead (since an exclusive lock
+        is not possible in that case)
       }
       }
       if ((mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead or fmShareDenyNone)) = 0) then
       if ((mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead or fmShareDenyNone)) = 0) then
         begin
         begin
-          mode := mode and not(fmShareCompat);
-          if ((mode and (fmOpenRead or fmOpenWrite or fmOpenReadWrite)) = fmOpenWrite) then
-            mode := mode or fmShareExclusive
+          if ((mode and (fmOpenRead or fmOpenWrite or fmOpenReadWrite)) = fmOpenRead) then
+            mode := mode or fmShareDenyWrite
           else
           else
-            mode := mode or fmShareDenyWrite;
+            mode := mode or fmShareExclusive;
         end;
         end;
 {$endif solaris}
 {$endif solaris}
       case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead or fmShareDenyNone)) of
       case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead or fmShareDenyNone)) of