Mercurial > dropbear
diff common-channel.c @ 221:a4b93a2ed879
* close a file descriptor after we've shutdown() both sides, to avoid a leak
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 08 Jul 2005 15:04:06 +0000 |
parents | c44df7123b0a |
children | c5d3ef11155f |
line wrap: on
line diff
--- a/common-channel.c Fri Jul 08 14:28:21 2005 +0000 +++ b/common-channel.c Fri Jul 08 15:04:06 2005 +0000 @@ -1019,6 +1019,7 @@ /* XXX server */ if (channel->type->sepfds) { + TRACE(("shutdown((%d), %d)", fd, how)) shutdown(fd, how); if (how == 0) { closeout = 1; @@ -1043,4 +1044,11 @@ 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); + } }