r3447 - in trunk/src/target/gsm: include/gsmd src/gsmd
tick at sita.openmoko.org
tick at sita.openmoko.org
Tue Nov 20 05:17:40 CET 2007
Author: tick
Date: 2007-11-20 05:17:35 +0100 (Tue, 20 Nov 2007)
New Revision: 3447
Modified:
trunk/src/target/gsm/include/gsmd/atcmd.h
trunk/src/target/gsm/src/gsmd/atcmd.c
trunk/src/target/gsm/src/gsmd/usock.c
Log:
[gsmd] Adding atcmd_terminate_matching (remove from the queues any command whose .ctx matches given)(Andrzej Zaborowski)
Modified: trunk/src/target/gsm/include/gsmd/atcmd.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/atcmd.h 2007-11-19 22:09:06 UTC (rev 3446)
+++ trunk/src/target/gsm/include/gsmd/atcmd.h 2007-11-20 04:17:35 UTC (rev 3447)
@@ -13,8 +13,9 @@
extern int cancel_atcmd(struct gsmd *g, struct gsmd_atcmd *cmd);
extern int atcmd_init(struct gsmd *g, int sockfd);
extern void atcmd_drain(int fd);
+extern int atcmd_terminate_matching(struct gsmd *g, void *ctx);
extern void atcmd_wake_pending_queue (struct gsmd *g);
-extern void atcmd_wait_pending_queue (struct gsmd *g);
+extern void atcmd_wait_pending_queue (struct gsmd *g);
#endif /* __GSMD__ */
Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c 2007-11-19 22:09:06 UTC (rev 3446)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c 2007-11-20 04:17:35 UTC (rev 3447)
@@ -719,3 +719,30 @@
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;
+}
Modified: trunk/src/target/gsm/src/gsmd/usock.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/usock.c 2007-11-19 22:09:06 UTC (rev 3446)
+++ trunk/src/target/gsm/src/gsmd/usock.c 2007-11-20 04:17:35 UTC (rev 3447)
@@ -1205,9 +1205,11 @@
/* EOF, this client has just vanished */
gsmd_unregister_fd(&gu->gfd);
close(fd);
+ /* finish pending atcmd's from this client thus
+ * destroying references to the user structure. */
+ atcmd_terminate_matching(gu->gsmd, gu);
/* destroy whole user structure */
llist_del(&gu->list);
- /* FIXME: delete busy ucmds from finished_ucmds */
talloc_free(gu);
return 0;
} else if (rcvlen < 0)
More information about the commitlog
mailing list