From d298bfd4cc842b3fa1899faf55bf8e58009e5110 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 8 Sep 2014 06:01:36 +0200 Subject: [PATCH] Do not restart the modem if already started --- src/modems/hayes.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modems/hayes.c b/src/modems/hayes.c index 844d93f..4a2593d 100644 --- a/src/modems/hayes.c +++ b/src/modems/hayes.c @@ -609,15 +609,28 @@ static int _hayes_request(Hayes * hayes, ModemRequest * request) /* hayes_start */ +static int _start_is_started(Hayes * hayes); + static int _hayes_start(Hayes * hayes, unsigned int retry) { hayes->retry = retry; + if(_start_is_started(hayes)) + return 0; if(hayes->source != 0) g_source_remove(hayes->source); hayes->source = g_idle_add(_on_reset, &hayes->channel); return 0; } +static int _start_is_started(Hayes * hayes) +{ + if(hayes->source != 0) + return 1; + if(hayes->channel.channel != NULL) + return 1; + return 0; +} + /* hayes_stop */ static void _stop_channel(Hayes * hayes, HayesChannel * channel);