OLD | NEW |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package netchan | 5 package netchan |
6 | 6 |
7 import ( | 7 import ( |
8 "io" | 8 "io" |
9 "log" | 9 "log" |
10 "net" | 10 "net" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 if nch.dir != Recv { | 127 if nch.dir != Recv { |
128 impLog("cannot happen: receive from non-Recv channel") | 128 impLog("cannot happen: receive from non-Recv channel") |
129 return | 129 return |
130 } | 130 } |
131 // Acknowledge receipt | 131 // Acknowledge receipt |
132 ackHdr.Id = hdr.Id | 132 ackHdr.Id = hdr.Id |
133 ackHdr.SeqNum = hdr.SeqNum | 133 ackHdr.SeqNum = hdr.SeqNum |
134 imp.encode(ackHdr, payAck, nil) | 134 imp.encode(ackHdr, payAck, nil) |
135 // Create a new value for each received item. | 135 // Create a new value for each received item. |
136 » » value := reflect.MakeZero(nch.ch.Type().(*reflect.ChanType).Elem
()) | 136 » » value := reflect.MakeZero(nch.ch.Type().Elem()) |
137 if e := imp.decode(value); e != nil { | 137 if e := imp.decode(value); e != nil { |
138 impLog("importer value decode:", e) | 138 impLog("importer value decode:", e) |
139 return | 139 return |
140 } | 140 } |
141 nch.send(value) | 141 nch.send(value) |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 func (imp *Importer) getChan(id int, errOk bool) *netChan { | 145 func (imp *Importer) getChan(id int, errOk bool) *netChan { |
146 imp.chanLock.Lock() | 146 imp.chanLock.Lock() |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 defer imp.chanLock.Unlock() | 237 defer imp.chanLock.Unlock() |
238 nc := imp.names[name] | 238 nc := imp.names[name] |
239 if nc == nil { | 239 if nc == nil { |
240 return os.ErrorString("netchan import: hangup: no such channel:
" + name) | 240 return os.ErrorString("netchan import: hangup: no such channel:
" + name) |
241 } | 241 } |
242 imp.names[name] = nil, false | 242 imp.names[name] = nil, false |
243 imp.chans[nc.id] = nil, false | 243 imp.chans[nc.id] = nil, false |
244 nc.close() | 244 nc.close() |
245 return nil | 245 return nil |
246 } | 246 } |
OLD | NEW |