mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-23 01:11:40 +00:00
ipnlocal: ensure TailFS share notifications are non-nil
This allows the UI to distinguish between 'no shares' versus 'not being notified about shares'. Updates ENG-2843 Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:
parent
20e9f3369d
commit
067ed0bf6f
@ -274,6 +274,10 @@ func (b *LocalBackend) tailFSSetSharesLocked(shares []*tailfs.Share) error {
|
|||||||
// tailFSNotifyShares notifies IPN bus listeners (e.g. Mac Application process)
|
// tailFSNotifyShares notifies IPN bus listeners (e.g. Mac Application process)
|
||||||
// about the latest list of shares.
|
// about the latest list of shares.
|
||||||
func (b *LocalBackend) tailFSNotifyShares(shares views.SliceView[*tailfs.Share, tailfs.ShareView]) {
|
func (b *LocalBackend) tailFSNotifyShares(shares views.SliceView[*tailfs.Share, tailfs.ShareView]) {
|
||||||
|
// Ensures shares is not nil to distinguish "no shares" from "not notifying shares"
|
||||||
|
if shares.IsNil() {
|
||||||
|
shares = views.SliceOfViews(make([]*tailfs.Share, 0))
|
||||||
|
}
|
||||||
b.send(ipn.Notify{TailFSShares: shares})
|
b.send(ipn.Notify{TailFSShares: shares})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,10 +293,6 @@ func (b *LocalBackend) tailFSNotifyCurrentSharesLocked() {
|
|||||||
lastNotified := b.lastNotifiedTailFSShares.Load()
|
lastNotified := b.lastNotifiedTailFSShares.Load()
|
||||||
if lastNotified == nil || !tailFSShareViewsEqual(lastNotified, shares) {
|
if lastNotified == nil || !tailFSShareViewsEqual(lastNotified, shares) {
|
||||||
// Do the below on a goroutine to avoid deadlocking on b.mu in b.send().
|
// Do the below on a goroutine to avoid deadlocking on b.mu in b.send().
|
||||||
if shares.IsNil() {
|
|
||||||
// set to a non-nil value to indicate we have 0 shares
|
|
||||||
shares = views.SliceOfViews(make([]*tailfs.Share, 0))
|
|
||||||
}
|
|
||||||
go b.tailFSNotifyShares(shares)
|
go b.tailFSNotifyShares(shares)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user