My point was that since the socket connection is accepted asynchronously, it would still be possible for a misbehaving device to block it, since, the connection could be accepted just before the misbehaving device is polled on the separate device thread, regardless of the order of devices in possibly_connected.
Without looking at the wireless driver code, I'm guessing that the reason it waits for a fixed time, is that it doesn't know if there is a currently connected device in the device thread? My inclination would be to add some API to the device driver interface so that the device thread can notify any drivers that it is already connected and therefore, they should abort any connection attempts. Then the connection thread can simply wait forever, until either the device subsytem informs it that it is connected, or actually tries to connect.
|