summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-10-30 00:24:54 +0000
committergVisor bot <gvisor-bot@google.com>2019-10-30 00:24:54 +0000
commit133f39d1945a9adfb467b724c94c8d6466f9c17d (patch)
treef69da60d965c5ce0f81c09f6838d0754c72d7319 /pkg
parent06ea1e9d8d3c90b2ed0fb5e37671d3c13e9488ff (diff)
parentdc21c5ca16dbc43755185ffdf53764c7bb4c3a12 (diff)
Merge release-20190806.1-344-gdc21c5c (automated)
Diffstat (limited to 'pkg')
-rw-r--r--pkg/tcpip/stack/stack.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go
index 360c54b2d..6d6ddc0ff 100644
--- a/pkg/tcpip/stack/stack.go
+++ b/pkg/tcpip/stack/stack.go
@@ -1210,6 +1210,37 @@ func (s *Stack) RestoreCleanupEndpoints(es []TransportEndpoint) {
s.mu.Unlock()
}
+// Close closes all currently registered transport endpoints.
+//
+// Endpoints created or modified during this call may not get closed.
+func (s *Stack) Close() {
+ for _, e := range s.RegisteredEndpoints() {
+ e.Close()
+ }
+}
+
+// Wait waits for all transport and link endpoints to halt their worker
+// goroutines.
+//
+// Endpoints created or modified during this call may not get waited on.
+//
+// Note that link endpoints must be stopped via an implementation specific
+// mechanism.
+func (s *Stack) Wait() {
+ for _, e := range s.RegisteredEndpoints() {
+ e.Wait()
+ }
+ for _, e := range s.CleanupEndpoints() {
+ e.Wait()
+ }
+
+ s.mu.RLock()
+ defer s.mu.RUnlock()
+ for _, n := range s.nics {
+ n.linkEP.Wait()
+ }
+}
+
// Resume restarts the stack after a restore. This must be called after the
// entire system has been restored.
func (s *Stack) Resume() {