manager: disable reset timers once reset sequence starts

`modem_reset()` can be called from multiple places, both tied to a
specific timer. In order to prevent calling this function multiple times
in a row, disable all related timers as soon as we enter this function.
This commit is contained in:
Arnaud Ferraris
2022-01-04 15:28:12 +01:00
committed by Arnaud Ferraris
parent 9e6bccdf37
commit 97b1878ebc

View File

@@ -153,7 +153,15 @@ gboolean modem_reset(struct EG25Manager *manager)
int fd, ret, len; int fd, ret, len;
/* reset sequence started, cannot be canceled anymore */ /* reset sequence started, cannot be canceled anymore */
manager->schedule_reset_timer = 0; if (manager->schedule_reset_timer) {
g_source_remove(manager->schedule_reset_timer);
manager->schedule_reset_timer = 0;
}
if (manager->modem_recovery_timer) {
g_source_remove(manager->modem_recovery_timer);
manager->modem_recovery_timer = 0;
}
if (manager->complete_reset_timer) { if (manager->complete_reset_timer) {
g_message("modem_reset: timer already setup, skipping..."); g_message("modem_reset: timer already setup, skipping...");
@@ -170,11 +178,6 @@ gboolean modem_reset(struct EG25Manager *manager)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
if (manager->modem_recovery_timer) {
g_source_remove(manager->modem_recovery_timer);
manager->modem_recovery_timer = 0;
}
if (!manager->modem_usb_id) { if (!manager->modem_usb_id) {
g_warning("Empty modem USB ID"); g_warning("Empty modem USB ID");
goto error; goto error;