free bchannels on broken pipe of remote application
[lcr.git] / socket_server.c
index 77e5309..bf3bfcd 100644 (file)
@@ -80,6 +80,8 @@ void free_connection(struct admin_list *admin)
        void *temp;
        union parameter param;
        class Join *join, *joinnext;
+       struct mISDNport *mISDNport;
+       int i, ii;
 
        /* free remote joins */
        if (admin->remote_name[0])
@@ -94,6 +96,26 @@ void free_connection(struct admin_list *admin)
                        "REMOTE APP release");
                add_trace("app", "name", "%s", admin->remote_name);
                end_trace();
+               /* release all exported channels */
+               mISDNport = mISDNport_first;
+               while(mISDNport)
+               {
+                       i = 0;
+                       ii = mISDNport->b_num;
+                       while(i < ii)
+                       {
+                               if (mISDNport->b_remote_id[i] == admin->sock)
+                               {
+                                       mISDNport->b_state[i] = B_STATE_IDLE;
+                                       mISDNport->b_timer[i] = 0;
+                                       mISDNport->b_remote_id[i] = 0;
+                                       mISDNport->b_remote_ref[i] = 0;
+                               }
+                               i++;
+                       }
+                       mISDNport = mISDNport->next;
+               }
+               /* release join */
                join = join_first;
                while(join)
                {
@@ -654,10 +676,11 @@ int admin_message_to_join(struct admin_msg *msg, struct admin_list *admin)
         * no ref given for *_ack */
        if (msg->type == MESSAGE_BCHANNEL)
        if (msg->param.bchannel.type == BCHANNEL_ASSIGN_ACK
-        || msg->param.bchannel.type == BCHANNEL_REMOVE_ACK)
+        || msg->param.bchannel.type == BCHANNEL_REMOVE_ACK
+        || msg->param.bchannel.type == BCHANNEL_RELEASE)
        {
                /* no ref, but address */
-               message_bchannel_from_join(NULL, msg->param.bchannel.type, msg->param.bchannel.handle);
+               message_bchannel_from_remote(NULL, msg->param.bchannel.type, msg->param.bchannel.handle);
                return(0);
        }