MCPcopy
hub / github.com/etcd-io/bbolt / close

Method close

tx.go:345–378  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

343}
344
345func (tx *Tx) close() {
346 if tx.db == nil {
347 return
348 }
349 if tx.writable {
350 // Grab freelist stats.
351 var freelistFreeN = tx.db.freelist.FreeCount()
352 var freelistPendingN = tx.db.freelist.PendingCount()
353 var freelistAlloc = tx.db.freelist.EstimatedWritePageSize()
354
355 // Remove transaction ref & writer lock.
356 tx.db.rwtx = nil
357 tx.db.rwlock.Unlock()
358
359 // Merge statistics.
360 if tx.db.stats != nil {
361 tx.db.statlock.Lock()
362 tx.db.stats.FreePageN = freelistFreeN
363 tx.db.stats.PendingPageN = freelistPendingN
364 tx.db.stats.FreeAlloc = (freelistFreeN + freelistPendingN) * tx.db.pageSize
365 tx.db.stats.FreelistInuse = freelistAlloc
366 tx.db.stats.TxStats.add(&tx.stats)
367 tx.db.statlock.Unlock()
368 }
369 } else {
370 tx.db.removeTx(tx)
371 }
372
373 // Clear all references.
374 tx.db = nil
375 tx.meta = nil
376 tx.root = Bucket{tx: tx}
377 tx.pages = nil
378}
379
380// Copy writes the entire database to a writer.
381// This function exists for backwards compatibility.

Callers 3

CommitMethod · 0.95
nonPhysicalRollbackMethod · 0.95
rollbackMethod · 0.95

Calls 5

addMethod · 0.80
removeTxMethod · 0.80
FreeCountMethod · 0.65
PendingCountMethod · 0.65

Tested by

no test coverage detected