Index: trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 20965)
+++ trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 20972)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004-2008  Joshua Hoblitt
 #
-# $Id: Server.pm,v 1.94 2008-12-12 21:13:41 jhoblitt Exp $
+# $Id: Server.pm,v 1.95 2008-12-13 00:41:15 jhoblitt Exp $
 
 package Nebulous::Server;
@@ -38,4 +38,12 @@
     my $config = Nebulous::Server::Config->new( @_ );
 
+    return $class->new_from_config($config);
+}
+
+
+sub new_from_config
+{
+    my ($class, $config) = @_;
+
     # log4perl is not avaliable until we call init()
     Nebulous::Server::Log->init($config);
@@ -52,8 +60,7 @@
 
     $log->debug( "leaving" );
-    
+
     return $self;
 }
-
 
 sub db
@@ -68,5 +75,7 @@
     if (defined $key) {
         # hash the key to select the correct database instance
-        $db_index = unpack("%20h", sha1_hex("$key")) % $config->n_db;
+        # only use the first 8 hex chars... have to be careful to avoid an int
+        # overflow here
+        $db_index = unpack("h8", sha1_hex("$key")) % $config->n_db;
     }
 
