mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Fix missing capture of remoteID in removeClient
This needed to be captured under the client lock. Adding a test that captured the races (when running enough times).
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"net"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -611,3 +612,47 @@ func TestAutoUnsubPropagation(t *testing.T) {
|
||||
|
||||
routeExpect(unsubnomaxRe)
|
||||
}
|
||||
|
||||
type ignoreLogger struct {
|
||||
}
|
||||
|
||||
func (l *ignoreLogger) Fatalf(f string, args ...interface{}) {
|
||||
}
|
||||
func (l *ignoreLogger) Errorf(f string, args ...interface{}) {
|
||||
}
|
||||
|
||||
func TestRouteConnectOnShutdownRace(t *testing.T) {
|
||||
s, opts := runRouteServer(t)
|
||||
defer s.Shutdown()
|
||||
|
||||
l := &ignoreLogger{}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
cQuit := make(chan bool, 1)
|
||||
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for {
|
||||
route := createRouteConn(l, opts.ClusterHost, opts.ClusterPort)
|
||||
if route != nil {
|
||||
setupRouteEx(l, route, opts, "ROUTE:4222")
|
||||
route.Close()
|
||||
}
|
||||
select {
|
||||
case <-cQuit:
|
||||
return
|
||||
default:
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
s.Shutdown()
|
||||
|
||||
cQuit <- true
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user