docker/spdystream — pull request #34 by jbenet (2014-12-31 08:40:59+00:00)
Title: Calling Reset with data remaining to be read hangs

Not sure if you guys are still maintaining this pkg (libchan seems on hold/dead).

In any case, calling Reset with data remaining to be read hangs. This PR introduces a test that shows the issue, and a (pretty crappy) workaround. See commit msg:

```
This commit introduces a `shutdownChan` to Streams
that works around the bug described below. I opted
for this approach because `closeChan` is ambiguous
(i believe it means the remote side closed, but not
sure), and the logic of Stream's sync is hard
to follow/modify (i suggest moving to a world
where everything calls one of three close functions
closeOutgoing, closeIncoming, closeBoth).

Reset-with-data-remaining Bug: if a client calls
Reset() on a stream with data remaining to be read,
a goroutine's stuck in `stream.dataChan <- frame.Data`
and also holds `stream.dataLock`, which means caller
of Reset will hang forever on s.dataLock.Lock().
Try running "TestStreamResetWithDataRemaining" in
the previous commit. This commit fixes the deadlock.

Note: my inspection also revealed several race
conditions, in particular when reading many variables
which are protected by locks only sometimes. For
example: (s *Stream).IsFinished() does not lock
s.finishLock.
```