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 /* | 5 /* |
6 The netchan package implements type-safe networked channels: | 6 The netchan package implements type-safe networked channels: |
7 it allows the two ends of a channel to appear on different | 7 it allows the two ends of a channel to appear on different |
8 computers connected by a network. It does this by transporting | 8 computers connected by a network. It does this by transporting |
9 data sent to a channel on one machine so it can be recovered | 9 data sent to a channel on one machine so it can be recovered |
10 by a receive of a channel of the same type on the other. | 10 by a receive of a channel of the same type on the other. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 clients: make(map[unackedCounter]bool), | 264 clients: make(map[unackedCounter]bool), |
265 }, | 265 }, |
266 } | 266 } |
267 go e.listen() | 267 go e.listen() |
268 return e, nil | 268 return e, nil |
269 } | 269 } |
270 | 270 |
271 // addClient creates a new expClient and records its existence | 271 // addClient creates a new expClient and records its existence |
272 func (exp *Exporter) addClient(conn net.Conn) *expClient { | 272 func (exp *Exporter) addClient(conn net.Conn) *expClient { |
273 client := newClient(exp, conn) | 273 client := newClient(exp, conn) |
| 274 exp.mu.Lock() |
274 exp.clients[client] = true | 275 exp.clients[client] = true |
275 exp.mu.Unlock() | 276 exp.mu.Unlock() |
276 return client | 277 return client |
277 } | 278 } |
278 | 279 |
279 // delClient forgets the client existed | 280 // delClient forgets the client existed |
280 func (exp *Exporter) delClient(client *expClient) { | 281 func (exp *Exporter) delClient(client *expClient) { |
281 exp.mu.Lock() | 282 exp.mu.Lock() |
282 exp.clients[client] = false, false | 283 exp.clients[client] = false, false |
283 exp.mu.Unlock() | 284 exp.mu.Unlock() |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 if ok { | 359 if ok { |
359 exp.chans[name] = nil, false | 360 exp.chans[name] = nil, false |
360 } | 361 } |
361 exp.mu.Unlock() | 362 exp.mu.Unlock() |
362 if !ok { | 363 if !ok { |
363 return os.ErrorString("netchan export: hangup: no such channel:
" + name) | 364 return os.ErrorString("netchan export: hangup: no such channel:
" + name) |
364 } | 365 } |
365 chDir.ch.Close() | 366 chDir.ch.Close() |
366 return nil | 367 return nil |
367 } | 368 } |
OLD | NEW |