Hi,<br><br>Im working on an application which doesnt use a main loop but the following construct:<br><br><br>while (1) {<br> dbus_connection_read_write(dbus_conn, 0);<br> msg = dbus_connection_pop_message(dbus_conn);<br>
if (NULL == msg ) { <br> //check if user wants to cancel the loop and if yes send the Signal/Message "DiscoveryCompleted"<br> <br> <br> usleep(300000);<br>
continue;<br> }<br> if (dbus_message_is_signal(msg, "org.bluez.Adapter", "RemoteDeviceFound")) {<br> //do something<br> }<br><br> else if (dbus_message_is_signal(msg, "org.bluez.Adapter", "DiscoveryCompleted")){<br>
<br> break; //cancel condition<br> }<br>}<br><br>As you can see Im working with bluez libs. Anyway my question if this construct is really safe.<br>Im afraid of an infinite loop. <br>The problem might be if the message/signal DiscoveryCompleted gets lost <br>
Well I can check if the message DiscoveryCompleted could be sent probably, but if it gets lost on the bus or the bus crashes then<br>this construct ends up in an infinite loop. How likely is this scenario of an infinite loop?<br>
Unfortunately using a simple variable as flag to cancel the loop is not possible since I have to get rid of the message DiscoveryCompleted.<br>Because if this message gets not read and deleted from the bus a new session gets canceled before it can even start.<br>
<br>Hope you got my problem<br><br>thanks<br><br><br clear="all"><br>-- <br>Regards,<br>--Codefritz<br><br><br><br>