Index: trunk/Nebulous-Server/bin/nebdiskd
===================================================================
--- trunk/Nebulous-Server/bin/nebdiskd	(revision 20164)
+++ trunk/Nebulous-Server/bin/nebdiskd	(revision 20167)
@@ -3,5 +3,5 @@
 # Copyright (C) 2007  Joshua Hoblitt
 # 
-# $Id: nebdiskd,v 1.12 2008-10-14 02:56:30 jhoblitt Exp $
+# $Id: nebdiskd,v 1.13 2008-10-15 03:01:19 jhoblitt Exp $
 
 use strict;
@@ -93,13 +93,24 @@
 $SIG{HUP}  = sub { $c = read_rcfile($rcfile) }; 
 
-
-poll_mounts(
-        db              => $db,
-        dbhost          => $dbhost,
-        dbuser          => $dbuser,
-        dbpass          => $dbpass,
-        poll_interval   => $poll_interval,
-        debug           => $debug,
-) or die "poll_mounts() should not have returned";
+while (1) {
+    eval {
+        poll_mounts(
+                db              => $db,
+                dbhost          => $dbhost,
+                dbuser          => $dbuser,
+                dbpass          => $dbpass,
+                poll_interval   => $poll_interval,
+                debug           => $debug,
+        ) or die "poll_mounts() should not have returned";
+    };
+    if ($!) {
+        warn $@;
+    }
+
+    sleep $poll_interval;
+}
+
+die "poll loop exited -- THIS SHOULD NOT HAPPEN";
+
 
 sub poll_mounts
@@ -114,59 +125,55 @@
     my $debug           = $p{debug} || 0;
 
-    while (1) {
-        # setup the db on every pass incase the database died on us
-        my $dbh = setup_db(
-            db      => $db,
-            dbhost  => $dbhost,
-            dbuser  => $dbuser,
-            dbpass  => $dbpass,
-        );
-
-        eval {
-            my $r_query = $dbh->prepare_cached("REPLACE INTO mount VALUES(?, ?, ?)");
-            my $d_query = $dbh->prepare_cached("DELETE FROM mount WHERE mountpoint = ?");
-
-            # determine valid mountpoints
-            foreach my $mnt (@$mounts) {
-                print "checking $mnt\n" if $debug;
-                # this /SHOULD/ fail if the mount point is handled by the
-                # automounter and it fails to mount
-                eval {
-                    unless (is_mountpoint($mnt)) {
-                        die "$mnt is not a valid mountpoint\n";
-                    }
-                };
-                if ($@) {
-                    print $@ if $debug;
-                    $d_query->execute($mnt);
-                    next;
+    # setup the db on every pass incase the database died on us
+    my $dbh = setup_db(
+        db      => $db,
+        dbhost  => $dbhost,
+        dbuser  => $dbuser,
+        dbpass  => $dbpass,
+    );
+
+    eval {
+        my $r_query = $dbh->prepare_cached("REPLACE INTO mount VALUES(?, ?, ?)");
+        my $d_query = $dbh->prepare_cached("DELETE FROM mount WHERE mountpoint = ?");
+
+        # determine valid mountpoints
+        foreach my $mnt (@$mounts) {
+            print "checking $mnt\n" if $debug;
+            # this /SHOULD/ fail if the mount point is handled by the
+            # automounter and it fails to mount
+            eval {
+                unless (is_mountpoint($mnt)) {
+                    die "$mnt is not a valid mountpoint\n";
                 }
-
-                # fetch stats on the mounted device.  this has to be done AFTER
-                # we determine if it's a valid mountpoint incase
-                # is_mountpoint() invokes the automounter
-                my $dev_info = df($mnt, 1024);
-                unless (defined $dev_info) {
-                    print "can't find device info for $mnt\n" if $debug;
-                    next;
-                }
-
-                $r_query->execute($mnt, @$dev_info{qw( blocks used )});
-                print "adding $mnt to db\n" if $debug;
-
+            };
+            if ($@) {
+                print $@ if $debug;
+                $d_query->execute($mnt);
+                next;
             }
 
-            $dbh->do("call getmountedvol()");
-
-            $dbh->commit;
-            print "commited to database\n" if $debug;
-        };
-        if ($@) {
-            $dbh->rollback;
-            print "rolledback transaction\n" if $debug;
-            warn $@;
+            # fetch stats on the mounted device.  this has to be done AFTER
+            # we determine if it's a valid mountpoint incase
+            # is_mountpoint() invokes the automounter
+            my $dev_info = df($mnt, 1024);
+            unless (defined $dev_info) {
+                print "can't find device info for $mnt\n" if $debug;
+                next;
+            }
+
+            $r_query->execute($mnt, @$dev_info{qw( blocks used )});
+            print "adding $mnt to db\n" if $debug;
+
         }
 
-        sleep $poll_interval;
+        $dbh->do("call getmountedvol()");
+
+        $dbh->commit;
+        print "commited to database\n" if $debug;
+    };
+    if ($@) {
+        $dbh->rollback;
+        print "rolledback transaction\n" if $debug;
+        warn $@;
     }
 }
