Bug 876396

Summary: systemd-inhibit integration issue with mate-power-manager
Product: [Fedora] Fedora Reporter: William Brown <william>
Component: systemdAssignee: systemd-maint
Status: CLOSED UPSTREAM QA Contact: Dan Mashal <dan.mashal>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: alekcejk, dan.mashal, johannbg, lnykryn, metherid, msekleta, notting, plautrba, systemd-maint, vpavlin
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-11-20 23:10:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 869998    
Bug Blocks:    

Description William Brown 2012-11-14 02:05:09 UTC
Description of problem:

attempting to use the systemd-inhibitors via dbus yields no inhibition of sleep. The code doing this is below. Once called, we leave the proxy and fd open, and close them both in the "finalize" of the application. From the debug logs we see:

TI:12:24:54	TH:0x142ced0	FI:gpm-manager.c	FN:gpm_manager_systemd_inhibit,1862
 - Inhibiting systemd sleep
TI:12:24:54	TH:0x142ced0	FI:gpm-manager.c	FN:gpm_manager_systemd_inhibit,1889
 - Inhibiting systemd sleep - fd = 21537632
TI:12:24:54	TH:0x142ced0	FI:gpm-manager.c	FN:gpm_manager_systemd_inhibit,1895
 - Inhibiting systemd sleep - success


Which indicates the call is suceeding and the fd is being returned. However, running systemd-inhibt --list shows no active inhibitors. 

Advice on how to get this integration to work with systemd is much appreciated. 


    /* Return a fd to the to the inhibitor, that we can close on exit. */
	//GDBusProxy *proxy;
    GError *error = NULL;
    gint32 r = -1;

    proxy == NULL;
    /* Should we define these elsewhere? */
    const char* arg_what = "handle-power-key:handle-suspend-key:handle-lid-switch";
    const char* arg_who = "mate-power-manager";
    const char* arg_why = "Mate power manager handles these events";
    const char* arg_mode = "block";

	egg_debug ("Inhibiting systemd sleep");
    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
                                        NULL,
                                        "org.freedesktop.login1",
                                        "/org/freedesktop/login1",
                                        "org.freedesktop.login1.Manager",
                                        NULL,
                                        &error );
    //append all our arguments
    if (proxy == NULL) {
        egg_error("Error connecting to dbus - %s", error->message);
        g_error_free (error);
        return -1;
    }
    r = g_dbus_proxy_call_sync (proxy, "Inhibit", 
                            g_variant_new( "(ssss)",
                                arg_what,
                                arg_who,
                                arg_why,
                                arg_mode
                            ),
                            G_DBUS_CALL_FLAGS_NONE,
                            -1,
                            NULL,
                            &error
                            );                        
	egg_debug ("Inhibiting systemd sleep - fd = %i", r);
    if (r < 1) {
        egg_error ("Error in dbus - %s", error->message);
        g_error_free (error);
        return -EIO;    
    }
    egg_debug ("Inhibiting systemd sleep - success");
    return r;

Comment 1 William Brown 2012-11-19 22:45:10 UTC
Besides working out that r is a pointer to a variant, and my code now having the code to get this value out.

Every time I recieve the fd from the variant, it is *always* 0. How can this issue be resolved and tracked down.