// Closes all Stmts prepared for this transaction.
970713
func (tx *Tx) closePrepared() {
	tx.stmts.Lock()
	for _, stmt := range tx.stmts.v {
		stmt.Close()
	}
	tx.stmts.Unlock()
}
608453
func (s *ScopedKeyManager) Close() {
	s.mtx.Lock()
	defer s.mtx.Unlock()

	// Attempt to clear sensitive public key material from memory too.
	s.zeroSensitivePublicData()
	return
}
1113380
func (s *Stmt) connStmt() (ci *driverConn, releaseConn func(error), si driver.Stmt, err error) {
	if err = s.stickyErr; err != nil {
		return
	}
	s.mu.Lock()
	if s.closed {
		s.mu.Unlock()
		err = errors.New("sql: statement is closed")
		return
	}

	// In a transaction, we always use the connection that the
	// transaction was created on.
	if s.tx != nil {
		s.mu.Unlock()
		ci, err = s.tx.grabConn() // blocks, waiting for the connection.
		if err != nil {
			return
		}
		releaseConn = func(error) {}
		return ci, releaseConn, s.txsi.si, nil
	}

	for i := 0; i < len(s.css); i++ {
		v := s.css[i]
		_, err := s.db.connIfFree(v.dc)
		if err == nil {
			s.mu.Unlock()
			return v.dc, v.dc.releaseConn, v.si, nil
		}
		if err == errConnClosed {
			// Lazily remove dead conn from our freelist.
			s.css[i] = s.css[len(s.css)-1]
			s.css = s.css[:len(s.css)-1]
			i--
		}

	}
	s.mu.Unlock()

	// If all connections are busy, either wait for one to become available (if
	// we've already hit the maximum number of open connections) or create a
	// new one.
	//
	// TODO(bradfitz): or always wait for one? make configurable later?
	dc, err := s.db.conn()
	if err != nil {
		return nil, nil, nil, err
	}

	// Do another pass over the list to see whether this statement has
	// already been prepared on the connection assigned to us.
	s.mu.Lock()
	for _, v := range s.css {
		if v.dc == dc {
			s.mu.Unlock()
			return dc, dc.releaseConn, v.si, nil
		}
	}
	s.mu.Unlock()

	// No luck; we need to prepare the statement on this connection
	dc.Lock()
	si, err = dc.prepareLocked(s.query)
	dc.Unlock()
	if err != nil {
		s.db.putConn(dc, err)
		return nil, nil, nil, err
	}
	s.mu.Lock()
	cs := connStmt{dc, si}
	s.css = append(s.css, cs)
	s.mu.Unlock()

	return dc, dc.releaseConn, si, nil
}
1280825
func (p *TxnPool) Close() {
	txn, ok := (*lmdb.Txn)(nil), true
	for ok {
		txn, ok = p.pool.Get().(*lmdb.Txn)
		if ok {
			txn.Abort()
		}
	}
}
916189
func (t *trg) Close() (err error) {
	t.Lock()
	if err = t.t.Stop(); err != nil {
		t.Unlock()
		return
	}
	<-t.s
	var e error
	for _, w := range t.pthLkp {
		if e = t.unwatch(w.p, w.fi); e != nil {
			dbgprintf("trg: unwatch %q failed: %q\n", w.p, e)
			err = nonil(err, e)
		}
	}
	if e = t.t.Close(); e != nil {
		dbgprintf("trg: closing native watch failed: %q\n", e)
		err = nonil(err, e)
	}
	if remaining := len(t.pthLkp); remaining != 0 {
		err = nonil(err, fmt.Errorf("Not all watches were removed: len(t.pthLkp) == %v", len(t.pthLkp)))
	}
	t.Unlock()
	return
}
923830
func (c *MockProducer) Close() {
	if !atomic.CompareAndSwapInt32(&c.closed, 0, 1) {
		// Already closed
		return
	}

	c.ledger.Unregister(c.rcvch)
	close(c.rcvch)
}
1247931
func (t *tree) Close() {
	t.Clear()
	*t = zt
	btTPool.Put(t)
}
213213
func (m *Mrb) Close() {
	// Delete all the methods from the state
	stateMethodTable.Mutex.Lock()
	delete(stateMethodTable.Map, m.state)
	stateMethodTable.Mutex.Unlock()

	// Close the state
	C.mrb_close(m.state)
}
558920
func (transactionDB *TransactionDB) Close() {
	C.rocksdb_transactiondb_close(transactionDB.c)
	transactionDB.c = nil
}
413205
func (c *CompileContext) Close() {
	C.mrbc_context_free(c.mrb.state, c.ctx)
}
1368784
func (_m *Transmitter) Close() <-chan struct{} {
	ret := _m.Called()

	var r0 <-chan struct{}
	if rf, ok := ret.Get(0).(func() <-chan struct{}); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(<-chan struct{})
		}
	}

	return r0
}
820442
func (p *Parser) Stmts(r io.Reader, fn func(*Stmt) bool) error {
	p.reset()
	p.f = &File{}
	p.src = r
	p.rune()
	p.next()
	p.stmts(fn)
	if p.err == nil {
		// EOF immediately after heredoc word so no newline to
		// trigger it
		p.doHeredocs()
	}
	return p.err
}
942801
func (combiner *itrCombiner) Close() {
	for _, holder := range combiner.holders {
		holder.itr.Close()
	}
}
703508
func (axp *TxPool) Close() {
	axp.ticks.Stop()
	for _, v := range axp.activePool.GetOutdated(time.Duration(0), "for closing") {
		conn := v.(*TxConnection)
		log.Warningf("killing transaction for shutdown: %s", conn.Format(nil))
		tabletenv.InternalErrors.Add("StrayTransactions", 1)
		conn.Close()
		conn.conclude(TxClose, "pool closed")
	}
	axp.conns.Close()
	axp.foundRowsPool.Close()
}
825185
func (t *PrimaryTree) Close() {
	t.Clear()
	*t = zt1
	btTPool1.Put(t)
}
1092430
func (t *Tree) Close() {
	t.Clear()
	*t = zt
	btTPool.Put(t)
}
793540
func (iter *CommonIterator) Close() error {
	_, err := iter.handler.handleQueryStateClose(iter.response.Id, iter.channelId, iter.txid)
	return err
}