Skip to content

Commit

Permalink
Bug Fix: Set the water reference before putting list in map, otherwis…
Browse files Browse the repository at this point in the history
…e it can be nil causing panic.
  • Loading branch information
manishrjain authored and Pawan Rawal committed Feb 10, 2017
1 parent d22e336 commit 625a9d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion posting/lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ func GetOrCreate(key []byte, group uint32) (rlist *List, decr func()) {
return lp, lp.decr
}

// Any initialization for l must be done before PutIfMissing. Once it's added
// to the map, any other goroutine can retrieve it.
l := getNew(key, pstore) // This retrieves a new *List and sets refcount to 1.
l.water = marks.Get(group)

lp = lhmap.PutIfMissing(fp, l)
// We are always going to return lp to caller, whether it is l or not. So, let's
// increment its reference counter.
Expand All @@ -378,7 +382,6 @@ func GetOrCreate(key []byte, group uint32) (rlist *List, decr func()) {
// Undo the increment in getNew() call above.
l.decr()
}
lp.water = marks.Get(group)
pk := x.Parse(key)

// This replaces "TokensTable". The idea is that we want to quickly add the
Expand Down

0 comments on commit 625a9d8

Please sign in to comment.