Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[usb_moded] Make sure charging timeout timer ids are not leaked
If charging_timeout should already contain a valid timer id when the
timer is started, the old timer will be leaked.

Remove existing timer id before assigning new one.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jul 7, 2016
1 parent 6ec3a73 commit de044e2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/usb_moded.c
Expand Up @@ -294,6 +294,8 @@ void set_usb_connected_state(void)
*/
usb_moded_send_signal(USB_CONNECTED_DIALOG_SHOW);
/* fallback to charging mode after 3 seconds */
if( charging_timeout )
g_source_remove(charging_timeout);
charging_timeout = g_timeout_add_seconds(3, charging_fallback, NULL);
/* in case there was nobody listening for the UI, they will know
that the UI is needed by requesting the current mode */
Expand Down

0 comments on commit de044e2

Please sign in to comment.