mirror of https://github.com/jackc/pgx.git
stdlib: fix race with Driver.configs in Open
The Driver.configs map is protected by configMutex in registerDriverConfig and unregisterDriverConfig, but not in Open. This results in a race if Open is called while another goroutine is registering/unregistering a DriverConfig.pull/480/head
parent
a0d2ce5a0e
commit
8b8e883961
|
@ -140,8 +140,10 @@ func (d *Driver) Open(name string) (driver.Conn, error) {
|
|||
if len(name) >= 9 && name[0] == 0 {
|
||||
idBuf := []byte(name)[1:9]
|
||||
id := int64(binary.BigEndian.Uint64(idBuf))
|
||||
d.configMutex.Lock()
|
||||
connConfig = d.configs[id].ConnConfig
|
||||
afterConnect = d.configs[id].AfterConnect
|
||||
d.configMutex.Unlock()
|
||||
name = name[9:]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue