Skip to content

Commit

Permalink
simpler stream rollback without an extra goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
steveyen committed Oct 28, 2014
1 parent ac74413 commit db1834d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pindex_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,15 @@ func RunBleveStream(mgr PIndexManager, pindex *PIndex, stream Stream,
pindex.Impl.Close()
os.RemoveAll(pindex.Path)

// NOTE: Without the goroutine, then deadlock would be
// possible in that telling the manager & janitor to close
// us means any feeds will also synchronously close -- but
// the feed that sent us a StreamRollback request might be
// blocked awaiting a reply from us.
go mgr.ClosePIndex(pindex)

// First, respond to the feed so that it can unblock.
if m.doneCh != nil {
close(m.doneCh)
}

// Because, here the manager/janitor will synchronously
// ask the feed to close and we don't want a deadlock.
mgr.ClosePIndex(pindex)

return false, false, nil

case *StreamSnapshot:
Expand Down

0 comments on commit db1834d

Please sign in to comment.