From 76a977b319864651b38690b2d512393af75cbd01 Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Sat, 23 Nov 2019 14:09:13 +0100 Subject: [PATCH] Instantiate mutex and rename AuthenticationQueue to AuthenticationMap --- authentication_queue.go => authentication_map.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename authentication_queue.go => authentication_map.go (93%) diff --git a/authentication_queue.go b/authentication_map.go similarity index 93% rename from authentication_queue.go rename to authentication_map.go index 39813bd..bf5585f 100644 --- a/authentication_queue.go +++ b/authentication_map.go @@ -17,7 +17,7 @@ type AuthenticationMap struct { } // Returns empty string when no request by that id is present -func (q *AuthenticationMap) getRequestByID(ID string) *AuthRequest { +func (q *AuthenticationMap) GetRequestByID(ID string) *AuthRequest { q.requestMapMutex.RLock() req, ok := q.requestMap[ID] @@ -57,6 +57,7 @@ func (q *AuthenticationMap) QueueRequest(r *AuthRequest) error { func (q *AuthenticationMap) Init() { q.requestMap = make(map[string]*AuthRequest) + q.requestMapMutex = &sync.RWMutex{} q.startRequestMapCleaner() }