mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
beacon/light/request: add checks for nil event callback function
This commit is contained in:
parent
766869ce39
commit
d673c4875c
1 changed files with 16 additions and 9 deletions
|
|
@ -186,11 +186,15 @@ func (s *serverWithTimeout) eventCallback(event Event) {
|
||||||
// call will just do nothing
|
// call will just do nothing
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
delete(s.timeouts, id)
|
delete(s.timeouts, id)
|
||||||
|
if s.childEventCb != nil {
|
||||||
s.childEventCb(event)
|
s.childEventCb(event)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
|
if s.childEventCb != nil {
|
||||||
s.childEventCb(event)
|
s.childEventCb(event)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// startTimeout starts a timeout timer for the given request.
|
// startTimeout starts a timeout timer for the given request.
|
||||||
|
|
@ -211,11 +215,15 @@ func (s *serverWithTimeout) startTimeout(reqData RequestResponse) {
|
||||||
delete(s.timeouts, id)
|
delete(s.timeouts, id)
|
||||||
childEventCb := s.childEventCb
|
childEventCb := s.childEventCb
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
|
if childEventCb != nil {
|
||||||
childEventCb(Event{Type: EvFail, Data: reqData})
|
childEventCb(Event{Type: EvFail, Data: reqData})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
childEventCb := s.childEventCb
|
childEventCb := s.childEventCb
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
|
if childEventCb != nil {
|
||||||
childEventCb(Event{Type: EvTimeout, Data: reqData})
|
childEventCb(Event{Type: EvTimeout, Data: reqData})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +237,6 @@ func (s *serverWithTimeout) unsubscribe() {
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.childEventCb = nil
|
|
||||||
s.parent.Unsubscribe()
|
s.parent.Unsubscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,10 +335,10 @@ func (s *serverWithLimits) eventCallback(event Event) {
|
||||||
}
|
}
|
||||||
childEventCb := s.childEventCb
|
childEventCb := s.childEventCb
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
if passEvent {
|
if passEvent && childEventCb != nil {
|
||||||
childEventCb(event)
|
childEventCb(event)
|
||||||
}
|
}
|
||||||
if sendCanRequestAgain {
|
if sendCanRequestAgain && childEventCb != nil {
|
||||||
childEventCb(Event{Type: EvCanRequestAgain})
|
childEventCb(Event{Type: EvCanRequestAgain})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +390,7 @@ func (s *serverWithLimits) canRequestNow() bool {
|
||||||
}
|
}
|
||||||
childEventCb := s.childEventCb
|
childEventCb := s.childEventCb
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
if sendCanRequestAgain {
|
if sendCanRequestAgain && childEventCb != nil {
|
||||||
childEventCb(Event{Type: EvCanRequestAgain})
|
childEventCb(Event{Type: EvCanRequestAgain})
|
||||||
}
|
}
|
||||||
return canRequest
|
return canRequest
|
||||||
|
|
@ -415,7 +422,7 @@ func (s *serverWithLimits) delay(delay time.Duration) {
|
||||||
}
|
}
|
||||||
childEventCb := s.childEventCb
|
childEventCb := s.childEventCb
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
if sendCanRequestAgain {
|
if sendCanRequestAgain && childEventCb != nil {
|
||||||
childEventCb(Event{Type: EvCanRequestAgain})
|
childEventCb(Event{Type: EvCanRequestAgain})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue