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

Method close

db.go:707–748  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

705}
706
707func (db *DB) close() error {
708 if !db.opened {
709 return nil
710 }
711
712 db.opened = false
713
714 db.freelist = nil
715
716 // Clear ops.
717 db.ops.writeAt = nil
718
719 var errs []error
720 // Close the mmap.
721 if err := db.munmap(); err != nil {
722 errs = append(errs, err)
723 }
724
725 // Close file handles.
726 if db.file != nil {
727 // No need to unlock read-only file.
728 if !db.readOnly {
729 // Unlock the file.
730 if err := funlock(db); err != nil {
731 errs = append(errs, fmt.Errorf("bolt.Close(): funlock error: %w", err))
732 }
733 }
734
735 // Close the file descriptor.
736 if err := db.file.Close(); err != nil {
737 errs = append(errs, fmt.Errorf("db file close: %w", err))
738 }
739 db.file = nil
740 }
741
742 db.path = ""
743
744 if len(errs) > 0 {
745 return errs[0]
746 }
747 return nil
748}
749
750// Begin starts a new transaction.
751// Multiple read-only transactions can be used concurrently but only one

Callers 2

CloseMethod · 0.95
OpenFunction · 0.45

Calls 4

munmapMethod · 0.95
funlockFunction · 0.70
ErrorfMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected