forked from TrueCloudLab/frostfs-node
[#324] morph/listener: Prevent potential writing to nil channel
Write error returned by BlockNotifications() call ins listenLoop method body to error channel only if it is procided. Otherwise, write debug log message. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
96febdb6a5
commit
5e212f97d6
1 changed files with 7 additions and 1 deletions
|
@ -155,7 +155,13 @@ func (s listener) listen(ctx context.Context, intError chan<- error) error {
|
|||
func (s listener) listenLoop(ctx context.Context, chEvent <-chan *state.NotificationEvent, intErr chan<- error) {
|
||||
blockChan, err := s.subscriber.BlockNotifications()
|
||||
if err != nil {
|
||||
intErr <- errors.Wrap(err, "could not open block notifications channel")
|
||||
if intErr != nil {
|
||||
intErr <- errors.Wrap(err, "could not open block notifications channel")
|
||||
} else {
|
||||
s.log.Debug("could not open block notifications channel",
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue