Skip to content

Commit

Permalink
Left a note for future-us about possible leak in channel Recv
Browse files Browse the repository at this point in the history
Left a TODO about goroutine that may possibly be blocked forever.

This shouldn't be a problem right now with how Recv consumers are
constructed but this may become a problem in future.

#3420 captures this
work.
  • Loading branch information
pdyraga committed Nov 29, 2022
1 parent a0064cb commit a080113
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/net/libp2p/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c *channel) Send(
// could explore using a channel. We would avoid unnecessary hop and the
// broadcast channel could be dropping messages if the receiving channel is full.
//
//https://github.com/keep-network/keep-core/issues/3420
// See https://github.com/keep-network/keep-core/issues/3420
func (c *channel) Recv(ctx context.Context, handler func(m net.Message)) {
messageHandler := &messageHandler{
ctx: ctx,
Expand Down Expand Up @@ -177,6 +177,11 @@ func (c *channel) Recv(ctx context.Context, handler func(m net.Message)) {
continue
}

// TODO: If this function blocks forever, this entire goroutine
// will be blocked forever. We should consider using a channel
// instead of a callback receiver.
//
// See https://github.com/keep-network/keep-core/issues/3420
handleWithRetransmissions(msg)
}
}
Expand Down

0 comments on commit a080113

Please sign in to comment.