Skip Menu |

This queue is for tickets about the File-SharedNFSLock CPAN distribution.

Report information
The Basics
Id: 81597
Status: resolved
Priority: 0/
Queue: File-SharedNFSLock

People
Owner: Nobody in particular
Requestors: florent.angly [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.03
Fixed in: (no value)



Subject: [Patch] Support for threads
Hi Steffen, I have been trying to use File::SharedNFSLock for a script that uses threads. Unfortunately, I found that the module did not work as expected. But after some debugging, I found out that it simply different perl threads as the same entity. I created a patch for this (attached. the important lines are 252-253, the rest is trivial stuff). After applying the patch, the module seems to work as expected on my Linux, non-NFS box. On an unrelated note, it seems like hard links are not supported on Windows (https://rt.cpan.org/Public/Bug/Display.html?id=33932). That means that the module is ineffective on Windows, correct? That would be good to document it if that's the case. Is there any solution to make the module truly cross-platform? Thanks for the good work, Florent
Subject: thread_patch.diff
132c132,133 < ."Time out for stale locks: $self->{timeout_stale}"; --- > ."Time out for stale locks: $self->{timeout_stale}\n" > ."Poll interval : $self->{poll_interval}\n"; 147c148 < warn "Getting lock on " . $self->{file} if DEBUG; --- > warn "Getting lock on ".$self->{file}."\n" if DEBUG; 150c151 < warn "It's not locked already... " . $self->{file} if DEBUG; --- > warn "It is locked already... ".$self->{file}."\n" if DEBUG; 152a154 > warn "Before time is $before_time\n" if DEBUG; 154,155c156 < my $got_lock = $self->_write_lock_file(); < if ($got_lock) { --- > if ($self->_write_lock_file()) { 157,158c158 < } < else { --- > } else { 160,165c160,163 < my $stale = $self->_is_stale_lock; < if ($stale) { < unlink($self->_lock_file); < unlink($self->_unique_lock_file); < } < else { --- > if ($self->_is_stale_lock) { > unlink $self->_lock_file; > unlink $self->_unique_lock_file; > } else { 167a166 > warn "Time now is $now\n" if DEBUG; 205c204 < warn "locked: LOCKED with " . $self->_unique_lock_file if DEBUG; --- > warn "locked: LOCKED with ".$self->_unique_lock_file."\n" if DEBUG; 209c208 < warn "locked: NOT LOCKED with " . $self->_unique_lock_file if DEBUG; --- > warn "locked: NOT LOCKED with ".$self->_unique_lock_file."\n" if DEBUG; 222c221 < warn "_unlink_lock_file: locked, removing main lock file" if DEBUG; --- > warn "_unlink_lock_file: locked, removing main lock file\n" if DEBUG; 225c224 < warn "_unlink_lock_file: removing unique lock file" if DEBUG; --- > warn "_unlink_lock_file: removing unique lock file\n" if DEBUG; 243c242 < warn "_write_lock_file: HAVE LOCK!" if DEBUG; --- > warn "_write_lock_file: HAVE LOCK!\n" if DEBUG; 253c252,253 < my $unique_lock_file = "$lock_file." . $self->{hostname} . ".$$." . $self->{token}; --- > my $thread_id = exists $INC{'threads.pm'} ? threads->tid : ''; > my $unique_lock_file = "$lock_file." . $self->{hostname} . ".$$.$thread_id." . $self->{token};
I have tested some code on a FAT32 USB stick so see how the module behaved (race condition? crash?). It seems like it hangs... My interpretation is that it tries to lock, but never succeeds. It would be nice to have a workaround for this filesystem, even if it not perfect. I know you have many modules and too little time, Steffen. If that's something you want, I am happy to co-maintain the module in order to improve it. Best, Florent
Subject: Re: [rt.cpan.org #81597] [Patch] Support for threads
Date: Mon, 03 Dec 2012 19:57:50 +0100
To: bug-File-SharedNFSLock [...] rt.cpan.org
From: Steffen Mueller <smueller [...] cpan.org>
On 12/03/2012 03:31 AM, Florent Angly via RT wrote: Show quoted text
> Queue: File-SharedNFSLock > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=81597 > > > I have tested some code on a FAT32 USB stick so see how the module > behaved (race condition? crash?). It seems like it hangs... My > interpretation is that it tries to lock, but never succeeds. > > It would be nice to have a workaround for this filesystem, even if it > not perfect. > > I know you have many modules and too little time, Steffen. If that's > something you want, I am happy to co-maintain the module in order to > improve it.
You know what? That sounds like an excellent idea. I've been seeing your valuable input and telling myself "tomorrow morning on the commute to work, I'll do something about this" and then there's a fire to put out or I'm too tired. I just assigned primary maintainer status to you (I retain co-maint) so that if the need arises, you can also make other co-maintainer. As for some of the other tickets you filed: - locked() is indeed a bit of a misnomer. Please don't rename it, but add an alias and document clearly. - As for shared/exclusive locking, please have a look at how the locking works (the trick with links). I'm not sure that you can emulate both kinds of lock. - As for FAT32, please keep in mind that this is called "SharedNFSLock"... I think you'll have to document this as a limitation. I think FAT32 doesn't support the locking technique (the hard links). Since you can't really reliable/portably tell which file system you're running on, that's kind of a deal breaker. Best regards, Steffen
Thank you very much for this, Steffen. SharedNFSLock did not appear to have a repository I started one on Github (https://github.com/fangly/file-sharednfslock). If you'd rather have it under your name, let me know and we'll transfer it. I applied the patch to support threads, so, I'll close this ticket. Florent