fix(log): use Rlock in getEntriesAfter

getEntriesAfter only reads the log and doesn't make any motifications.
Using an RLock is safe here.
pull/820/head
Xiang Li 2014-01-27 17:04:41 -05:00 committed by Brandon Philips
parent 36556bf8e0
commit e615676f54
1 changed files with 2 additions and 2 deletions

4
log.go
View File

@ -238,8 +238,8 @@ func (l *Log) containsEntry(index uint64, term uint64) bool {
// index provided. A nil list of entries is returned if the index no longer
// exists because a snapshot was made.
func (l *Log) getEntriesAfter(index uint64, maxLogEntriesPerRequest uint64) ([]*LogEntry, uint64) {
l.mutex.Lock()
defer l.mutex.Unlock()
l.mutex.RLock()
defer l.mutex.RUnlock()
// Return nil if index is before the start of the log.
if index < l.startIndex {