Re: [LIP] problem with fcntl while locking file on NFS
Gaurav Varshney <gkvarshney-/[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
Binand,
I tried with "ssll" instead of "ssLL" but still
facing the same problem -
"INFO >> Could not lock file Invalid argument"
I am not sure about nfs server, but i am not dealing
with large files. BTW, i tried handling the EINVAL in
the same way as i am handling EINTR, but this ended
up in an infinite loop and process got hung (strace
showed it was in an infinite loop).
snip of the code that i had tried -
$buf = pack("ssLL", F_WRLCK ,0,0,0);
while (1)
{
unless (fcntl($fh, F_SETLKW, $buf))
{
next if ($! =~ /^Interrupted|Invalid/); # <---
note the change
$msg = "Could not lock file $!";
$err++;
last;
}
else
{
$msg = "File locked";
last;
}
}
- gaurav
[email protected] wrote:
>Gaurav Varshney posted in linux-india-programmers:
>
>>I am using fcntl for locking the file on linux
(flock
>>doesn't work properly on NFS), and facing problem.
>>Following code works most of the time but fails
>>sometime with the error message "Invalid argument"
>>(EINVAL). What could be the reason for this error
>>message and how it can be handled ?
>>
>>
>> $buf = pack("ssLL", F_WRLCK ,0,0,0);
>
>
>Shouldn't that be "ssll"? man fcntl seems to think
so.
>
>I think file locking over NFS is dicey, whatever the
locking method you
>use. Is your NFS server Linux too? Are you dealing
with big files (> 2GB)?
>
>Binand
>
Cheers,
Gaurav Varshney
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click