File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
test/integration/connection-pool Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -19,15 +19,23 @@ util.inherits(PG, EventEmitter);
1919
2020PG . prototype . end = function ( ) {
2121 var self = this ;
22- Object . keys ( self . pools . all ) . forEach ( function ( key ) {
22+ var keys = Object . keys ( self . pools . all ) ;
23+ var count = keys . length ;
24+ keys . forEach ( function ( key ) {
2325 var pool = self . pools . all [ key ] ;
2426 delete self . pools . all [ key ] ;
2527 pool . drain ( function ( ) {
26- pool . destroyAllNow ( ) ;
28+ pool . destroyAllNow ( function ( ) {
29+ count -- ;
30+ if ( count === 0 ) {
31+ self . emit ( 'end' ) ;
32+ }
33+ } ) ;
2734 } ) ;
2835 } ) ;
2936} ;
3037
38+
3139PG . prototype . connect = function ( config , callback ) {
3240 if ( typeof config == "function" ) {
3341 callback = config ;
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ var called = false;
44test ( 'disconnects' , function ( ) {
55 var sink = new helper . Sink ( 4 , function ( ) {
66 called = true ;
7+ var eventSink = new helper . Sink ( 1 , function ( ) { } ) ;
8+ helper . pg . on ( 'end' , function ( ) {
9+ eventSink . add ( ) ;
10+ } ) ;
11+
712 //this should exit the process, killing each connection pool
813 helper . pg . end ( ) ;
914 } ) ;
You can’t perform that action at this time.
0 commit comments