Commit a5b54a7 1 parent e1e3be8 commit a5b54a7 Copy full SHA for a5b54a7
File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ class DialRequest {
45
45
const th = new FIFO ( )
46
46
tokens . forEach ( t => th . push ( t ) )
47
47
const dialAbortControllers = this . addrs . map ( ( ) => new AbortController ( ) )
48
+ let completedDials = 0
48
49
49
50
try {
50
51
return await pAny ( this . addrs . map ( async ( addr , i ) => {
@@ -56,9 +57,17 @@ class DialRequest {
56
57
// Remove the successful AbortController so it is no aborted
57
58
dialAbortControllers . splice ( i , 1 )
58
59
} catch ( err ) {
59
- th . push ( token ) // return to token holder on error so another ma can be attempted
60
60
throw err
61
+ } finally {
62
+ completedDials ++
63
+ // If we have more dials to make, recycle the token, otherwise release it
64
+ if ( completedDials < this . addrs . length ) {
65
+ th . push ( token )
66
+ } else {
67
+ this . dialer . releaseToken ( tokens . splice ( tokens . indexOf ( token ) , 1 ) [ 0 ] )
68
+ }
61
69
}
70
+
62
71
return conn
63
72
} ) )
64
73
} finally {
You can’t perform that action at this time.
0 commit comments