From 89370b7d7f83a51c76a14ef900e6a39a45873fad Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 22 Feb 2022 19:15:07 -0400 Subject: [PATCH] fix: random mailserver selection when available mailservers is 1 --- protocol/messenger_mailserver_cycle.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protocol/messenger_mailserver_cycle.go b/protocol/messenger_mailserver_cycle.go index 44314ec52..2a9a567fa 100644 --- a/protocol/messenger_mailserver_cycle.go +++ b/protocol/messenger_mailserver_cycle.go @@ -293,6 +293,11 @@ func (m *Messenger) findNewMailserverV1() error { // Picks a random mailserver amongs the ones with the lowest latency // The pool size is 1/4 of the mailservers were pinged successfully pSize := poolSize(len(availableMailservers) - 1) + if pSize <= 0 { + m.logger.Warn("No store nodes available") // Do nothing... + return nil + } + r, err := rand.Int(rand.Reader, big.NewInt(int64(pSize))) if err != nil { return err