Skip to content

Commit

Permalink
Update the LastMapUpdate timestamp in all cases.
Browse files Browse the repository at this point in the history
It used to be that in case of errors we didn't update
the "last" timestamp, meaning that we could potentially call
the costly UpdateMap function too often. Closes elastic#7.
  • Loading branch information
Tudor Golubenco committed Apr 14, 2015
1 parent bec51f5 commit 8e8ed11
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions procs/procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ func (proc *ProcessesWatcher) FindProc(port uint16) (procname string) {
return p.Proc.Name
}

if time.Now().Sub(proc.LastMapUpdate) > proc.MaxReadFreq {
now := time.Now()

if now.Sub(proc.LastMapUpdate) > proc.MaxReadFreq {
proc.LastMapUpdate = now
proc.UpdateMap()

// try again
Expand Down Expand Up @@ -294,7 +297,6 @@ func (proc *ProcessesWatcher) UpdateMap() {
}
}

proc.LastMapUpdate = time.Now()
}

// Parses the /proc/net/tcp file
Expand Down

0 comments on commit 8e8ed11

Please sign in to comment.