* close a file descriptor after we've shutdown() both sides, to avoid a leak

--HG--
extra : convert_revision : 06fda32c634cf16a4c75797441ec2bd533f571c6
This commit is contained in:
Matt Johnston 2005-07-08 15:04:06 +00:00
parent 9888ffd8d1
commit 5002c95048

View File

@ -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);
}
}