diff options
author | tick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-11-20 04:17:35 +0000 |
---|---|---|
committer | tick <tick@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-11-20 04:17:35 +0000 |
commit | 6ad8e1931d2df52ff173e4b83a5c3c0e1812b931 (patch) | |
tree | 48dc9cbaf6e424eb8ee818873623498b20fc8a53 /src/gsmd/atcmd.c | |
parent | 5e9fde8743d4d3d733303bef99e20000c0769148 (diff) |
[gsmd] Adding atcmd_terminate_matching (remove from the queues any command whose .ctx matches given)(Andrzej Zaborowski)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3447 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/gsmd/atcmd.c')
-rw-r--r-- | src/gsmd/atcmd.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gsmd/atcmd.c b/src/gsmd/atcmd.c index 747000b..2b5825a 100644 --- a/src/gsmd/atcmd.c +++ b/src/gsmd/atcmd.c @@ -719,3 +719,30 @@ int atcmd_init(struct gsmd *g, int sockfd) return gsmd_register_fd(&g->gfd_uart); } + +/* remove from the queues any command whose .ctx matches given */ +int atcmd_terminate_matching(struct gsmd *g, void *ctx) +{ + int num = 0; + struct gsmd_atcmd *cmd, *pos; + + llist_for_each_entry_safe(cmd, pos, &g->busy_atcmds, list) + if (cmd->ctx == ctx) { + cmd->ret = -ESHUTDOWN; + cmd->cb(cmd, cmd->ctx, "ERROR"); + cmd->cb = NULL; + cmd->ctx = NULL; + num ++; + } + + llist_for_each_entry_safe(cmd, pos, &g->pending_atcmds, list) + if (cmd->ctx == ctx) { + llist_del(&cmd->list); + cmd->ret = -ESHUTDOWN; + cmd->cb(cmd, cmd->ctx, "ERROR"); + talloc_free(cmd); + num ++; + } + + return num; +} |