diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-09-24 13:38:08 -0400 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-09-24 13:38:50 -0400 |
| commit | f69f0b97f5d1ee74dd4e5ef625da804d3334f879 (patch) | |
| tree | 931f6a19cde9a12ce6d6ade55f95663eeb68bcd6 | |
| parent | 4361ea968655f91505c24b83b890f51c1bb938a1 (diff) | |
| download | invidious-f69f0b97f5d1ee74dd4e5ef625da804d3334f879.tar.gz invidious-f69f0b97f5d1ee74dd4e5ef625da804d3334f879.tar.bz2 invidious-f69f0b97f5d1ee74dd4e5ef625da804d3334f879.zip | |
Add fix for index out of bounds during high load
| -rw-r--r-- | src/invidious/helpers/handlers.cr | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.cr index f2240691..949eb335 100644 --- a/src/invidious/helpers/handlers.cr +++ b/src/invidious/helpers/handlers.cr @@ -237,3 +237,16 @@ class HTTP::Client response end end + +struct Crystal::ThreadLocalValue(T) + @values = Hash(Thread, T).new + + def get(&block : -> T) + th = Thread.current + if !@values[th]? + @values[th] = yield + else + @values[th] + end + end +end |
