diff --git a/capi20/application.c b/capi20/application.c index b54af4a..704cfe1 100644 --- a/capi20/application.c +++ b/capi20/application.c @@ -63,6 +63,7 @@ struct mApplication *RegisterApplication(uint16_t ApplId, uint32_t MaxB3Connecti void ReleaseApplication(struct mApplication *appl) { struct mApplication *ma = mApplications; + struct lController *lc, *lcn; /* first remove from list */ while (ma) { @@ -77,59 +78,17 @@ void ReleaseApplication(struct mApplication *appl) } ma = ma->next; } - /* TODO clean controller refs */ + /* remove assigned logical controllers */ + lc = appl->contL; + while (lc) { + lcn = lc->nextA; + dprint(MIDEBUG_CONTROLLER, "Appl:%3d remove lc=%p (next:%p)\n", appl->AppId, lc, lcn); + rm_lController(lc); + lc = lcn; + } close(appl->fd); + dprint(MIDEBUG_CAPIMSG, "Appl:%3d removed\n", appl->AppId); free(appl); -#if 0 - int i, used = 0; - AppPlci_t **aplci_p = appl->AppPlcis; - - if (test_and_set_bit(APPL_STATE_DESTRUCTOR, &appl->state)) { - // we are allready in this function - return (-EBUSY); - } - test_and_set_bit(APPL_STATE_RELEASE, &appl->state); - test_and_clear_bit(APPL_STATE_ACTIV, &appl->state); - listenDestr(appl); - if (who > 2) { - appl->contr = NULL; - } - if (aplci_p) { - for (i = 0; i < appl->maxplci; i++) { - if (*aplci_p) { - switch (who) { - case 4: - AppPlciDestr(*aplci_p); - *aplci_p = NULL; - break; - case 1: - case 2: - case 3: - AppPlciRelease(*aplci_p); - case 0: - if ((volatile AppPlci_t *)(*aplci_p)) - used++; - break; - } - } - aplci_p++; - } - } - if (used) { - if (who == 3) { - list_del_init(&appl->head); - list_add(&appl->head, &garbage_applications); - } - test_and_clear_bit(APPL_STATE_DESTRUCTOR, &appl->state); - return (-EBUSY); - } - list_del_init(&appl->head); - appl->maxplci = 0; - kfree(appl->AppPlcis); - appl->AppPlcis = NULL; - kfree(appl); - return (0); -#endif } struct lController *get_lController(struct mApplication *app, int cont) diff --git a/capi20/daemon.c b/capi20/daemon.c index f76052e..17e8a0f 100644 --- a/capi20/daemon.c +++ b/capi20/daemon.c @@ -980,10 +980,11 @@ int ListenController(struct pController *pc) lc = pc->lClist; while (lc) { + dprint(MIDEBUG_CONTROLLER, "pc->lClist %p %08x/%08x/%08x\n", lc, lc->InfoMask, lc->CIPmask, lc->CIPmask2); InfoMask |= lc->InfoMask; CIPMask |= lc->CIPmask; CIPMask2 |= lc->CIPmask2; - lc = lc->nextA; + lc = lc->nextC; } dprint(MIDEBUG_CONTROLLER, "Controller %d change InfoMask %08x -> %08x\n", pc->profile.ncontroller, pc->InfoMask, InfoMask); dprint(MIDEBUG_CONTROLLER, "Controller %d change CIPMask %08x -> %08x\n", pc->profile.ncontroller, pc->CIPmask, CIPMask); @@ -1404,7 +1405,7 @@ int main_loop(void) if (pollinfo[i].type == PIT_Application) ReleaseApplication(pollinfo[i].data); fd = mainpoll[i].fd; - dprint(MIDEBUG_POLL, "read 0 socket %d closed\n", fd); + dprint(MIDEBUG_POLL, "read 0 socket %d type %d closed\n", fd, pollinfo[i].type); close(mainpoll[i].fd); res = del_mainpoll(mainpoll[i].fd); if (res < 0) { diff --git a/capi20/listen.c b/capi20/listen.c index 0ea7521..d2d29c7 100644 --- a/capi20/listen.c +++ b/capi20/listen.c @@ -58,6 +58,8 @@ static void listen_req_l_x(struct FsmInst *fi, int event, void *arg, int state) FsmChangeState(fi, state); + dprint(MIDEBUG_CONTROLLER, "Controller%d: lc=%p nC=%p nA=%p\n", + lc->Contr->profile.ncontroller, lc, lc->nextC, lc->nextA); dprint(MIDEBUG_CONTROLLER, "Controller%d: set InfoMask %08x -> %08x\n", lc->Contr->profile.ncontroller, lc->InfoMask, mc->cmsg.InfoMask); dprint(MIDEBUG_CONTROLLER, "Controller%d: set CIPmask %08x -> %08x\n", diff --git a/capi20/m_capi.h b/capi20/m_capi.h index 8a89d6c..0eb19a3 100644 --- a/capi20/m_capi.h +++ b/capi20/m_capi.h @@ -129,8 +129,8 @@ int OpenLayer3(struct pController *); /* This is a struct for the logical controller per application, also has the listen statemachine */ struct lController { - struct lController *nextC; - struct lController *nextA; + struct lController *nextC; /* List of Logical controllers on the physical controller */ + struct lController *nextA; /* List of Logical controllers on the application */ int refc; /* refcount */ struct pController *Contr; /* pointer to the physical controler */ struct mApplication *Appl; /* pointer to the CAPI application */