File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -2092,7 +2092,7 @@ func (s *S) TestDoNotFallbackToMonotonic(c *C) {
20922092
20932093func (s * S ) TestConnectServerFailed (c * C ) {
20942094 dials := int32 (0 )
2095- maxDials := 100
2095+ maxDials := 50
20962096 info := & mgo.DialInfo {
20972097 Addrs : []string {"localhost:40001" },
20982098 DialServer : func (addr * mgo.ServerAddr ) (net.Conn , error ) {
@@ -2112,16 +2112,18 @@ func (s *S) TestConnectServerFailed(c *C) {
21122112
21132113 errs := make (chan error , 1 )
21142114 var done int32
2115- var wg sync.WaitGroup
2115+ var finished sync.WaitGroup
2116+ var starting sync.WaitGroup
21162117 defer func () {
21172118 atomic .StoreInt32 (& done , 1 )
2118- wg .Wait ()
2119+ finished .Wait ()
21192120 }()
21202121 for i := 0 ; i < maxDials ; i ++ {
2121- wg .Add (1 )
2122+ finished .Add (1 )
2123+ starting .Add (1 )
21222124 go func (s0 * mgo.Session ) {
2123- defer wg .Done ()
2124- for {
2125+ defer finished .Done ()
2126+ for i := 0 ; ; i ++ {
21252127 if atomic .LoadInt32 (& done ) == 1 {
21262128 break
21272129 }
@@ -2139,10 +2141,14 @@ func (s *S) TestConnectServerFailed(c *C) {
21392141 default :
21402142 }
21412143 }
2144+ if i == 0 {
2145+ starting .Done ()
2146+ }
21422147 }
21432148 }(session )
21442149 time .Sleep (10 * time .Millisecond )
21452150 }
2151+ starting .Wait ()
21462152
21472153 // no errors expect.
21482154 var opErr error
You can’t perform that action at this time.
0 commit comments