[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] Flock Locking over NFS
****** message to minivend-users from Mike Heins <mikeh@minivend.com> ******
Quoting Kevin Walsh (kevin@cursor-software.co.uk):
>
> MiniVend currently uses flock to lock its files but flock is not
> supported on Linux when locking files over NFS.
Hmm. My understanding is that Perl uses fcntl when locking NFS file
systems; I have done some fairly heavy lock testing on NFS-mounted
systems to verify this.
>
> The following patch adds a fcntl locking mechanism that is
> supported on Linux/NFS. Perhaps someone other than us will find
> it useful when setting up a MiniVend farm with a shared session
> database.
I will look into this; as well as a mechanism for selecting it. I am
not sure it can be done on a catalog-by-catalog basis, but it certainly
could be selected in minivend.cfg.
Thanks for the contribution!
>
> The patch is for lib/Vend/Util.pm (MV 4.04).
>
> -------------------CUT HERE-----------------------------
> 908a909,944
> > ### fcntl locking
> >
> > sub fcntl_lock {
> > my ($fh, $excl, $wait) = @_;
> > my $flag = $excl ? F_WRLCK : F_RDLCK;
> > my $buf = pack("ssLL",$flag,0,0,0);
> >
> > LOCKLOOP:{
> > if ($wait) {
> > if (! fcntl($fh, F_SETLKW, $buf)) {
> > redo LOCKLOOP if $! =~ m/^Interrupted/;
> > die "Could not lock file: $!\n";
> > }
> > }
> > else {
> > if (! fcntl($fh, F_SETLK, $buf)) {
> > redo LOCKLOOP if $! =~ m/^Interrupted/;
> > if ($! =~ m/^Try again/
> > or $! =~ m/^Resource temporarily unavailable/
> > or $! =~ m/^Operation would block/) {
> > return 0;
> > }
> > die "Could not lock file: $!\n";
> > }
> > }
> > return 1;
> > }
> > }
> >
> > sub fcntl_unlock {
> > my ($fh) = @_;
> > my $buf = pack("ssLL",F_WRLCK,0,0,0);
> > fcntl($fh, F_UNLCK, $buf) or die "Could not unlock file: $!\n";
> > }
> >
> >
> 917c953
> < $use = 'flock';
> ---
> > $use = 'fcntl';
> 926a963,966
> > }
> > elsif ($use eq 'fcntl') {
> > $lock_function = \&fcntl_lock;
> > $unlock_function = \&fcntl_unlock;
> -------------------CUT HERE-----------------------------
>
--
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>
Research is what I'm doing when I don't know what I'm doing.
-- Wernher Von Braun
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list