# HG changeset patch # User Matt Johnston # Date 1120835046 0 # Node ID a4b93a2ed8790bfe2e1ebb95a18e112d1a780bee # Parent 9089929fb2b749d2b516b3dccbdbf4e5852d20d0 * close a file descriptor after we've shutdown() both sides, to avoid a leak diff -r 9089929fb2b7 -r a4b93a2ed879 common-channel.c --- 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); + } }