Cleaning up dbus connection in the GLib Application area after a dbus daemon failover

I have an application written in vala which communicates to another process (written in vala) using dbus-daemon. It works fine. But it fails to communicate after dbus-daemon is restarted.

My application ( which is not restarted) tries to re connect to the dbus daemon after dbus daemon is restarted. I have cleanup code for the dbus connection references within my application area. But the GTK.Application initiates dbus connection for its use. This is not cleaned up after dbus daemon is terminated.

Since the references of dbus-connection is not cleaned in the GTK.Application, the dbus-connection returned after failover remains the same and it returns “connection is closed” error for dbus operations.

Is there a way to do a cleanup ( basically remove the references of dbus-connection) in the GTK.Application code? Or anybody has tried to exclude the dbus-connection initiation in the GTK.Application code during startup?

During my debugging, I tried the following.

I tried to unref the dbus-connection 4-5 times ( within my dbus cleanup code), and then the reconnection to the dbus-daemon would work. This means the dbus-connection is in use in some other area (I assume, GTK.Application code) and it is not properly cleaned up after the dbus-daemon is terminated. When I do unref ( for debugging purpose) 4-5 times in the cleanup code, and then if I stop my application, it results in segmentation fault in the GTK.Application code area ( which is explainable as the stale memory pointers of dbus-connection is still in use in GTK.Application code.

May I ask you why are you restarting the dbus service in the first place?

Bob, Thanks for the response.
I am having a session dbus-daemon specifically for my applications. This dbus-daemon is started from my backend application and the life of it is the same as the backend application. When backend application is stopped (for some reason), I would stop the dbus daemon as well.
So after the fail over, there will be a new dbus daemon and hence I need to reconnect to the new dbus-daemon from my client applications.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.