Remove update of start in readLoop

That broke sending async INFO in case where there was an update
between accepting the tcp connection and receiving the CONNECT
that indicates that client can receive async INFO.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2020-05-22 18:40:46 -06:00
committed by Derek Collison
parent a693b677c6
commit f76f0df5ce
2 changed files with 6 additions and 4 deletions

View File

@@ -894,10 +894,7 @@ func (c *client) readLoop() {
// Check the per-account-cache for closed subscriptions
cpacc := c.kind == ROUTER || c.kind == GATEWAY
// Last per-account-cache check for closed subscriptions
now := time.Now()
lpacc := now
// Update our notion of when we started. Useful for better initial RTT estimation.
c.start = now
lpacc := time.Now()
c.mu.Unlock()
defer func() {

View File

@@ -753,6 +753,7 @@ func wait(ch chan bool) error {
func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
s1Opts := DefaultOptions()
s1Opts.ServerName = "A"
s1Opts.Host = "127.0.0.1"
s1Opts.Port = 4222
s1Opts.Cluster.Host = "127.0.0.1"
@@ -771,6 +772,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
chch <- true
}
nc, err := nats.Connect(s1Url,
nats.ReconnectWait(50*time.Millisecond),
nats.ReconnectHandler(connHandler),
nats.DiscoveredServersHandler(func(_ *nats.Conn) {
ch <- true
@@ -780,6 +782,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
}
s2Opts := DefaultOptions()
s2Opts.ServerName = "B"
s2Opts.Host = "127.0.0.1"
s2Opts.Port = s1Opts.Port + 1
s2Opts.Cluster.Host = "127.0.0.1"
@@ -794,6 +797,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
}
checkPool := func(expected []string) {
t.Helper()
// Don't use discovered here, but Servers to have the full list.
// Also, there may be cases where the mesh is not formed yet,
// so try again on failure.
@@ -822,6 +826,7 @@ func TestServerPoolUpdatedWhenRouteGoesAway(t *testing.T) {
checkPool([]string{s1Url, s2Url})
s3Opts := DefaultOptions()
s3Opts.ServerName = "C"
s3Opts.Host = "127.0.0.1"
s3Opts.Port = s2Opts.Port + 1
s3Opts.Cluster.Host = "127.0.0.1"