Browse Source

Fixed: connectionQueue should be buffered so it can be filled immediately

Rod Hynes 11 years ago
parent
commit
9a8648aa25
1 changed files with 2 additions and 2 deletions
  1. 2 2
      psiphon/runTunnel.go

+ 2 - 2
psiphon/runTunnel.go

@@ -75,7 +75,7 @@ func runTunnel(config *Config) error {
 		candidateList = append(candidateList, &Tunnel{serverEntry: serverEntry})
 	}
 	waitGroup := new(sync.WaitGroup)
-	candidateQueue := make(chan *Tunnel)
+	candidateQueue := make(chan *Tunnel, len(candidateList))
 	firstEstablishedTunnel := make(chan *Tunnel, 1)
 	timeout := time.After(ESTABLISH_TUNNEL_TIMEOUT)
 	for i := 0; i < CONNECTION_WORKER_POOL_SIZE; i++ {
@@ -88,7 +88,7 @@ func runTunnel(config *Config) error {
 	close(candidateQueue)
 	var establishedTunnel *Tunnel
 	select {
-	case establishedTunnel := <-firstEstablishedTunnel:
+	case establishedTunnel = <-firstEstablishedTunnel:
 		defer establishedTunnel.Close()
 	case <-timeout:
 		return errors.New("timeout establishing tunnel")