Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
Revert "fix deadlock and goroutine leak in chunk restore (#149)" (#152)
Browse files Browse the repository at this point in the history
This reverts commit 852c5e9.
  • Loading branch information
IANTHEREAL authored and kennytm committed Mar 25, 2019
1 parent 9991839 commit c3886a8
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1399,25 +1399,8 @@ func (cr *chunkRestore) restore(
}
block.cond = sync.NewCond(new(sync.Mutex))
deliverCompleteCh := make(chan error, 1)
deliveryClosedCh, deliveryCancel := context.WithCancel(ctx)

deliveryExitFn := func() {
deliveryCancel()
block.cond.Signal()
}

encodeExitFn := func() {
block.cond.L.Lock()
block.encodeCompleted = true
block.cond.Signal()
block.cond.L.Unlock()
}

defer encodeExitFn()

go func() {
defer deliveryExitFn()

var dataKVs, indexKVs []kvenc.KvPair
for {
block.cond.L.Lock()
Expand Down Expand Up @@ -1531,13 +1514,10 @@ func (cr *chunkRestore) restore(
}()

var buffer bytes.Buffer
encodeLoop:
for {
select {
case <-ctx.Done():
return ctx.Err()
case <-deliveryClosedCh.Done():
break encodeLoop
default:
}

Expand Down Expand Up @@ -1625,7 +1605,10 @@ encodeLoop:
block.cond.L.Unlock()
}

encodeExitFn()
block.cond.L.Lock()
block.encodeCompleted = true
block.cond.Signal()
block.cond.L.Unlock()

select {
case err := <-deliverCompleteCh:
Expand Down

0 comments on commit c3886a8

Please sign in to comment.