On 03 May 2009, at 14:51, Jonas Maebe wrote:

On 03 May 2009, at 14:09, ajv wrote:

With Region Do                         Begin
  l_type  := F_WRLCK; l_whence := SEEK_SET;
  l_start := 10;      l_len    := 20
End;
If FpFcntl (F, F_SETLK, Region) = -1 Then
  WriteLn ('unable to apply writelock');   //  <-- OK
Sleep (20000);                              // Sleep 20 Sec
FpClose (F);
End.
--------------------------------------------------------------------------------------
Then within 20 seconds i start test to obtain a readlock on 80.
This fails. Why? What am I doing wrong?

Your test works fine under Solaris. It's a bug somewhere in the FPC Linux units. strace shows this for your first program:

fcntl(3, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=10, len=0}) = 0

As you can see, "len=0" is passed to the system call (instead of len=20), so it locks the entire file. That's the reason why the other program is unable to lock anything else.

It's similar to http://bugs.freepascal.org/view.php?id=13363 : the kernel's off_t is 32 bit on 32 bit systems. It's defined as 64 bit in the Linux rtl for all platforms.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to