netstack: update goroutine save / restore safety comments.

PiperOrigin-RevId: 204930314
Change-Id: Ifc4c41ed28616cd57fafbf7c92e87141a945c41f
This commit is contained in:
Zhaozhong Ni
2018-07-17 10:15:00 -07:00
committed by Shentubot
parent 29e00c943a
commit beb89bb757
6 changed files with 12 additions and 6 deletions
+4 -1
View File
@@ -108,7 +108,10 @@ func New(opts *Options) tcpip.LinkEndpointID {
// dispatches them via the provided dispatcher.
func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) {
e.attached = true
go e.dispatchLoop(dispatcher) // S/R-FIXME
// Link endpoints are not savable. When transportation endpoints are
// saved, they stop sending outgoing packets and all incoming packets
// are rejected.
go e.dispatchLoop(dispatcher) // S/R-SAFE: See above.
}
// IsAttached implements stack.LinkEndpoint.IsAttached.
+4 -1
View File
@@ -142,7 +142,10 @@ func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) {
if !e.workerStarted && atomic.LoadUint32(&e.stopRequested) == 0 {
e.workerStarted = true
e.completed.Add(1)
go e.dispatchLoop(dispatcher) // S/R-FIXME
// Link endpoints are not savable. When transportation endpoints
// are saved, they stop sending outgoing packets and all
// incoming packets are rejected.
go e.dispatchLoop(dispatcher) // S/R-SAFE: see above.
}
e.mu.Unlock()
}
+1 -1
View File
@@ -187,7 +187,7 @@ func main() {
// Start the writer in its own goroutine.
writerCompletedCh := make(chan struct{})
go writer(writerCompletedCh, ep) // S/R-FIXME
go writer(writerCompletedCh, ep) // S/R-SAFE: sample code.
// Read data and write to standard output until the peer closes the
// connection from its side.
+1 -1
View File
@@ -187,6 +187,6 @@ func main() {
log.Fatal("Accept() failed:", err)
}
go echo(wq, n) // S/R-FIXME
go echo(wq, n) // S/R-SAFE: sample code.
}
}
+1 -1
View File
@@ -262,7 +262,7 @@ func (c *linkAddrCache) startAddressResolution(k tcpip.FullAddress, linkRes Link
e := c.makeAndAddEntry(k, "")
e.addWaker(waker)
go func() { // S/R-FIXME
go func() { // S/R-SAFE: link non-savable; wakers dropped synchronously.
for i := 0; ; i++ {
// Send link request, then wait for the timeout limit and check
// whether the request succeeded.
+1 -1
View File
@@ -90,7 +90,7 @@ func (f *Forwarder) HandlePacket(r *stack.Route, id stack.TransportEndpointID, v
// Launch a new goroutine to handle the request.
f.inFlight[id] = struct{}{}
s.incRef()
go f.handler(&ForwarderRequest{ // S/R-FIXME
go f.handler(&ForwarderRequest{ // S/R-SAFE: not used by Sentry.
forwarder: f,
segment: s,
synOptions: opts,