mirror of
https://github.com/golang/go
synced 2024-11-26 14:08:37 -07:00
database/sql: remove extra RemoveDep call
This should have been removed in 45c12efb4635. Not a correctness issue, but unnecessary work. This CL also adds paranoia checks in removeDep so this doesn't happen again. Fixes #5502 R=adg CC=gobot, golang-dev, google https://golang.org/cl/9543043
This commit is contained in:
parent
509a1173a3
commit
0e10196982
@ -357,21 +357,27 @@ func (db *DB) removeDep(x finalCloser, dep interface{}) error {
|
||||
|
||||
func (db *DB) removeDepLocked(x finalCloser, dep interface{}) func() error {
|
||||
//println(fmt.Sprintf("removeDep(%T %p, %T %p)", x, x, dep, dep))
|
||||
done := false
|
||||
|
||||
xdep := db.dep[x]
|
||||
if xdep != nil {
|
||||
xdep, ok := db.dep[x]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("unpaired removeDep: no deps for %T", x))
|
||||
}
|
||||
|
||||
l0 := len(xdep)
|
||||
delete(xdep, dep)
|
||||
if len(xdep) == 0 {
|
||||
delete(db.dep, x)
|
||||
done = true
|
||||
}
|
||||
}
|
||||
|
||||
if !done {
|
||||
switch len(xdep) {
|
||||
case l0:
|
||||
// Nothing removed. Shouldn't happen.
|
||||
panic(fmt.Sprintf("unpaired removeDep: no %T dep on %T", dep, x))
|
||||
case 0:
|
||||
// No more dependencies.
|
||||
delete(db.dep, x)
|
||||
return x.finalClose
|
||||
default:
|
||||
// Dependencies remain.
|
||||
return func() error { return nil }
|
||||
}
|
||||
return x.finalClose
|
||||
}
|
||||
|
||||
// Open opens a database specified by its database driver name and a
|
||||
@ -1261,7 +1267,6 @@ func (s *Stmt) finalClose() error {
|
||||
for _, v := range s.css {
|
||||
s.db.noteUnusedDriverStatement(v.dc, v.si)
|
||||
v.dc.removeOpenStmt(v.si)
|
||||
s.db.removeDep(v.dc, s)
|
||||
}
|
||||
s.css = nil
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user