Skip to content
This repository was archived by the owner on Jul 28, 2020. It is now read-only.

Commit 59631ca

Browse files
committed
Fixes random panic in analyticsd
Revert "Stop using *pointer in analyticsd daemon to avoid random panics" This reverts commit bd5b555.
1 parent bd5b555 commit 59631ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

analyticsd/daemon/daemon.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Daemon struct {
2828
ticker *time.Ticker
2929
pollingInterval time.Duration
3030
logger *log.Logger
31-
lastTime time.Time
31+
lastTime *time.Time
3232
doneChan chan bool
3333
}
3434

@@ -138,7 +138,7 @@ func (d *Daemon) do(isFirstTime bool) error {
138138

139139
params := url.Values{}
140140
params.Add("q", "type IN "+eventTypesFilter())
141-
if !isFirstTime {
141+
if !isFirstTime && d.lastTime != nil {
142142
params.Add("q", "timestamp>"+d.lastTime.Format(ccTimeStampFormat))
143143
}
144144

@@ -257,7 +257,7 @@ func eventTypesFilter() string {
257257

258258
func (d *Daemon) saveLatestTime(t time.Time) {
259259
t = t.UTC()
260-
if t.After(d.lastTime) {
261-
d.lastTime = t
260+
if d.lastTime == nil || t.After(*d.lastTime) {
261+
d.lastTime = &t
262262
}
263263
}

0 commit comments

Comments
 (0)