mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
Update LastActivity on connect for routes
Signed-off-by: Waldemar Quevedo <wally@nats.io>
This commit is contained in:
@@ -1905,6 +1905,9 @@ func (s *Server) addRoute(c *client, didSolicit bool, info *Info, accName string
|
||||
c.mu.Lock()
|
||||
idHash := c.route.idHash
|
||||
cid := c.cid
|
||||
if c.last.IsZero() {
|
||||
c.last = time.Now()
|
||||
}
|
||||
c.mu.Unlock()
|
||||
|
||||
// Store this route with key being the route id hash + account name
|
||||
@@ -1980,10 +1983,13 @@ func (s *Server) addRoute(c *client, didSolicit bool, info *Info, accName string
|
||||
rHash := c.route.hash
|
||||
rn := c.route.remoteName
|
||||
url := c.route.url
|
||||
// For solicited routes, we need now to send the INFO protocol
|
||||
// For solicited routes, we need now to send the INFO protocol.
|
||||
if didSolicit {
|
||||
c.enqueueProto(s.generateRouteInitialInfoJSON(_EMPTY_, c.route.compression, idx))
|
||||
}
|
||||
if c.last.IsZero() {
|
||||
c.last = time.Now()
|
||||
}
|
||||
c.mu.Unlock()
|
||||
|
||||
// Add to the slice and bump the count of connections for this remote
|
||||
|
||||
@@ -1153,7 +1153,18 @@ func TestRouteNoCrashOnAddingSubToRoute(t *testing.T) {
|
||||
defer rs.Shutdown()
|
||||
servers = append(servers, rs)
|
||||
|
||||
// Create a sub on each routed server
|
||||
// Confirm routes are active before clients connect.
|
||||
for _, srv := range servers {
|
||||
rz, err := srv.Routez(nil)
|
||||
require_NoError(t, err)
|
||||
for i, route := range rz.Routes {
|
||||
if route.LastActivity.IsZero() {
|
||||
t.Errorf("Expected LastActivity to be valid (%d)", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a sub on each routed server.
|
||||
nc := natsConnect(t, fmt.Sprintf("nats://%s:%d", ropts.Host, ropts.Port))
|
||||
defer nc.Close()
|
||||
natsSub(t, nc, "foo", cb)
|
||||
|
||||
Reference in New Issue
Block a user