From d4d4d353f4f78760e994f3ce9505540ed97db007 Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Tue, 4 Aug 2020 10:59:15 +0200 Subject: [PATCH] Properly lock access to the shared map --- .../en/docs/config/grpc/services/appprovider/_index.md | 4 ++-- internal/grpc/services/appprovider/appprovider.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/content/en/docs/config/grpc/services/appprovider/_index.md b/docs/content/en/docs/config/grpc/services/appprovider/_index.md index 2e892a3851f..625ecd27255 100644 --- a/docs/content/en/docs/config/grpc/services/appprovider/_index.md +++ b/docs/content/en/docs/config/grpc/services/appprovider/_index.md @@ -9,7 +9,7 @@ description: > # _struct: config_ {{% dir name="iopsecret" type="string" default="" %}} -The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L60) +The iopsecret used to connect to the wopiserver. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L61) {{< highlight toml >}} [grpc.services.appprovider] iopsecret = "" @@ -17,7 +17,7 @@ iopsecret = "" {{% /dir %}} {{% dir name="wopiurl" type="string" default="" %}} -The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L61) +The wopiserver's URL. [[Ref]](https://github.com/cs3org/reva/tree/master/internal/grpc/services/appprovider/appprovider.go#L62) {{< highlight toml >}} [grpc.services.appprovider] wopiurl = "" diff --git a/internal/grpc/services/appprovider/appprovider.go b/internal/grpc/services/appprovider/appprovider.go index 0decaa1c6e4..75caf9c9814 100644 --- a/internal/grpc/services/appprovider/appprovider.go +++ b/internal/grpc/services/appprovider/appprovider.go @@ -30,6 +30,7 @@ import ( "path" "strconv" "strings" + "sync" "time" providerpb "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1" @@ -51,7 +52,7 @@ func init() { type service struct { provider app.Provider conf *config - appsURLMap map[string]interface{} + appsURLMap sync.Map } type config struct { @@ -142,7 +143,7 @@ func (s *service) getWopiAppEndpoints(ctx context.Context) error { return err } - s.appsURLMap = make(map[string]interface{}) + s.appsURLMap = sync.Map{} err = json.Unmarshal(appsBody, &s.appsURLMap) if err != nil { return err