Commit f4546a18 authored by Peter Hutterer's avatar Peter Hutterer Committed by George Kiagiadakis
Browse files

m-reserve-device: replace the hash table key on new insert

We're using the WpReserveDevice's name as key in the hash table, so we
must update the key as well when we replace an item in the hashtable -
the old device (and its name) will be released.

The side-effect of this is that the *third* device with an identical
name will no longer replace the previous device. This results in the
following sequence:

- dev1 added: name Audio0
  - dev1 requests name owner Audio0
- dev2 added: name Audio0
  - replace dev1 in the hashtable
     - dev1 emits "release" signal
     - dev1 unowns the Audio0 name
  - dev2 requests name owner Audio0
- dev3 added: name Audio0
  - adds to the hashtable because the existing key is now undefined
  - dev3 requests name owner Audio0
     - error, you cannot request ownership for the same name twice

Fixes #93
parent f7e8bad4
Pipeline #448945 passed with stages
in 2 minutes and 57 seconds
......@@ -221,7 +221,7 @@ wp_reserve_device_plugin_create_reservation (WpReserveDevicePlugin *self,
/* use rd->name to avoid copying @em name again */
g_hash_table_insert (self->reserve_devices, rd->name, rd);
g_hash_table_replace (self->reserve_devices, rd->name, rd);
return g_object_ref (rd);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment