Jelajahi Sumber

Fix: psiphond startup failure race condition

tunnelServer.Run may be invoked and fail before the main loop is ready to
consume errorChannel. In this case, the error delivered to errorChannel will
be dropped. And psiphond will not log the error and continue running.

The fix is to buffer errorChannel so at least one error can be sent even when
the main loop is not actively receiving from errorChannel.
Rod Hynes 6 tahun lalu
induk
melakukan
ce92801130
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      psiphon/server/services.go

+ 1 - 1
psiphon/server/services.go

@@ -71,7 +71,7 @@ func RunServices(configJSON []byte) error {
 
 	waitGroup := new(sync.WaitGroup)
 	shutdownBroadcast := make(chan struct{})
-	errorChannel := make(chan error)
+	errorChannel := make(chan error, 1)
 
 	tunnelServer, err := NewTunnelServer(supportServices, shutdownBroadcast)
 	if err != nil {