Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(224)

Side by Side Diff: src/pkg/netchan/export.go

Issue 3460042: code review 3460042: netchan: fix dumb locking bug introduced in recent editing. (Closed)
Patch Set: code review 3460042: netchan: fix dumb locking bug introduced in recent editing. Created 14 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b