more idiomatic closing of forwarders, by closing a 'finished' channel

The previous scheme set the reference to main channel to nil and then
drained it. That was racy and hence could lead to deadlock in the
following scenario:

1. multiple senders obtain the main channel from the stored reference
2. main channel reference is set to nil
3. main channel is drained
4. multiple senders send to main channel

So the issue here is that the entire forwarder stopping sequence
occurs between senders obtaining of the reference to the main channel,
and then sending on that channel. If more senders sent than there is
capacity in the channel then this leads to deadlock.
This commit is contained in:
Matthias Radestock committed 2015-03-28 20:58:42 +00:00
1 parent 4dbb3d97e0
commit b6448fa196
2 files changed
+34 -44

No files matched your search

+2
View File
@@ -53,6 +53,8 @@ type LocalConnection struct {
fragTest *time.Ticker
forwardChan chan<- *ForwardedFrame
forwardChanDF chan<- *ForwardedFrame
forwardFinished <-chan struct{}
forwardFinishedDF <-chan struct{}
verifyPMTU chan<- int
Decryptor Decryptor
Router *Router