fix: random mailserver selection when available mailservers is 1

This commit is contained in:
Richard Ramos 2022-02-22 19:15:07 -04:00
parent 3cc683587d
commit 89370b7d7f
1 changed files with 5 additions and 0 deletions

View File

@ -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