summaryrefslogtreecommitdiff
path: root/FS/FS/nas.pm
diff options
context:
space:
mode:
authorivan <ivan>2001-04-15 13:35:12 +0000
committerivan <ivan>2001-04-15 13:35:12 +0000
commitfb13e429f8499f6eadad09c1452489ca0f4f7031 (patch)
tree768437065780d879ee9bf5bf818293ff833b58d1 /FS/FS/nas.pm
parent018f6678557506e68cc6b8643862143cc332f7da (diff)
transactions part deux
Diffstat (limited to 'FS/FS/nas.pm')
-rw-r--r--FS/FS/nas.pm23
1 files changed, 6 insertions, 17 deletions
diff --git a/FS/FS/nas.pm b/FS/FS/nas.pm
index 13d0fb8..cb0c1b9 100644
--- a/FS/FS/nas.pm
+++ b/FS/FS/nas.pm
@@ -3,7 +3,7 @@ package FS::nas;
use strict;
use vars qw( @ISA );
use FS::Record qw(qsearchs); #qsearch);
-use FS::UID qw( dbh ); #to lock the tables for heartbeat; ugh, MySQL-specific
+use FS::UID qw( dbh );
@ISA = qw(FS::Record);
@@ -126,31 +126,20 @@ Updates the timestamp for this nas
sub heartbeat {
my($self, $timestamp) = @_;
my $dbh = dbh;
- my $sth = $dbh->prepare("LOCK TABLES nas WRITE");
- $sth->execute or die $sth->errstr; #die?
- my $lock_self = qsearchs('nas', { 'nasnum' => $self->nasnum } )
- or die "can't find own record for $self nasnum ". $self->nasnum;
- if ( $timestamp > $lock_self->last ) {
- my $new_self = new FS::nas ( { $lock_self->hash } );
- $new_self->last($timestamp);
- #is there a reason to? #$self->last($timestamp);
- $new_self->replace($lock_self);
- };
- $sth = $dbh->prepare("UNLOCK TABLES");
- $sth->execute or die $sth->errstr; #die?
+ my $sth =
+ $dbh->prepare("UPDATE nas SET last = ? WHERE nasnum = ? AND last < ?");
+ $sth->execute($timestamp, $self->nasnum, $timestamp) or die $sth->errstr;
+ $self->last($timestamp);
}
=back
=head1 VERSION
-$Id: nas.pm,v 1.4 2001-02-21 01:45:37 ivan Exp $
+$Id: nas.pm,v 1.5 2001-04-15 13:35:12 ivan Exp $
=head1 BUGS
-The B<heartbeat> method is MySQL-specific. Yuck. It's also not quite
-perfectly subclassable, which is much less yuck.
-
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.