diff options
Diffstat (limited to 'meta/packages/libgsmd/files/0002-Flush-all-pending-commands-before-restarting-the-mod.patch')
-rw-r--r-- | meta/packages/libgsmd/files/0002-Flush-all-pending-commands-before-restarting-the-mod.patch | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/meta/packages/libgsmd/files/0002-Flush-all-pending-commands-before-restarting-the-mod.patch b/meta/packages/libgsmd/files/0002-Flush-all-pending-commands-before-restarting-the-mod.patch new file mode 100644 index 0000000000..3683596389 --- /dev/null +++ b/meta/packages/libgsmd/files/0002-Flush-all-pending-commands-before-restarting-the-mod.patch | |||
@@ -0,0 +1,74 @@ | |||
1 | From 1078f7aced63c6216bffe649930b97c9ccf9a16e Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrzej Zaborowski <balrog@zabor.org> | ||
3 | Date: Wed, 19 Sep 2007 14:04:50 +0200 | ||
4 | Subject: [PATCH] Flush all pending commands before restarting the modem initialisation. | ||
5 | |||
6 | --- | ||
7 | include/gsmd/gsmd.h | 1 + | ||
8 | src/gsmd/atcmd.c | 21 +++++++++++++++++++++ | ||
9 | src/gsmd/timer.c | 8 ++++++++ | ||
10 | 3 files changed, 30 insertions(+), 0 deletions(-) | ||
11 | |||
12 | diff --git a/include/gsmd/gsmd.h b/include/gsmd/gsmd.h | ||
13 | index 4afdf66..6ac9d8e 100644 | ||
14 | --- a/include/gsmd/gsmd.h | ||
15 | +++ b/include/gsmd/gsmd.h | ||
16 | @@ -131,6 +131,7 @@ struct gsmd_timer { | ||
17 | |||
18 | int gsmd_timer_init(void); | ||
19 | void gmsd_timer_check_n_run(void); | ||
20 | +void gsmd_timer_reset(void); | ||
21 | |||
22 | struct gsmd_timer *gsmd_timer_alloc(void); | ||
23 | int gsmd_timer_register(struct gsmd_timer *timer); | ||
24 | diff --git a/src/gsmd/atcmd.c b/src/gsmd/atcmd.c | ||
25 | index 27dfa41..2f6cee2 100644 | ||
26 | --- a/src/gsmd/atcmd.c | ||
27 | +++ b/src/gsmd/atcmd.c | ||
28 | @@ -264,6 +264,27 @@ static int ml_parse(const char *buf, int len, void *ctx) | ||
29 | if (strlen(buf) == 0 || | ||
30 | !strcmp(buf, "AT-Command Interpreter ready")) { | ||
31 | g->interpreter_ready = 1; | ||
32 | + g->clear_to_send = 1; | ||
33 | + | ||
34 | + /* Flush current queue and reinitialise */ | ||
35 | + while (!llist_empty(&g->busy_atcmds)) { | ||
36 | + cmd = llist_entry(g->busy_atcmds.next, | ||
37 | + struct gsmd_atcmd, list); | ||
38 | + gsmd_log(GSMD_NOTICE, "discarding busy cmd %s\n", | ||
39 | + cmd->buf); | ||
40 | + llist_del(&cmd->list); | ||
41 | + talloc_free(cmd); | ||
42 | + } | ||
43 | + while (!llist_empty(&g->pending_atcmds)) { | ||
44 | + cmd = llist_entry(g->pending_atcmds.next, | ||
45 | + struct gsmd_atcmd, list); | ||
46 | + gsmd_log(GSMD_NOTICE, "discarding pending cmd %s\n", | ||
47 | + cmd->buf); | ||
48 | + llist_del(&cmd->list); | ||
49 | + talloc_free(cmd); | ||
50 | + } | ||
51 | + | ||
52 | + gsmd_timer_reset(); | ||
53 | gsmd_initsettings(g); | ||
54 | gmsd_alive_start(g); | ||
55 | atcmd_wake_queue(g); | ||
56 | diff --git a/src/gsmd/timer.c b/src/gsmd/timer.c | ||
57 | index 5200690..8877275 100644 | ||
58 | --- a/src/gsmd/timer.c | ||
59 | +++ b/src/gsmd/timer.c | ||
60 | @@ -215,3 +215,11 @@ void gsmd_timer_unregister(struct gsmd_timer *timer) | ||
61 | /* re-calculate next expiration */ | ||
62 | calc_next_expiration(); | ||
63 | } | ||
64 | + | ||
65 | +void gsmd_timer_reset(void) | ||
66 | +{ | ||
67 | + while (!llist_empty(&gsmd_timers)) | ||
68 | + /* TODO: free associated resources (e.g timer->cancel_cb()) */ | ||
69 | + llist_del(&llist_entry(gsmd_timers.next, | ||
70 | + struct gsmd_timer, list)->list); | ||
71 | +} | ||
72 | -- | ||
73 | 1.5.2.1 | ||
74 | |||