Merge "flow/manager: Make TestDialCachedConn actually test something."
diff --git a/runtime/internal/rpc/xserver.go b/runtime/internal/rpc/xserver.go
index 8b3b892..10ed8a0 100644
--- a/runtime/internal/rpc/xserver.go
+++ b/runtime/internal/rpc/xserver.go
@@ -55,9 +55,6 @@
 	chosenEndpoints   []*inaming.Endpoint
 	typeCache         *typeCache
 
-	// state of proxies keyed by the name of the proxy
-	proxies map[string]proxyState
-
 	disp               rpc.Dispatcher // dispatcher to serve RPCs
 	dispReserved       rpc.Dispatcher // dispatcher for reserved methods
 	active             sync.WaitGroup // active goroutines we've spawned.
@@ -103,7 +100,6 @@
 		principal:         principal,
 		blessings:         principal.BlessingStore().Default(),
 		publisher:         publisher.New(ctx, ns, publishPeriod),
-		proxies:           make(map[string]proxyState),
 		stoppedChan:       make(chan struct{}),
 		ns:                ns,
 		stats:             newRPCStats(statsPrefix),
@@ -247,10 +243,18 @@
 	s.Lock()
 	defer s.Unlock()
 	var lastErr error
+	if len(listenSpec.Proxy) > 0 {
+		lastErr = s.flowMgr.Listen(ctx, inaming.Network, listenSpec.Proxy)
+		if lastErr != nil {
+			s.ctx.VI(2).Infof("Listen(%q, %q, ...) failed: %v", inaming.Network, listenSpec.Proxy, lastErr)
+		}
+	}
 	for _, addr := range listenSpec.Addrs {
 		if len(addr.Address) > 0 {
 			lastErr = s.flowMgr.Listen(ctx, addr.Protocol, addr.Address)
-			s.ctx.VI(2).Infof("Listen(%q, %q, ...) failed: %v", addr.Protocol, addr.Address, lastErr)
+			if lastErr != nil {
+				s.ctx.VI(2).Infof("Listen(%q, %q, ...) failed: %v", addr.Protocol, addr.Address, lastErr)
+			}
 		}
 	}
 
diff --git a/services/device/deviced/internal/starter/starter.go b/services/device/deviced/internal/starter/starter.go
index 3ad0a74..0849d6a 100644
--- a/services/device/deviced/internal/starter/starter.go
+++ b/services/device/deviced/internal/starter/starter.go
@@ -173,16 +173,30 @@
 	}
 	var epName string
 	if args.Device.ListenSpec.Proxy != "" {
-		for {
-			p := server.Status().Proxies
-			if len(p) == 0 {
+		if os.Getenv("V23_RPC_TRANSITION_STATE") == "xservers" {
+			for {
+				eps := server.Status().Endpoints
+				if len(eps) > 0 && len(eps[0].Addr().Network()) > 0 {
+					epName = eps[0].Name()
+					ctx.Infof("Proxied address: %s", epName)
+					break
+				}
 				ctx.Infof("Waiting for proxy address to appear...")
 				time.Sleep(time.Second)
-				continue
 			}
-			epName = p[0].Endpoint.Name()
-			ctx.Infof("Proxied address: %s", epName)
-			break
+		} else {
+			// TODO(suharshs): Remove this else block once the transition is complete.
+			for {
+				p := server.Status().Proxies
+				if len(p) == 0 {
+					ctx.Infof("Waiting for proxy address to appear...")
+					time.Sleep(time.Second)
+					continue
+				}
+				epName = p[0].Endpoint.Name()
+				ctx.Infof("Proxied address: %s", epName)
+				break
+			}
 		}
 	} else {
 		if len(endpoints) == 0 {