Replacing evil looping code

Havoc Pennington hp at redhat.com
Mon Nov 6 08:37:55 PST 2006



>>     while (!dbus_pending_call_get_completed (pending_call) &&
>>            dbus_connection_read_write_dispatch 
>> (connection->connection, -1))
>>         ;
>>

Oh, in case someone cut-and-pastes from the archives, I want to 
underline where you said this is a private connection. Doing this on a 
normal (shared) bus connection from dbus_bus_get() would be pretty scary 
since all sorts of stuff could get dispatched; and if this code weren't 
in the main thread, the dispatching would be in the wrong thread.

Doing the above minus the _dispatch() part would be just fine on a 
shared connection though, even from another thread.

Havoc



More information about the dbus mailing list