-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Description
Exception Thrown When Unregistering GATT Application in Incorrect Order
Environment
- OS Distro: _Ubuntu v22.04
- Linux.Bluetooth Version:5.66
Severity (1-5)
4=(ends up leaking if not addressed)
Steps To Reproduce
Steps to reproduce the behavior:
- Modify the
UnregisterGattApplicationin theGattServer.csclass with Debug traces and try/catch - Run any sample that starts the GattServer and registers an application service with at least one characteristic
- Call the unregister and look at the traces
Expected Behavior
You should not see exceptions thrown
Current traces with modified code
Error unregistering GATT application: Tmds.DBus.DBusException: org.freedesktop.DBus.Error.UnknownObject: Method "UnregisterApplication" with signature "o" on interface "org.bluez.GattManager1" doesn't exist
at Tmds.DBus.DBusConnection.CallMethodAsync(Message msg, Boolean checkConnected, Boolean checkReplyType)
at Tmds.DBus.Connection.CallMethodAsync(Message message)
at Tmds.DBus.CodeGen.DBusObjectProxy.SendMethodReturnReaderAsync(String iface, String member, Nullable`1 inSignature, MessageWriter writer)
at Linux.Bluetooth.GattServer.GattServer.UnregisterGattApplication() in C:\_Src\Sdbx\Linux.Bluetooth\src\Linux.Bluetooth\GattServer\GattServer.cs:line 162
Additional context
Here is the code fix, with the additional traces to demonstrate it works:
public async Task UnregisterGattApplication()
{
try
{
if (_gattApplication is not null)
{
await _gattManager.UnregisterApplicationAsync(_gattApplication.ObjectPath);
foreach (GattService service in _gattApplication.Services)
{
foreach (GattCharacteristicServer characteristic in service.Characteristics)
{
// delete this
foreach (GattDescriptor descriptor in characteristic.Descriptors)
{
Debug.WriteLine($"Unregistering descriptor {descriptor.ObjectPath}...");
}
Connection.UnregisterObjects(characteristic.Descriptors);
}
// delete this
foreach (var characteristic in service.Characteristics)
{
Debug.WriteLine($"Unregistering characteristic {characteristic.ObjectPath}...");
}
Connection.UnregisterObjects(_gattApplication.Services);
}
}
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error unregistering GATT application: {ex}");
}
_gattApplication = null;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
6.0.xv6.0.xv6.0.x