1
0
mirror of https://github.com/gusaul/grpcox.git synced 2024-09-29 04:10: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])
}
c.Lock()
c.conn[host] = conn
c.Unlock()
}
func (c *ConnStore) getConnection(host string) (res *Resource, found bool) {