Skip to content

Commit

Permalink
Fix for calling concurrent Date and sendError
Browse files Browse the repository at this point in the history
For some reason I used Lock instead of RLock for Date. That's wrong.
  • Loading branch information
fiorix committed Nov 21, 2014
1 parent cc079e0 commit 228f699
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ func (db *DB) renameFile(name string) error {
// Date returns the UTC date the database file was last modified.
// If no database file has been opened the behaviour of Date is undefined.
func (db *DB) Date() time.Time {
db.mu.Lock()
defer db.mu.Unlock()
db.mu.RLock()
defer db.mu.RUnlock()
return db.lastUpdated
}

Expand All @@ -287,8 +287,8 @@ func (db *DB) NotifyError() (errChan <-chan error) {
}

func (db *DB) sendError(err error) {
db.mu.Lock()
defer db.mu.Unlock()
db.mu.RLock()
defer db.mu.RUnlock()
if db.closed {
return
}
Expand Down

0 comments on commit 228f699

Please sign in to comment.