comparison common-channel.c @ 1039:d0e6dd5af46e

Use m_close() which will avoid close(-1)
author Matt Johnston <matt@ucc.asn.au>
date Tue, 24 Feb 2015 20:53:32 +0800
parents d3925ed45a85
children 01eea88963f3
comparison
equal deleted inserted replaced
1038:d3925ed45a85 1039:d0e6dd5af46e
584 584
585 if (IS_DROPBEAR_SERVER || (channel->writefd != STDOUT_FILENO)) { 585 if (IS_DROPBEAR_SERVER || (channel->writefd != STDOUT_FILENO)) {
586 /* close the FDs in case they haven't been done 586 /* close the FDs in case they haven't been done
587 * yet (they might have been shutdown etc) */ 587 * yet (they might have been shutdown etc) */
588 TRACE(("CLOSE writefd %d", channel->writefd)) 588 TRACE(("CLOSE writefd %d", channel->writefd))
589 close(channel->writefd); 589 m_close(channel->writefd);
590 TRACE(("CLOSE readfd %d", channel->readfd)) 590 TRACE(("CLOSE readfd %d", channel->readfd))
591 close(channel->readfd); 591 m_close(channel->readfd);
592 TRACE(("CLOSE errfd %d", channel->errfd)) 592 TRACE(("CLOSE errfd %d", channel->errfd))
593 close(channel->errfd); 593 m_close(channel->errfd);
594 } 594 }
595 595
596 if (!channel->close_handler_done 596 if (!channel->close_handler_done
597 && channel->type->closehandler) { 597 && channel->type->closehandler) {
598 channel->type->closehandler(channel); 598 channel->type->closehandler(channel);
999 } else { 999 } else {
1000 closein = 1; 1000 closein = 1;
1001 } 1001 }
1002 } else { 1002 } else {
1003 TRACE(("CLOSE some fd %d", fd)) 1003 TRACE(("CLOSE some fd %d", fd))
1004 close(fd); 1004 m_close(fd);
1005 closein = closeout = 1; 1005 closein = closeout = 1;
1006 } 1006 }
1007 1007
1008 if (closeout && (fd == channel->readfd)) { 1008 if (closeout && (fd == channel->readfd)) {
1009 channel->readfd = FD_CLOSED; 1009 channel->readfd = FD_CLOSED;
1022 /* if we called shutdown on it and all references are gone, then we 1022 /* if we called shutdown on it and all references are gone, then we
1023 * need to close() it to stop it lingering */ 1023 * need to close() it to stop it lingering */
1024 if (channel->type->sepfds && channel->readfd == FD_CLOSED 1024 if (channel->type->sepfds && channel->readfd == FD_CLOSED
1025 && channel->writefd == FD_CLOSED && channel->errfd == FD_CLOSED) { 1025 && channel->writefd == FD_CLOSED && channel->errfd == FD_CLOSED) {
1026 TRACE(("CLOSE (finally) of %d", fd)) 1026 TRACE(("CLOSE (finally) of %d", fd))
1027 close(fd); 1027 m_close(fd);
1028 } 1028 }
1029 } 1029 }
1030 1030
1031 1031
1032 #if defined(USING_LISTENERS) || defined(DROPBEAR_CLIENT) 1032 #if defined(USING_LISTENERS) || defined(DROPBEAR_CLIENT)