Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 [Feature]: Sustainably prevent data races #2400

Open
3 tasks done
leonklingele opened this issue Apr 2, 2023 · 1 comment
Open
3 tasks done

🚀 [Feature]: Sustainably prevent data races #2400

leonklingele opened this issue Apr 2, 2023 · 1 comment

Comments

@leonklingele
Copy link
Member

Feature Description

The data race "fixed" in https://github.com/gofiber/fiber/pull/2368/files wasn't fixed at all.

Instead we should do something à la:

func (s *Storage) ConnLocked(fn func(map[string]entry)) {
    s.mux.Lock()
    defer s.mux.Unlock()
    fn(s.db)
}

Additional Context (optional)

No response

Code Snippet (optional)

No response

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my suggestion prior to opening this one.
  • I understand that improperly formatted feature requests may be closed without explanation.
Hrily added a commit to Hrily/fiber that referenced this issue Oct 8, 2023
This commit updates `Conn` method of memory storage to fix race conditions.

Fixes: gofiber#2400
@Hrily
Copy link

Hrily commented Oct 8, 2023

Hey folks

I've raised a PR #2669 to fix this.

It also adds a unit test to check for race condition, which would otherwise fail in older implementation or without using lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants