* hopefully final fix to unix locking: specifying no locking mode again

means "exclusive lock" where supported (not on Solaris when opening
    a file in read-only mode)

git-svn-id: trunk@12675 -
This commit is contained in:
Jonas Maebe 2009-02-03 13:34:56 +00:00
parent adaae268ae
commit 6581c8dec5

View File

@ -185,12 +185,26 @@ begin
{$ifndef beos}
if (Handle>=0) then
begin
case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead)) of
{$ifdef solaris}
{ Solaris' flock is based on top of fcntl, which does not allow
exclusive locks for files only opened for reading nor shared
locks for files opened only for writing
}
if ((mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead)) = 0) then
begin
mode := mode and not(fmShareCompat);
if ((mode and (fmOpenRead or fmOpenWrite or fmOpenReadWrite)) = fmOpenWrite) then
mode := mode or fmShareExclusive
else
mode := mode or fmShareDenyWrite;
end;
{$endif solaris}
case (mode and (fmShareCompat or fmShareExclusive or fmShareDenyWrite or fmShareDenyRead or fmShareDenyNone)) of
fmShareCompat,
fmShareExclusive:
lockop:=LOCK_EX or LOCK_NB;
fmShareDenyWrite:
lockop:=LOCK_SH or LOCK_NB;
fmShareCompat,
fmShareDenyNone:
exit;
else