diff options
| author | Mitchell <mitch@riedstra.dev> | 2021-01-12 20:53:02 -0500 |
|---|---|---|
| committer | Mitchell <mitch@riedstra.dev> | 2021-01-12 20:53:02 -0500 |
| commit | 9b04f4ca1c2fe470a562be4b075d48d1c18962da (patch) | |
| tree | 7cb3b465eec5bde3de88d826880d2cc625eff005 /cmd/web/index.go | |
| parent | fde64077cdd85f7a7b989fef320bf7fa3826a01d (diff) | |
| download | steam-export-9b04f4ca1c2fe470a562be4b075d48d1c18962da.tar.gz steam-export-9b04f4ca1c2fe470a562be4b075d48d1c18962da.tar.xz | |
Remove the rwmutex from the steam library as the template may be mutating the map causing issues. Embed the mutexes.
Diffstat (limited to 'cmd/web/index.go')
| -rw-r--r-- | cmd/web/index.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cmd/web/index.go b/cmd/web/index.go index 970810f..3121384 100644 --- a/cmd/web/index.go +++ b/cmd/web/index.go @@ -129,10 +129,14 @@ Change library path ) func index(w http.ResponseWriter, r *http.Request) { - libMu.RLock() - defer libMu.RUnlock() - status.m.RLock() - defer status.m.RUnlock() + // During rendering of the template I believe it's + // mutating during the sort of keys, so Lib no longer + // is an RWMutex and we're just locking this as if + // we're writing to it + Lib.Lock() + defer Lib.Unlock() + status.Lock() + defer status.Unlock() err := Templ.ExecuteTemplate(w, "index", struct { @@ -143,8 +147,8 @@ func index(w http.ResponseWriter, r *http.Request) { Port string Version string }{ - Lib, - status.s, + &Lib.Library, + status, isLocal(r.RemoteAddr), getHostIP(), getPort(), |
