Merge pull request #41 from pterodactyl/fix/race-1

Fix a possible race condition when Unsubscribing from the EventBus
This commit is contained in:
Dane Everitt
2020-07-31 20:11:21 -07:00
committed by GitHub
2 changed files with 23 additions and 21 deletions

View File

@@ -26,9 +26,9 @@ func (h *Handler) ListenForExpiration(ctx context.Context) {
jwt := h.GetJwt()
if jwt != nil {
if jwt.ExpirationTime.Unix()-time.Now().Unix() <= 0 {
h.SendJson(&Message{Event: TokenExpiredEvent})
_ = h.SendJson(&Message{Event: TokenExpiredEvent})
} else if jwt.ExpirationTime.Unix()-time.Now().Unix() <= 180 {
h.SendJson(&Message{Event: TokenExpiringEvent})
_ = h.SendJson(&Message{Event: TokenExpiringEvent})
}
}
}
@@ -63,7 +63,7 @@ func (h *Handler) ListenForServerEvents(ctx context.Context) {
close(eventChannel)
default:
h.SendJson(&Message{
_ = h.SendJson(&Message{
Event: d.Topic,
Args: []string{d.Data},
})