Browse files

First pass at connected fix

  • Loading branch information...
1 parent 791da95 commit f505b901f5d1b59456f35ad71a704dfe45c68601 @calvinfo calvinfo committed Oct 1, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/pool.js
View
19 lib/pool.js
@@ -80,20 +80,23 @@ Pool.prototype.connect = function(callback){
self.dead.push(host);
} else {
connected += 1;
- self.clients.push(connection);
- }
- if(finished === len){
- //set the keyspaces connection to be the pool
if(keyspace){
keyspace.connection = self;
}
- //we only want to callback once, after we get the final connection
- if(self.clients.length === 0){
- replyNotAvailable(callback);
- } else {
+ self.clients.push(connection);
+
+ // Callback on the first good client.
+ if(connected === 1){
callback(null, keyspace);
}
+ }
+
+ if(finished === len){
+ // if there are no clients, we haven't called back and are not available
+ if(connected === 0){
+ replyNotAvailable(callback);
+ }
//now that we have a connection, lets start monitoring
self.monitorConnections();
}

0 comments on commit f505b90

Please sign in to comment.