From ba0310894bffdb2f8bc2072a4965e347c97e489b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Ros=C3=A9n?= Date: Mon, 13 Dec 2021 20:16:36 +0100 Subject: [PATCH] fix(SubscribeState): add the path to the recieved chan type also remove the check for the signal to be the current path since this will block us from receiving updates to the actual object before it only signaled on when we deactivated, since the activation happens on another device. --- ActiveConnection.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ActiveConnection.go b/ActiveConnection.go index 3f6e3dc..b06cc9b 100644 --- a/ActiveConnection.go +++ b/ActiveConnection.go @@ -2,6 +2,7 @@ package gonetworkmanager import ( "fmt" + "github.com/godbus/dbus/v5" ) @@ -220,6 +221,7 @@ func (a *activeConnection) GetPropertyMaster() (Device, error) { } type StateChange struct { + Path dbus.ObjectPath State NmActiveConnectionState Reason NmActiveConnectionStateReason } @@ -243,17 +245,17 @@ func (a *activeConnection) SubscribeState(receiver chan StateChange, exit chan s for { select { case signal, ok := <-channel: - if !ok { err = fmt.Errorf("connection closed for %s", ActiveConnectionSignalStateChanged) return } - if signal.Path != a.GetPath() || signal.Name != ActiveConnectionInterface+"."+ActiveConnectionSignalStateChanged { + if signal.Name != ActiveConnectionInterface+"."+ActiveConnectionSignalStateChanged { continue } stateChange := StateChange{ + Path: signal.Path, State: NmActiveConnectionState(signal.Body[0].(uint32)), Reason: NmActiveConnectionStateReason(signal.Body[1].(uint32)), }