From ccbb33c35a2024dde33c5b799a5f5009003551cf Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Thu, 5 Dec 2024 18:03:25 -0800 Subject: [PATCH] Fix concurrent map write (#292) * Fix concurrent map write --- cmd/tlserver/main.go | 1 - internal/clock/swcache.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/tlserver/main.go b/cmd/tlserver/main.go index ed24f6cd..6e1bc5d5 100644 --- a/cmd/tlserver/main.go +++ b/cmd/tlserver/main.go @@ -106,7 +106,6 @@ func (cmd *ServerCommand) AddFlags(fl *pflag.FlagSet) { fl.BoolVar(&cmd.LoadAdmins, "load-admins", false, "Load admin polygons from database into memory") fl.IntVar(&cmd.LoaderBatchSize, "loader-batch-size", 100, "GraphQL Loader batch size") fl.IntVar(&cmd.LoaderStopTimeBatchSize, "loader-stop-time-batch-size", 1, "GraphQL Loader batch size for StopTimes") - } func (cmd *ServerCommand) Parse(args []string) error { diff --git a/internal/clock/swcache.go b/internal/clock/swcache.go index 436905be..52a8df7c 100644 --- a/internal/clock/swcache.go +++ b/internal/clock/swcache.go @@ -36,8 +36,8 @@ func NewServiceWindowCache(db sqlx.Ext) *ServiceWindowCache { func (f *ServiceWindowCache) Get(ctx context.Context, fvid int) (ServiceWindow, bool, error) { f.lock.Lock() + defer f.lock.Unlock() a, ok := f.fvslWindows[fvid] - f.lock.Unlock() if ok { return a, ok, nil }