diff common-channel.c @ 37:0913e2ee3545

we're nearly there yet
author Matt Johnston <matt@ucc.asn.au>
date Fri, 30 Jul 2004 03:02:19 +0000
parents db2c8e6fb284
children 20563735e8b5
line wrap: on
line diff
--- a/common-channel.c	Thu Jul 29 15:43:26 2004 +0000
+++ b/common-channel.c	Fri Jul 30 03:02:19 2004 +0000
@@ -67,6 +67,7 @@
 	ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*));
 	ses.chansize = 1;
 	ses.channels[0] = NULL;
+	ses.chancount = 0;
 
 	ses.chantypes = chantypes;
 
@@ -153,6 +154,7 @@
 	newchan->recvmaxpacket = RECV_MAXPACKET;
 
 	ses.channels[i] = newchan;
+	ses.chancount++;
 
 	TRACE(("leave newchannel"));
 
@@ -515,6 +517,7 @@
 
 	ses.channels[channel->index] = NULL;
 	m_free(channel);
+	ses.chancount--;
 	
 }
 
@@ -934,6 +937,7 @@
 
 	unsigned int chan;
 	struct Channel * channel;
+	int ret;
 
 	TRACE(("enter recv_msg_channel_open_confirmation"));
 	chan = buf_getint(ses.payload);
@@ -949,6 +953,15 @@
 	
 	TRACE(("new chan remote %d localho %d", channel->remotechan, chan));
 
+	/* Run the inithandler callback */
+	if (channel->type->inithandler) {
+		ret = channel->type->inithandler(channel);
+		if (ret > 0) {
+			removechannel(channel);
+			TRACE(("inithandler returned failure %d", ret));
+		}
+	}
+
 	
 	TRACE(("leave recv_msg_channel_open_confirmation"));
 }