Heartbeat#sendEvent(m): nil-check m before dereferencing it

as it can be nil.
This commit is contained in:
Alexander A. Klimov 2023-01-19 16:55:11 +01:00
parent 4ed4db3ab6
commit 5a79a72ff5

View file

@ -179,9 +179,12 @@ func (h *Heartbeat) sendEvent(m *HeartbeatMessage) {
select {
case old := <-h.events:
if old != nil {
h.logger.Debugw("Previous heartbeat not read from channel",
zap.Time("previous", old.received),
zap.Time("current", m.received))
kv := []any{zap.Time("previous", old.received)}
if m != nil {
kv = append(kv, zap.Time("current", m.received))
}
h.logger.Debugw("Previous heartbeat not read from channel", kv...)
} else {
h.logger.Debug("Previous heartbeat loss event not read from channel")
}