Skip to content

Commit

Permalink
[dbus] Block suspend also during method calls that bypasses mce-dbus.…
Browse files Browse the repository at this point in the history
… Contributes to JB#32462

Previously it was not possible to cancel method calls made with the
helper functions provided by mce-dbus. For this reason the mce code
base has several places where method calls are made using libdbus api
directly.

Make sure that also the code that uses libdbus api gets similar
suspend blocking protection as code using dbus_send_ex() from mce-dbus.
  • Loading branch information
spiiroin committed Oct 9, 2015
1 parent eec2fcb commit db55c71
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mce-dbus.c
Expand Up @@ -98,6 +98,21 @@ static void mdb_callgate_attach(DBusPendingCall *pc)
g_free(name);
}

/** Public function for making dbus method calls suspend proof
*
* NOTE: We would not need this function if all of the mce code base
* would use dbus_send_ex() based method call handling.
*
* FIXME: Fix all code that uses dbus_connection_send_with_reply()
* so that dbus_send_ex() is used instead.
*
* @param pc Pending call object to protect
*/
void mce_dbus_pending_call_blocks_suspend(DBusPendingCall *pc)
{
mdb_callgate_attach(pc);
}

static bool introspectable_signal(const char *interface, const char *member);

/** Placeholder for any basic dbus data type */
Expand Down
2 changes: 2 additions & 0 deletions mce-dbus.h
Expand Up @@ -171,4 +171,6 @@ void mce_dbus_get_pid_async(const char *name, mce_dbus_pid_notify_t cb);

const char *mce_dbus_nameowner_get(const char *name);

void mce_dbus_pending_call_blocks_suspend(DBusPendingCall *pc);

#endif /* _MCE_DBUS_H_ */
2 changes: 2 additions & 0 deletions modules/battery-upower.c
Expand Up @@ -889,6 +889,8 @@ static void xup_properties_get_all(const char *path)
if( !pc )
goto EXIT;

mce_dbus_pending_call_blocks_suspend(pc);

if( !dbus_pending_call_set_notify(pc, xup_properties_get_all_cb,
strdup(path), free) )
goto EXIT;
Expand Down
2 changes: 2 additions & 0 deletions modules/cpu-keepalive.c
Expand Up @@ -1050,6 +1050,8 @@ cka_clients_verify_name(const char *name)
goto EXIT;
}

mce_dbus_pending_call_blocks_suspend(pc);

key = g_strdup(name);

if( !dbus_pending_call_set_notify(pc, cka_clients_verify_name_cb,
Expand Down
2 changes: 2 additions & 0 deletions modules/display.c
Expand Up @@ -5578,6 +5578,8 @@ static gboolean mdy_compositor_start_state_req(renderer_state_t state)
if( !mdy_compositor_state_req_pc )
goto EXIT;

mce_dbus_pending_call_blocks_suspend(mdy_compositor_state_req_pc);

if( !dbus_pending_call_set_notify(mdy_compositor_state_req_pc,
mdy_compositor_state_req_cb,
GINT_TO_POINTER(state), 0) )
Expand Down
6 changes: 6 additions & 0 deletions modules/radiostates.c
Expand Up @@ -622,6 +622,8 @@ static gboolean xconnman_set_property_bool(const char *key, gboolean val)
if( !pc )
goto EXIT;

mce_dbus_pending_call_blocks_suspend(pc);

if( !dbus_pending_call_set_notify(pc, xconnman_set_property_cb, 0, 0) )
goto EXIT;

Expand Down Expand Up @@ -820,6 +822,8 @@ static gboolean xconnman_get_properties(void)
if( !pc )
goto EXIT;

mce_dbus_pending_call_blocks_suspend(pc);

if( !dbus_pending_call_set_notify(pc, xconnman_get_properties_cb, 0, 0) )
goto EXIT;

Expand Down Expand Up @@ -917,6 +921,8 @@ static gboolean xconnman_check_service(void)
if( !pc )
goto EXIT;

mce_dbus_pending_call_blocks_suspend(pc);

if( !dbus_pending_call_set_notify(pc, xconnman_check_service_cb, 0, 0) )
goto EXIT;

Expand Down

0 comments on commit db55c71

Please sign in to comment.