Skip to content

Commit

Permalink
🩹 Fix limiter middleware db connection (gofiber#1813)
Browse files Browse the repository at this point in the history
* remove release() method

* Revert "remove release() method"

This reverts commit fdfc8da.

* Rearrange mutexes in limiter_fixed.go

* refactor limiter_fixed.go

* Update limiter_fixed.go

Co-authored-by: RW <rene@gofiber.io>
  • Loading branch information
kwarabei and ReneWerner87 committed Mar 15, 2022
1 parent bd20e90 commit c92a505
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions middleware/limiter/limiter_fixed.go
Expand Up @@ -92,9 +92,13 @@ func (FixedWindow) New(cfg Config) fiber.Handler {
// Check for SkipFailedRequests and SkipSuccessfulRequests
if (cfg.SkipSuccessfulRequests && c.Response().StatusCode() < fiber.StatusBadRequest) ||
(cfg.SkipFailedRequests && c.Response().StatusCode() >= fiber.StatusBadRequest) {
// Lock entry
mux.Lock()
e = manager.get(key)
e.currHits--
remaining++
manager.set(key, e, cfg.Expiration)
// Unlock entry
mux.Unlock()
}

Expand Down

0 comments on commit c92a505

Please sign in to comment.