1
0
mirror of https://github.com/gusaul/grpcox.git synced 2025-01-24 21:24:39 +00:00

add mutex to append conn to map to avoid concurrent map access

This commit is contained in:
gusaul 2020-05-29 08:14:33 +07:00
parent 6148904bec
commit 3908c00c11

View File

@ -121,7 +121,9 @@ func (c *ConnStore) addConnection(host string, res *Resource, ttl ...time.Durati
conn.expired = time.Now().Add(ttl[0]) conn.expired = time.Now().Add(ttl[0])
} }
c.Lock()
c.conn[host] = conn c.conn[host] = conn
c.Unlock()
} }
func (c *ConnStore) getConnection(host string) (res *Resource, found bool) { func (c *ConnStore) getConnection(host string) (res *Resource, found bool) {