diff --git a/src/ca/iocinf.c b/src/ca/iocinf.c index 30e91a1ba..66eb428cb 100644 --- a/src/ca/iocinf.c +++ b/src/ca/iocinf.c @@ -1196,6 +1196,8 @@ void close_ioc (struct ioc_in_use *piiu) piiuCast = NULL; } else { + chid *pNext; + /* * remove IOC from the hash table */ @@ -1209,18 +1211,17 @@ void close_ioc (struct ioc_in_use *piiu) * handler tries to use a channel before * I mark it disconnected. */ - chix = (chid) &piiu->chidlist.node.next; - while (chix = (chid) chix->node.next) { + chix = (chid) ellFirst(&piiu->chidlist); + while (chix) { chix->state = cs_prev_conn; + chix = (chid) ellNext(&chix->node); } - chix = (chid) &piiu->chidlist.node.next; - while (chix = (chid) chix->node.next) { + chix = (chid) ellFirst(&piiu->chidlist); + while (chix) { + pNext = (chid) ellNext(&chix->node); cacDisconnectChannel(chix, TRUE); - } - - if (piiu->chidlist.count) { - ca_signal (ECA_DISCONN,piiu->host_name_str); + chix = pNext; } } @@ -1246,6 +1247,8 @@ void close_ioc (struct ioc_in_use *piiu) ellFree (&piiu->destAddr); + ca_signal (ECA_DISCONN,piiu->host_name_str); + free (piiu); UNLOCK; diff --git a/src/ca/service.c b/src/ca/service.c index ed1f66965..152149909 100644 --- a/src/ca/service.c +++ b/src/ca/service.c @@ -721,7 +721,9 @@ const struct in_addr *pnet_addr * need to move the channel back to the cast IIU * (so we will be able to reconnect) */ + LOCK; cacDisconnectChannel(chan, FALSE); + UNLOCK; break; } default: