summaryrefslogtreecommitdiffhomepage
path: root/common-channel.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2005-07-08 15:04:06 +0000
committerMatt Johnston <matt@ucc.asn.au>2005-07-08 15:04:06 +0000
commit5002c9504880309ffd273690a3e32fd544ea4950 (patch)
tree3e7a20dfc895a10ecb4eb5aaf6ac386adfd4aa3e /common-channel.c
parent9888ffd8d176fa85c6232f814f47f359561f2f57 (diff)
* close a file descriptor after we've shutdown() both sides, to avoid a leak
--HG-- extra : convert_revision : 06fda32c634cf16a4c75797441ec2bd533f571c6
Diffstat (limited to 'common-channel.c')
-rw-r--r--common-channel.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common-channel.c b/common-channel.c
index f03039a..dfff1b4 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -1019,6 +1019,7 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
/* XXX server */
if (channel->type->sepfds) {
+ TRACE(("shutdown((%d), %d)", fd, how))
shutdown(fd, how);
if (how == 0) {
closeout = 1;
@@ -1043,4 +1044,11 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
if (closein && (channel->extrabuf != NULL) && (fd == channel->errfd)) {
channel->errfd = FD_CLOSED;
}
+
+ /* if we called shutdown on it and all references are gone, then we
+ * need to close() it to stop it lingering */
+ if (channel->type->sepfds && channel->outfd == FD_CLOSED
+ && channel->infd == FD_CLOSED && channel->errfd == FD_CLOSED) {
+ close(fd);
+ }
}