From 9b04f4ca1c2fe470a562be4b075d48d1c18962da Mon Sep 17 00:00:00 2001 From: Mitchell Date: Tue, 12 Jan 2021 20:53:02 -0500 Subject: Remove the rwmutex from the steam library as the template may be mutating the map causing issues. Embed the mutexes. --- cmd/web/index.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cmd/web/index.go') 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(), -- cgit v1.2.3