[siesta-commit] siesta/lib/Siesta/Storage DBI.pm,1.20,1.21

[prev] [thread] [next] [lurker] [Date index for 2002/09/10]

From: clampr
Subject: [siesta-commit] siesta/lib/Siesta/Storage DBI.pm,1.20,1.21
Date: 20:30 on 10 Sep 2002
Update of /cvsroot/siesta/siesta/lib/Siesta/Storage
In directory usw-pr-cvs1:/tmp/cvs-serv7783

Modified Files:
	DBI.pm 
Log Message:
add busy wait on SQLite


Index: DBI.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Storage/DBI.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- DBI.pm	10 Sep 2002 19:08:15 -0000	1.20
+++ DBI.pm	10 Sep 2002 19:30:00 -0000	1.21
@@ -10,6 +10,14 @@
 sub new {
     my $class = shift;
     my $dbh   = DBI->connect(@_);
+
+    unless ($dbh) { # busy wait for SQLite
+        for (1..10) {
+            sleep 2;
+            $dbh = DBI->connect(@_)
+              and last;
+        }
+    }
     return unless $dbh;
     bless { _dbh => $dbh }, $class;
 }
@@ -21,8 +29,7 @@
     my %where   = %{ $args{where} || {} };
     my @columns = @{ $args{columns} };
 
-    my $sql =
-      join ( '', "SELECT ", join ( ', ', @columns ), " FROM ", $args{table}, );
+    my $sql = "SELECT ". join ( ', ', @columns ) ." FROM $args{table}" );
 
     $sql .= join ( '',
                    " WHERE ",
@@ -39,10 +46,11 @@
 sub get_lists {
     my $self = shift;
 
-    return map { Siesta::List->new_from_hash(%$_) } $self->_get_rows(
-                                               table   => 'lists',
-                                               columns => \@Siesta::List::fields
-                                               );
+    map { Siesta::List->new_from_hash(%$_) }
+      $self->_get_rows(
+                       table   => 'lists',
+                       columns => \@Siesta::List::fields
+                      );
 }
 
 sub get_users {



Generated at 13:57 on 01 Jul 2004 by mariachi 0.52