Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make sure the trigger does not get restarted when we clean up.
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Oct 29, 2013
1 parent 0b2c861 commit 2ce029a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/usb_moded-udev.c
Expand Up @@ -43,6 +43,7 @@ static struct udev_monitor *mon;
static GIOChannel *iochannel;
static guint watch_id;
static const char *dev_name;
static int cleanup = 0;

/* static function definitions */
static gboolean monitor_udev(GIOChannel *iochannel G_GNUC_UNUSED, GIOCondition cond,
Expand All @@ -51,6 +52,9 @@ static void udev_parse(struct udev_device *dev);

static void notify_issue (gpointer data)
{
/* we do not want to restart when we try to clean up */
if(cleanup)
return;
log_debug("USB connection watch destroyed, restarting it\n!");
/* restart trigger */
hwal_cleanup();
Expand All @@ -62,6 +66,8 @@ gboolean hwal_init(void)
const gchar *udev_path = NULL, *udev_subsystem = NULL;
struct udev_device *dev;
int ret = 0;

cleanup = 0;

/* Create the udev object */
udev = udev_new();
Expand Down Expand Up @@ -163,6 +169,10 @@ static gboolean monitor_udev(GIOChannel *iochannel G_GNUC_UNUSED, GIOCondition c

void hwal_cleanup(void)
{
cleanup = 1;

log_debug("HWhal cleanup\n");

if(watch_id != 0)
{
g_source_remove(watch_id);
Expand Down

0 comments on commit 2ce029a

Please sign in to comment.