Use defer to unlock pgConn in Prepare
This commit is contained in:
@@ -501,10 +501,10 @@ func (pgConn *PgConn) Prepare(ctx context.Context, name, sql string, paramOIDs [
|
||||
if err := pgConn.lock(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer pgConn.unlock()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
pgConn.unlock()
|
||||
return nil, ctx.Err()
|
||||
default:
|
||||
}
|
||||
@@ -548,8 +548,6 @@ readloop:
|
||||
}
|
||||
}
|
||||
|
||||
pgConn.unlock()
|
||||
|
||||
if parseErr != nil {
|
||||
return nil, parseErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user