GMainLoop and D-Bus : My application exits silently



Hello everyone!

I'm trying to use D-Bus/GLib binding to write a D-Bus application. First, I know I should use the D-Bus support in GLib but as I have the Glib 2.24 available with my toolchain, I'm using the D-Bus Glib binding...

I have my application main loop and the GMainLoop to catch D-Bus signals I registered to. However, sometime my application exits "silently" and I don't know why, this means no special error (segmentation fault, ...), not through my own main and returns an error code of 1:
# ./dbusTest 
/* Some output of my program ... */
# echo $?
1

It stops running when a call a method on D-Bus, sometime :-p. I think my D-Bus method call is working because this works for a while until it quits silently... 
callOk = dbus_g_proxy_call(m_pDbPrIface, "Scan", &error,
        DBUS_TYPE_G_MAP_OF_VARIANT, params, G_TYPE_INVALID, // Call param
        G_TYPE_INVALID);                                    // Ret. param

I'm suspecting the GLib main loop doing too much for me. However as I don't have much log, I don't really know where the problem comes from. I tried to catch the GLib logs with g_log_set_handler but nothing comes!
// Enable GLib logging facility
logLevelFlags = (GLogLevelFlags)(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_ERROR |
        G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE |
        G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG);
g_log_set_handler("GLib", logLevelFlags, log_glib, NULL);

This is how I start my GMainLoop. This is done in a separated thread of my application:
/* Do some D-Bus initialization */
// Initialize and run glib main loop to catch D-Bus messages
m_pMainLoop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(m_pMainLoop);
logWarn(LOG_IMPL, "Left Glib main loop!");
uninitDBusConnection();

How can I enable some GLib debug facility to see why my programm is exiting? Is my design correct (running both main loop from separated thread) or should I use the "g_main_context_iteration()" to have a better control on the D-Bus (GLib) main loop? Is GLib using signals I don't/can't catch?

Any pointers is strongly appreciated!

Regards,

Guy Morand


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]