Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use monotonic time for measuring time internally #4154

Merged
merged 1 commit into from May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/accounts.go
Expand Up @@ -3502,7 +3502,7 @@ func (s *Server) updateAccountClaimsWithRefresh(a *Account, ac *jwt.AccountClaim
a.jsLimits = nil
}

a.updated = time.Now().UTC()
a.updated = time.Now()
clients := a.getClientsLocked()
a.mu.Unlock()

Expand Down Expand Up @@ -3961,7 +3961,7 @@ func removeCb(s *Server, pubKey string) {
a.mpay = 0
a.mconns = 0
a.mleafs = 0
a.updated = time.Now().UTC()
a.updated = time.Now()
jsa := a.js
a.mu.Unlock()
// set the account to be expired and disconnect clients
Expand Down
2 changes: 1 addition & 1 deletion server/gateway.go
Expand Up @@ -761,7 +761,7 @@ func (s *Server) createGateway(cfg *gatewayCfg, url *url.URL, conn net.Conn) {
// Snapshot server options.
opts := s.getOpts()

now := time.Now().UTC()
now := time.Now()
c := &client{srv: s, nc: conn, start: now, last: now, kind: GATEWAY}

// Are we creating the gateway based on the configuration
Expand Down
6 changes: 3 additions & 3 deletions server/monitor.go
Expand Up @@ -783,7 +783,7 @@ type RouteInfo struct {
// Routez returns a Routez struct containing information about routes.
func (s *Server) Routez(routezOpts *RoutezOptions) (*Routez, error) {
rs := &Routez{Routes: []*RouteInfo{}}
rs.Now = time.Now().UTC()
rs.Now = time.Now()

if routezOpts == nil {
routezOpts = &RoutezOptions{}
Expand Down Expand Up @@ -970,7 +970,7 @@ func (s *Server) Subsz(opts *SubszOptions) (*Subsz, error) {
slStats := &SublistStats{}

// FIXME(dlc) - Make account aware.
sz := &Subsz{s.info.ID, time.Now().UTC(), slStats, 0, offset, limit, nil}
sz := &Subsz{s.info.ID, time.Now(), slStats, 0, offset, limit, nil}

if subdetail {
var raw [4096]*subscription
Expand Down Expand Up @@ -1595,7 +1595,7 @@ func (s *Server) updateVarzConfigReloadableFields(v *Varz) {
v.MaxPending = opts.MaxPending
v.TLSTimeout = opts.TLSTimeout
v.WriteDeadline = opts.WriteDeadline
v.ConfigLoadTime = s.configTime
v.ConfigLoadTime = s.configTime.UTC()
// Update route URLs if applicable
if s.varzUpdateRouteURLs {
v.Cluster.URLs = urlsToStrings(opts.Routes)
Expand Down
2 changes: 1 addition & 1 deletion server/mqtt.go
Expand Up @@ -422,7 +422,7 @@ func (s *Server) createMQTTClient(conn net.Conn, ws *websocket) *client {
if maxSubs == 0 {
maxSubs = -1
}
now := time.Now().UTC()
now := time.Now()

c := &client{srv: s, nc: conn, mpay: maxPay, msubs: maxSubs, start: now, last: now, mqtt: &mqtt{}, ws: ws}
c.headers = true
Expand Down
12 changes: 6 additions & 6 deletions server/server.go
Expand Up @@ -373,7 +373,7 @@ func NewServer(opts *Options) (*Server, error) {
info.TLSAvailable = true
}

now := time.Now().UTC()
now := time.Now()

s := &Server{
kp: kp,
Expand Down Expand Up @@ -884,7 +884,7 @@ func (s *Server) configureAccounts(reloading bool) (map[string]struct{}, error)
s.mu.Lock()
acc.mu.Lock()
}
acc.updated = time.Now().UTC()
acc.updated = time.Now()
acc.mu.Unlock()
return true
})
Expand Down Expand Up @@ -1383,7 +1383,7 @@ func (s *Server) createInternalClient(kind int) *client {
if kind != SYSTEM && kind != JETSTREAM && kind != ACCOUNT {
return nil
}
now := time.Now().UTC()
now := time.Now()
c := &client{srv: s, kind: kind, opts: internalOpts, msubs: -1, mpay: -1, start: now, last: now}
c.initClient()
c.echo = false
Expand Down Expand Up @@ -1453,7 +1453,7 @@ func (s *Server) registerAccountNoLock(acc *Account) *Account {
acc.lqws = make(map[string]int32)
}
acc.srv = s
acc.updated = time.Now().UTC()
acc.updated = time.Now()
accName := acc.Name
jsEnabled := len(acc.jsLimits) > 0
acc.mu.Unlock()
Expand Down Expand Up @@ -2581,7 +2581,7 @@ func (s *Server) createClient(conn net.Conn) *client {
if maxSubs == 0 {
maxSubs = -1
}
now := time.Now().UTC()
now := time.Now()

c := &client{srv: s, nc: conn, opts: defaultOpts, mpay: maxPay, msubs: maxSubs, start: now, last: now}

Expand Down Expand Up @@ -2748,7 +2748,7 @@ func (s *Server) createClient(conn net.Conn) *client {
// This will save off a closed client in a ring buffer such that
// /connz can inspect. Useful for debugging, etc.
func (s *Server) saveClosedClient(c *client, nc net.Conn, reason ClosedState) {
now := time.Now().UTC()
now := time.Now()

s.accountDisconnectEvent(c, now, reason.String())

Expand Down