veyron2/context: Allow users to remove cancellation and deadlines from contexts.
Also remove the previous hack that prevented unmounting from being canceled.
Change-Id: I23ec4f1441de9a0b74f72df80ca84b86f4d000ff
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 936402c..7fc7546 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -40,6 +40,7 @@
sync.Mutex
state serverState // track state of the server.
ctx *context.T // context used by the server to make internal RPCs.
+ cancel context.CancelFunc // function to cancel the above context.
streamMgr stream.Manager // stream manager to listen for new flows.
publisher publisher.Publisher // publisher to publish mounttable mounts.
listenerOpts []stream.ListenerOpt // listener opts for Listen.
@@ -147,10 +148,12 @@
func (ReservedNameDispatcher) IPCServerOpt() {}
func InternalNewServer(ctx *context.T, streamMgr stream.Manager, ns naming.Namespace, client ipc.Client, opts ...ipc.ServerOpt) (ipc.Server, error) {
+ ctx, cancel := context.WithRootCancel(ctx)
ctx, _ = vtrace.SetNewSpan(ctx, "NewServer")
statsPrefix := naming.Join("ipc", "server", "routing-id", streamMgr.RoutingID().String())
s := &server{
ctx: ctx,
+ cancel: cancel,
streamMgr: streamMgr,
publisher: publisher.New(ctx, ns, publishPeriod),
listeners: make(map[stream.Listener]struct{}),
@@ -842,6 +845,7 @@
return verror.Make(verror.Internal, s.ctx, firstErr)
}
s.state = stopped
+ s.cancel()
return nil
}