diff options
Diffstat (limited to 'src/pkg/netchan/import.go')
| -rw-r--r-- | src/pkg/netchan/import.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pkg/netchan/import.go b/src/pkg/netchan/import.go index bde36f615..454e265b2 100644 --- a/src/pkg/netchan/import.go +++ b/src/pkg/netchan/import.go @@ -49,6 +49,17 @@ func NewImporter(network, remoteaddr string) (*Importer, os.Error) { return imp, nil } +// shutdown closes all channels for which we are receiving data from the remote side. +func (imp *Importer) shutdown() { + imp.chanLock.Lock() + for _, ich := range imp.chans { + if ich.dir == Recv { + ich.ch.Close() + } + } + imp.chanLock.Unlock() +} + // Handle the data from a single imported data stream, which will // have the form // (response, data)* @@ -60,6 +71,7 @@ func (imp *Importer) run() { for { if e := imp.decode(hdr); e != nil { log.Stderr("importer header:", e) + imp.shutdown() return } switch hdr.payloadType { @@ -72,7 +84,7 @@ func (imp *Importer) run() { } if err.error != "" { log.Stderr("importer response error:", err.error) - // TODO: tear down connection + imp.shutdown() return } default: |
