On Wed, 2008-01-30 at 17:31 +0000, Bastien Nocera wrote: > On Tue, 2008-01-29 at 18:01 +0100, Marcel Holtmann wrote: > > Hi Bastien, > > > > > Some time ago I had problems with client.c's architecture. It would > > > allow me to easily report completed discoveries without causing crashes. > > > > > > The attached patch moves all the static variables into the main > > > BluetoothClient object, and instead of return a new object when using > > > _new() we return an existing instance of the client. > > > > > > This makes no changes to the external API for the BluetoothClient, and > > > should work just as well as older versions did. > > > > patch has been applied. Don't really see the difference, but I am okay > > with doing it this way. > > > > > A couple of bugs I found in client.c: > > > - launch test-client with a dongle inserted, remove and reinsert the > > > dongle, the bdaddr of the device is not set anymore > > > - launch test-client without a dongle inserted, insert it, the bdaddr is > > > not set and there's no children to the adapter (although there are if > > > inserted when started) > > Both of those are a race: > When the AdapterAdded signal is launched in hcid, the address isn't > available yet. It is available when "ModeChanged" has been launched > though. > > hcid_dbus_register_device() setups the structures, and launched > AdapterAdded, but the address is only set when hcid_dbus_start_device() > is called (and the ModeChanged signal is launched). > > How do you think we should be handling that? I would think we should > make GetAddress fail if the data isn't available yet, or hack around it > in client.c and only setup the adapters when the mode changes. The easy fix for hcid attached (the default bdaddr should be 00:00:00:00:00:00:00, not an empty string). And also a patch for client.c to get the device address again when the device changes mode, so we can change it in the tree from the default all-zeros address to the real one. I'll fix the other bugs now. Cheers