Skip to content

Commit

Permalink
handle dropped connections better JAVA-140
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Jul 29, 2010
1 parent 3a4449e commit 57c73bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/main/com/mongodb/DBPortPool.java
Expand Up @@ -166,7 +166,22 @@ void gotError( Exception e ){
return;
}
Bytes.LOGGER.log( Level.INFO , "emptying DBPortPool b/c of error" , e );
clear();

// force close all sockets

List<DBPort> all = new ArrayList<DBPort>();
while ( true ){
DBPort temp = get(0);
if ( temp == null )
break;
all.add( temp );
}

for ( DBPort p : all ){
p.close();
done(p);
}

}

void close(){
Expand Down
10 changes: 8 additions & 2 deletions src/main/com/mongodb/DBTCPConnector.java
Expand Up @@ -285,11 +285,17 @@ void done( DBPort p ){
}

void error( Exception e ){
_curPortPool.remove( _port );
if ( _last == null )
throw new IllegalStateException( "this should be impossible" );

_curPortPool.gotError( e );

_internalStack = 0;
_curPortPool.done( _last );
_last.close();

_last = null;
_port = null;
_internalStack = 0;
}

void requestEnsureConnection(){
Expand Down

0 comments on commit 57c73bf

Please sign in to comment.