diff common-channel.c @ 423:b2b67cfcd66e channel-fix

- Fix bug in child-exit handling where the wrong pid was being matched. - Also wait for errfd to close before closing the channel
author Matt Johnston <matt@ucc.asn.au>
date Mon, 12 Feb 2007 10:39:22 +0000
parents a01c0c8e543a
children c216212001fc
line wrap: on
line diff
--- a/common-channel.c	Mon Feb 12 10:37:35 2007 +0000
+++ b/common-channel.c	Mon Feb 12 10:39:22 2007 +0000
@@ -313,6 +313,7 @@
 	/* And if we can't receive any more data from them either, close up */
 	if (!channel->sent_close
 			&& channel->readfd == FD_CLOSED
+			&& (ERRFD_IS_WRITE(channel) || channel->errfd == FD_CLOSED)
 			&& !write_pending(channel)) {
 		TRACE(("sending close, readfd is closed"))
 		send_msg_channel_close(channel);
@@ -624,8 +625,8 @@
 			close_chan_fd(channel, fd, SHUT_RD);
 		}
 		ses.writepayload->len = ses.writepayload->pos = 0;
-		TRACE(("leave send_msg_channel_data: len %d read err or EOF for fd %d", 
-					len, channel->index));
+		TRACE(("leave send_msg_channel_data: len %d read err %d or EOF for fd %d", 
+					len, errno, fd))
 		return;
 	}
 	buf_incrwritepos(ses.writepayload, len);