[maybe solved] Go-yamux: signaling to the remote that the stream is closed

It seems that when Close() is called on a stream with go-yamux, it’s possible that the remote does not immediately realize the stream has been closed.

I’m not running into this issue anymore now that I changed the behavior of my app to not rely on the Close notification going through to signal done, but I wonder if this could lead to streams leaking / being left unclosed on one end of the connection.

There are a few other things that can be improved a bit, probably:

  • Atomic integers can be updated to use the new atomic.Int64
  • Is the rtt measurement / window size goroutine necessary? (Can’t we spin off a goroutine to measure it periodically when Read is called?)
  • 3 goroutines for every session - see above

Hopefully I can send some PRs soon for this.

After adding some debug messages:

[P1] [DEBUG] yamux: registered new outgoing stream: 4 
[P2] [DEBUG] yamux: registered new incoming stream: 4

# Close() called on P2
[P2] [DEBUG] yamux: deleted stream: 4
[P2] [WARN] yamux: Discarding data for stream: 4

So: after calling CloseSend followed by Close (a second later) on P2, P1 still thinks the stream is open