aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2015-05-18 13:45:02 -0600
committerBen Johnson <benbjohnson@yahoo.com>2015-05-18 13:45:02 -0600
commitdf52bd0803e5062c92eb947ef63fdf0dd74c5753 (patch)
tree3ad764d7a6580f264cd7ceea9175ef76a021775f /db.go
parentmake ignoring Truncate() explicit (diff)
downloaddedo-df52bd0803e5062c92eb947ef63fdf0dd74c5753.tar.gz
dedo-df52bd0803e5062c92eb947ef63fdf0dd74c5753.tar.xz
Add test case inline documentation.
Diffstat (limited to 'db.go')
-rw-r--r--db.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/db.go b/db.go
index d1b722a..6592b38 100644
--- a/db.go
+++ b/db.go
@@ -102,10 +102,12 @@ type DB struct {
statlock sync.RWMutex // Protects stats access.
ops struct {
- writeAt func(b []byte, off int64) (n int, err error)
+ writeAt func(b []byte, off int64) (n int, err error)
}
- readOnly bool // Read only mode. Update()/Begin(true) would return ErrDatabaseReadOnly immediately.
+ // Read only mode.
+ // When true, Update() and Begin(true) return ErrDatabaseReadOnly immediately.
+ readOnly bool
}
// Path returns the path to currently open database file.
@@ -440,9 +442,11 @@ func (db *DB) beginTx() (*Tx, error) {
}
func (db *DB) beginRWTx() (*Tx, error) {
+ // If the database was opened with Options.ReadOnly, return an error.
if db.readOnly {
return nil, ErrDatabaseReadOnly
}
+
// Obtain writer lock. This is released by the transaction when it closes.
// This enforces only one writer transaction at a time.
db.rwlock.Lock()