Closing a channel after you put something on it is fine, a channel 
won't actually be closed to the code pulling from the channel until all 
of the contents that were on the channel when it was closed are 
drained. The other issue is a good point. You *could* check to see if 
there's a pack on the channel, of course.

All in all it's not that big a deal. Not using a goroutine appeals to 
me b/c a) spinning up goroutines are cheap, but not free and b) when 
you spin up the goroutine, it's quite likely that the code that puts a 
pack on the channel and the code that pulls from the channel will run 
at about the same time, causing lock contention for the channel. If you 
don't, then clearly there won't be any lock contention. It's not like 
this is in a tight loop or anything, though, so I'll leave it to you.

And with that, I'm out the door to catch an airplane. See ya next week!

On Wed May 15 09:44:10 2013, Ben Bangert wrote:
> In pipeline/pipeline_runner.go:
>
> >  func (foRunner *foRunner) InChan() (inChan chan *PipelineCapture) {
> > +	if foRunner.retainPack != nil {
> > +		retainChan := make(chan *PipelineCapture)
> > +		go func() {
> > +			retainChan <- foRunner.retainPack
> > +			foRunner.retainPack = nil
> > +			close(retainChan)
> > +		}()
> > +		return retainChan
> > +	}
>
> Also, the channel has to be closed after its consumed, if it returns a
> channel of 1 with 1 packet, the plugin will never exit even though
> this channel will never get anything on it again...
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/mozilla-services/heka/pull/177/files#r4238660>.
>