From d534cb96a981199b2cce2d705e8780213c5fa3e8 Mon Sep 17 00:00:00 2001
From: Deluan <deluan@deluan.com>
Date: Tue, 21 Apr 2020 08:41:04 -0400
Subject: [PATCH] Replace math.Max with utils.MaxInt

---
 server/subsonic/api.go | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/server/subsonic/api.go b/server/subsonic/api.go
index 9717fab0d..ae9c2c8e5 100644
--- a/server/subsonic/api.go
+++ b/server/subsonic/api.go
@@ -4,17 +4,16 @@ import (
 	"encoding/json"
 	"encoding/xml"
 	"fmt"
-	"github.com/deluan/navidrome/consts"
-	"github.com/go-chi/chi/middleware"
-	"math"
 	"net/http"
 	"runtime"
 
+	"github.com/deluan/navidrome/consts"
 	"github.com/deluan/navidrome/engine"
 	"github.com/deluan/navidrome/log"
 	"github.com/deluan/navidrome/server/subsonic/responses"
 	"github.com/deluan/navidrome/utils"
 	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/middleware"
 )
 
 const Version = "1.10.2"
@@ -121,8 +120,8 @@ func (api *Router) routes() http.Handler {
 	r.Group(func(r chi.Router) {
 		c := initMediaRetrievalController(api)
 		// configure request throttling
-		maxRequests := math.Max(2, float64(runtime.NumCPU()))
-		withThrottle := r.With(middleware.ThrottleBacklog(int(maxRequests), consts.RequestThrottleBacklogLimit, consts.RequestThrottleBacklogTimeout))
+		maxRequests := utils.MaxInt(2, runtime.NumCPU())
+		withThrottle := r.With(middleware.ThrottleBacklog(maxRequests, consts.RequestThrottleBacklogLimit, consts.RequestThrottleBacklogTimeout))
 		H(withThrottle, "getAvatar", c.GetAvatar)
 		H(withThrottle, "getCoverArt", c.GetCoverArt)
 	})