Implemented sandbox state cleanup on exit() or exception.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15363 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
160e3e52ae
commit
377fdec495
|
@ -941,16 +941,38 @@ static thread_t *sb_msg_wait_timeout_s(sysinterval_t timeout) {
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void sb_cleanup(void) {
|
||||||
|
#if SB_CFG_ENABLE_VFS == TRUE
|
||||||
|
sb_class_t *sbp = (sb_class_t *)chThdGetSelfX()->ctx.syscall.p;
|
||||||
|
unsigned fd;
|
||||||
|
|
||||||
|
/* Closing all file descriptors.*/
|
||||||
|
for (fd = 0U; fd < SB_CFG_FD_NUM; fd++) {
|
||||||
|
if (sbp->io.vfs_nodes[fd] != NULL) {
|
||||||
|
sbp->io.vfs_nodes[fd]->vmt->release(sbp->io.vfs_nodes[fd]);
|
||||||
|
sbp->io.vfs_nodes[fd] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module exported functions. */
|
/* Module exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
void __sb_abort(msg_t msg) {
|
void __sb_abort(msg_t msg) {
|
||||||
|
|
||||||
|
chSysUnlock();
|
||||||
|
|
||||||
|
sb_cleanup();
|
||||||
|
|
||||||
|
chSysLock();
|
||||||
#if CH_CFG_USE_EVENTS == TRUE
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
chEvtBroadcastI(&sb.termination_es);
|
chEvtBroadcastI(&sb.termination_es);
|
||||||
#endif
|
#endif
|
||||||
chThdExitS(msg);
|
chThdExitS(msg);
|
||||||
|
chSysHalt("zombies");
|
||||||
}
|
}
|
||||||
|
|
||||||
void sb_api_stdio(struct port_extctx *ectxp) {
|
void sb_api_stdio(struct port_extctx *ectxp) {
|
||||||
|
@ -1002,6 +1024,8 @@ void sb_api_stdio(struct port_extctx *ectxp) {
|
||||||
|
|
||||||
void sb_api_exit(struct port_extctx *ectxp) {
|
void sb_api_exit(struct port_extctx *ectxp) {
|
||||||
|
|
||||||
|
sb_cleanup();
|
||||||
|
|
||||||
chSysLock();
|
chSysLock();
|
||||||
#if CH_CFG_USE_EVENTS == TRUE
|
#if CH_CFG_USE_EVENTS == TRUE
|
||||||
chEvtBroadcastI(&sb.termination_es);
|
chEvtBroadcastI(&sb.termination_es);
|
||||||
|
|
Loading…
Reference in New Issue