Index: branches/stable/cgi-bin/CustIDCK.pm
===================================================================
--- branches/stable/cgi-bin/CustIDCK.pm	(revision 112)
+++ branches/stable/cgi-bin/CustIDCK.pm	(revision 113)
@@ -32,5 +32,19 @@
 
 # some example code for a database check
-  my $dbh = DBI->connect ("DBI:Pg:host=billing;dbname=custids", "cidcheck", "c1dch4ck");
+  # Try to catch failures to connect.  If the remote server is up but
+  # not responding (this has HAPPENED) we need to break out rather than hanging.
+  eval {
+    local $SIG{ALRM} = sub { die "failed connection to billing!!" };
+    alarm 3;	# 3-second timeout.  This may be too aggressive.
+    my $dbh = DBI->connect ("DBI:Pg:host=billing;dbname=custids", "cidcheck", "c1dch4ck");
+    alarm 0;	# cancel the alarm
+  };
+  alarm 0;	# avoid race conditions.  May not be needed here.  (Hah!)
+  if ($@ && $@ !~ /failed connection to billing!!/) {
+    $CustIDCK::Error = 1;
+    $CustIDCK::ErrMsg = "Failed connection to billing DB host!  Unable to verify CustIDs.";
+    return 0;
+  }
+
   my $sth = $dbh->prepare("SELECT custid FROM custid WHERE custid = '$custid';");
   $sth->execute;
