File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -106,19 +106,26 @@ private function pop(): \Generator {
106106 }
107107
108108 while ($ this ->idle ->isEmpty ()) { // While loop to ensure an idle connection is available after promises below are resolved.
109- try {
110- if ( $ this -> connections -> count () + $ this -> pending >= $ this -> getMaxConnections ()) {
111- // All possible connections busy, so wait until one becomes available.
109+ if ( $ this -> connections -> count () + $ this -> pending >= $ this -> getMaxConnections ()) {
110+ // All possible connections busy, so wait until one becomes available.
111+ try {
112112 $ this ->deferred = new Deferred ;
113113 yield $ this ->promise = $ this ->deferred ->promise (); // May be resolved with defunct connection.
114- } else {
115- // Max connection count has not been reached, so open another connection.
116- $ this ->promise = $ this ->createConnection ();
117- $ this ->addConnection (yield $ this ->promise );
114+ } finally {
115+ $ this ->deferred = null ;
116+ $ this ->promise = null ;
118117 }
119- } finally {
120- $ this ->deferred = null ;
121- $ this ->promise = null ;
118+ } else {
119+ // Max connection count has not been reached, so open another connection.
120+ ++$ this ->pending ;
121+ try {
122+ $ connection = yield $ this ->createConnection ();
123+ } finally {
124+ --$ this ->pending ;
125+ }
126+
127+ $ this ->connections ->attach ($ connection );
128+ return $ connection ;
122129 }
123130 }
124131
You can’t perform that action at this time.
0 commit comments