Dbus in Multi-threaded application

Abhi Arora <[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <PN1PR01MB0368C9469269D7DC7A9ABFDBFA990@PN1PR01MB0368.INDPRD01.PROD.OUTLOOK.COM>
Hello Community,


I have developed an application for BLE using DBUS for Linux. It is working fine but sometimes I have seen seg fault.


My application has a single event loop thread for dbus (THREAD A). I have used glib event loop. It is exactly similar to "bluetoothctl" event loop implementation: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/gdbus/mainloop.c . I using that thread for receiving signal and error dbus messages using filter callbacks (by using function "dbus_connection_add_filter"). I have set watch and timeout handlers using glib implementation (by calling dbus_connection_set_watch_functions, dbus_connection_set_timeout_functions and dbus_connection_set_dispatch_status_function). You can check the above link as i have using their code.


My main thread (THREAD B) calls dbus methods and block on pending call instance for replies. I am not sure whether there could be some race condition with current software architecture as I have seen seg fault and valgrind showed it was related to invalid memory read and write in my timeout implementation. Unfortunately, I was not able to record the valgrind output and seg fault never occured after that. I just want to be sure I am doing it correctly so I won't see seg fault if I release my software.


For example, THREAD B calls a dbus method and it has set a timeout for it. I will then block on it. The THREAD A may dispatch a timeout event if timeout has occurred. I am not completely sure but I think there could be some race condition in this case. Please help me.


Thanks

_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.