After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 790714 - Fix regression and issues from patchset in bug #782530
Fix regression and issues from patchset in bug #782530
Status: RESOLVED FIXED
Product: gnome-bluetooth
Classification: Core
Component: general
unspecified
Other All
: Normal critical
: ---
Assigned To: gnome-bluetooth-general-maint@gnome.bugs
gnome-bluetooth-general-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2017-11-22 15:03 UTC by Benjamin Berg
Modified: 2017-11-23 12:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
lib: Fix parameters of interface_removed call (951 bytes, patch)
2017-11-22 15:04 UTC, Benjamin Berg
committed Details | Review
lib: Listen to object addition and removal on the bus (2.53 KB, patch)
2017-11-22 15:04 UTC, Benjamin Berg
needs-work Details | Review
lib: Keep references to adapters and unused devices (1.40 KB, patch)
2017-11-22 15:04 UTC, Benjamin Berg
committed Details | Review
lib: Fix updating device and adapter list after initialization (2.45 KB, patch)
2017-11-22 18:09 UTC, Benjamin Berg
none Details | Review
lib: Fix updating device and adapter list after initialization (2.45 KB, patch)
2017-11-22 19:37 UTC, Benjamin Berg
committed Details | Review
lib: Fix updating device and adapter list after initialization (2.45 KB, patch)
2017-11-23 12:21 UTC, Benjamin Berg
committed Details | Review

Description Benjamin Berg 2017-11-22 15:03:59 UTC
The patchset in bug #782530 fixed a race condition. Unfortunately some
regressions were introduce.
Comment 1 Benjamin Berg 2017-11-22 15:04:03 UTC
Created attachment 364203 [details] [review]
lib: Fix parameters of interface_removed call

Patch 17983ace (lib: Use GDBusObjectManager) ported the interface
addition and removal to GDBusObjectManager. However the parameter list
of interface_remove was not updated correctly.
Comment 2 Benjamin Berg 2017-11-22 15:04:09 UTC
Created attachment 364204 [details] [review]
lib: Listen to object addition and removal on the bus

Patch 17983ace (lib: Use GDBusObjectManager) only added listeners for
interface-added and interface-removed. However, as GDBusObjectManager
simplifies the API to emit object-added/-removed those have to be
listened for changes too.

Without this the list of bluetooth devices and adapters is never updated
after the initial object listing.
Comment 3 Benjamin Berg 2017-11-22 15:04:15 UTC
Created attachment 364205 [details] [review]
lib: Keep references to adapters and unused devices

Patch 17983ace (lib: Use GDBusObjectManager) changes the logic of
device_add and adapter_add so that the device/adapter object is passsed
in. Because of that the object must not be unref'ed anymore, as it is
owned by the surrounding code (i.e. GDBusObjectManager).
Comment 4 Bastien Nocera 2017-11-22 16:19:55 UTC
Review of attachment 364203 [details] [review]:

Ha, signal callbacks and C :/

Can you please change the subject to something more like:
"lib: Fix crash when disconnecting certain devices"

Which I think is the only case where bluetoothd removes interfaces from devices.
Comment 5 Bastien Nocera 2017-11-22 16:25:12 UTC
Review of attachment 364204 [details] [review]:

> Listen to object addition and removal on the bus

> Without this the list of bluetooth devices and adapters is never updated
> after the initial object listing.

Can you please put this explanation in the commit subject? I prefer the subject to show the impact of the patch, and the body to contain how it was fixed. Makes writing NEWS files, and backporting patches easier.

::: lib/bluetooth-client.c
@@ +733,3 @@
+	      BluetoothClient    *client)
+{
+	GList *interfaces, *li;

Please use "*l" for the iterator instead of "li".

@@ +737,3 @@
+	interfaces = g_dbus_object_get_interfaces (object);
+	li = interfaces;
+	while (li) {

I prefer:
for (l = interfaces; l != NULL; l = l->next)
rather than a while loop.

If you find a way to reduce the code duplication between those 2 functions, that would also be nice (I couldn't find something that would end up being shorter and more readable on top of my head).
Comment 6 Bastien Nocera 2017-11-22 16:26:51 UTC
Review of attachment 364205 [details] [review]:

> lib: Keep references to adapters and unused devices

"lib: Fix possible crash when devices or adapters are added" ?

Looks good otherwise.
Comment 7 Benjamin Berg 2017-11-22 18:09:25 UTC
Created attachment 364220 [details] [review]
lib: Fix updating device and adapter list after initialization

Patch 17983ace (lib: Use GDBusObjectManager) only added listeners for
interface-added and interface-removed. However, as GDBusObjectManager
simplifies the API to emit object-added/-removed those have to be
listened for changes too.

Without this the list of bluetooth devices and adapters is never updated
after the initial object listing.
Comment 8 Bastien Nocera 2017-11-22 19:01:30 UTC
Review of attachment 364220 [details] [review]:

::: lib/bluetooth-client.c
@@ +732,3 @@
+
+	for (l = interfaces; l != NULL; l = l->next)
+		interface_added (manager, object, G_DBUG_INTERFACE (l->data), client);

Can you please compile-test the patches before uploading them? :)
I doubt G_DBUG_INTERFACE is going to work.
Comment 9 Benjamin Berg 2017-11-22 19:37:06 UTC
Created attachment 364226 [details] [review]
lib: Fix updating device and adapter list after initialization

Patch 17983ace (lib: Use GDBusObjectManager) only added listeners for
interface-added and interface-removed. However, as GDBusObjectManager
simplifies the API to emit object-added/-removed those have to be
listened for changes too.

Without this the list of bluetooth devices and adapters is never updated
after the initial object listing.
Comment 10 Benjamin Berg 2017-11-22 19:37:56 UTC
(In reply to Bastien Nocera from comment #8)
> Can you please compile-test the patches before uploading them? :)
> I doubt G_DBUG_INTERFACE is going to work.

Haha, and I was sure I had tested that change together with the agent stuff :)
Comment 11 Bastien Nocera 2017-11-23 10:45:25 UTC
Review of attachment 364226 [details] [review]:

Looks good.
Comment 12 Benjamin Berg 2017-11-23 12:20:52 UTC
The following fix has been pushed:
d09e649 lib: Fix updating device and adapter list after initialization
Comment 13 Benjamin Berg 2017-11-23 12:21:10 UTC
Created attachment 364268 [details] [review]
lib: Fix updating device and adapter list after initialization

Patch 17983ace (lib: Use GDBusObjectManager) only added listeners for
interface-added and interface-removed. However, as GDBusObjectManager
simplifies the API to emit object-added/-removed those have to be
listened for changes too.

Without this the list of bluetooth devices and adapters is never updated
after the initial object listing.