- Timestamp:
- Jun 3, 2020, 3:28:31 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user.go
r309 r311 89 89 } 90 90 91 func (net *network) isStopped() bool { 92 select { 93 case <-net.stopped: 94 return true 95 default: 96 return false 97 } 98 } 99 91 100 func (net *network) run() { 92 101 var lastTry time.Time 93 102 for { 94 select { 95 case <-net.stopped: 103 if net.isStopped() { 96 104 return 97 default:98 // This space is intentionally left blank99 105 } 100 106 … … 121 127 } 122 128 129 // TODO: this is racy with net.stopped. If the network is stopped 130 // before the user goroutine receives eventUpstreamConnected, the 131 // connection won't be closed. 123 132 net.user.events <- eventUpstreamConnected{uc} 124 133 if err := uc.readMessages(net.user.events); err != nil { … … 132 141 133 142 func (net *network) stop() { 134 select { 135 case <-net.stopped: 136 return 137 default: 143 if !net.isStopped() { 138 144 close(net.stopped) 139 145 }
Note:
See TracChangeset
for help on using the changeset viewer.