Skip to content

Commit

Permalink
[callstate] Suspend proof delayed call state evaluation. Fixes JB#32462
Browse files Browse the repository at this point in the history
The callstate plugin uses idle call back to avoid premature call state
evaluation and dbus signaling. The glib idle callback mechanism is
not protected against suspend and thus the state transition that would
block suspend might not be acted on in time.

Use wltimer for scheduling the delayed call state evaluation.
  • Loading branch information
spiiroin committed Oct 9, 2015
1 parent a180ca1 commit 220e39f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .depend
Expand Up @@ -522,6 +522,7 @@ modules/callstate.o:\
datapipe.h\
mce-dbus.h\
mce-log.h\
mce-wltimer.h\
mce.h\

modules/callstate.pic.o:\
Expand All @@ -530,6 +531,7 @@ modules/callstate.pic.o:\
datapipe.h\
mce-dbus.h\
mce-log.h\
mce-wltimer.h\
mce.h\

modules/camera.o:\
Expand Down
23 changes: 11 additions & 12 deletions modules/callstate.c
Expand Up @@ -23,6 +23,7 @@
#include "../mce.h"
#include "../mce-log.h"
#include "../mce-dbus.h"
#include "../mce-wltimer.h"

#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -1629,39 +1630,33 @@ call_state_rethink_now(void)
return changed;
}

/** Timer id for evaluating call state */
static guint call_state_rethink_id = 0;
/** Idle timer for evaluating call state */
static mce_wltimer_t *call_state_rethink_tmr = 0;

/** Timer callback for evaluating call state */
static gboolean
call_state_rethink_cb(gpointer aptr)
{
(void)aptr;

if( !call_state_rethink_id )
goto EXIT;
call_state_rethink_id = 0;

call_state_rethink_now();

EXIT:
return G_SOURCE_REMOVE;
}

/** Cancel delayed call state evaluation */
static void
call_state_rethink_cancel(void)
{
if( call_state_rethink_id )
g_source_remove(call_state_rethink_id), call_state_rethink_id = 0;
mce_wltimer_stop(call_state_rethink_tmr);
}

/** Request delayed call state evaluation */
static void
call_state_rethink_schedule(void)
{
if( !call_state_rethink_id )
call_state_rethink_id = g_idle_add(call_state_rethink_cb, 0);
if( !mce_wltimer_is_active(call_state_rethink_tmr) )
mce_wltimer_start(call_state_rethink_tmr);
}

/** Request immediate call state evaluation */
Expand Down Expand Up @@ -1785,6 +1780,9 @@ const gchar *g_module_check_init(GModule *module)
{
(void)module;

call_state_rethink_tmr = mce_wltimer_create("call_state_rethink",
0, call_state_rethink_cb, 0);

/* create look up tables */
clients_init();
vcalls_init();
Expand Down Expand Up @@ -1815,7 +1813,8 @@ void g_module_unload(GModule *module)
mce_callstate_quit_dbus();

/* remove all timers & callbacks */
call_state_rethink_cancel();
mce_wltimer_delete(call_state_rethink_tmr),
call_state_rethink_tmr = 0;

/* delete look up tables */
modems_quit();
Expand Down

0 comments on commit 220e39f

Please sign in to comment.