예제 #1
1
파일: sql.go 프로젝트: serge-hulne/golang
// noteUnusedDriverStatement notes that si is no longer used and should
// be closed whenever possible (when c is next not in use), unless c is
// already closed.
func (db *DB) noteUnusedDriverStatement(c driver.Conn, si driver.Stmt) {
	db.mu.Lock()
	defer db.mu.Unlock()
	if db.outConn[c] {
		db.onConnPut[c] = append(db.onConnPut[c], func() {
			si.Close()
		})
	} else {
		si.Close()
	}
}
예제 #2
0
파일: sql.go 프로젝트: arnold8/go
// noteUnusedDriverStatement notes that si is no longer used and should
// be closed whenever possible (when c is next not in use), unless c is
// already closed.
func (db *DB) noteUnusedDriverStatement(c *driverConn, si driver.Stmt) {
	db.mu.Lock()
	defer db.mu.Unlock()
	if c.inUse {
		c.onPut = append(c.onPut, func() {
			si.Close()
		})
	} else {
		c.Lock()
		defer c.Unlock()
		if !c.finalClosed {
			si.Close()
		}
	}
}