Hi,<br><br>Im working on an application which doesnt use a main loop but the following construct:<br><br><br>while (1) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dbus_connection_read_write(dbus_conn, 0);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; msg = dbus_connection_pop_message(dbus_conn);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (NULL == msg ) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //check if user wants to cancel the loop and if yes send the Signal/Message &quot;DiscoveryCompleted&quot;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; usleep(300000);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; continue;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (dbus_message_is_signal(msg, &quot;org.bluez.Adapter&quot;, &quot;RemoteDeviceFound&quot;)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //do something<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (dbus_message_is_signal(msg, &quot;org.bluez.Adapter&quot;, &quot;DiscoveryCompleted&quot;)){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; //cancel condition<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<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>