control/controlclient: allow multiple non-streaming map requests (#19106)
A client with an active streaming session would break if using the same client for a non-streaming session. Allow the client 1 streaming and n non-streaming sessions at the same time. Fixes #19105 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
@@ -1121,18 +1121,22 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.streamingMapSession != nil {
|
if isStreaming && c.streamingMapSession != nil {
|
||||||
panic("mapSession is already set")
|
panic("mapSession is already set")
|
||||||
}
|
}
|
||||||
|
|
||||||
sess := newMapSession(persist.PrivateNodeKey(), nu, c.controlKnobs)
|
sess := newMapSession(persist.PrivateNodeKey(), nu, c.controlKnobs)
|
||||||
c.streamingMapSession = sess
|
if isStreaming {
|
||||||
defer func() {
|
c.streamingMapSession = sess
|
||||||
sess.Close()
|
defer func() {
|
||||||
c.mu.Lock()
|
sess.Close()
|
||||||
c.streamingMapSession = nil
|
c.mu.Lock()
|
||||||
c.mu.Unlock()
|
c.streamingMapSession = nil
|
||||||
}()
|
c.mu.Unlock()
|
||||||
|
}()
|
||||||
|
} else {
|
||||||
|
defer sess.Close()
|
||||||
|
}
|
||||||
sess.cancel = cancel
|
sess.cancel = cancel
|
||||||
sess.logf = c.logf
|
sess.logf = c.logf
|
||||||
sess.vlogf = vlogf
|
sess.vlogf = vlogf
|
||||||
|
|||||||
Reference in New Issue
Block a user