From deac3be776851b0404aa2faa5c964d59845430a3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 22 Jan 2018 08:34:51 +0100 Subject: [PATCH] Package app: Add mutex to persistingTokenSource. --- app/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/user.go b/app/user.go index e47a5cc..1215653 100644 --- a/app/user.go +++ b/app/user.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "sync" "github.com/google/uuid" legacy_context "golang.org/x/net/context" @@ -107,9 +108,14 @@ type persistingTokenSource struct { t *oauth2.Token src oauth2.TokenSource key *datastore.Key + + sync.Mutex } func (s *persistingTokenSource) Token() (*oauth2.Token, error) { + s.Lock() + defer s.Unlock() + tok, err := s.src.Token() if err != nil { return nil, err -- 2.11.0