summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-10-09 19:51:19 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-10-09 19:51:19 +0000
commit203973800228590a646c29d14526f1e209b9b894 (patch)
tree1bc889befbf50adc149f741bf73aaba10cbf82c6 /usr.bin
parent58b3ca33ac24e29a87e65c127bbab25a6771ae25 (diff)
close all channels if the connection to the remote host has been closed,
should fix sshd's hanging with WCHAN==wait
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/serverloop.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/ssh/serverloop.c b/usr.bin/ssh/serverloop.c
index fc7ecc2596a..2460b0b2744 100644
--- a/usr.bin/ssh/serverloop.c
+++ b/usr.bin/ssh/serverloop.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: serverloop.c,v 1.79 2001/10/04 15:12:37 markus Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.80 2001/10/09 19:51:18 markus Exp $");
#include "xmalloc.h"
#include "packet.h"
@@ -699,6 +699,7 @@ server_loop2(Authctxt *authctxt)
if (child_terminated) {
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
session_close_by_pid(pid, status);
+ /* XXX race */
child_terminated = 0;
}
if (!rekeying)
@@ -708,6 +709,9 @@ server_loop2(Authctxt *authctxt)
break;
process_output(writeset);
}
+ /* close all channels, no more reads and writes */
+ channel_close_all();
+
if (readset)
xfree(readset);
if (writeset)
@@ -715,14 +719,14 @@ server_loop2(Authctxt *authctxt)
signal(SIGCHLD, SIG_DFL);
+ /* collect dead children */
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
session_close_by_pid(pid, status);
/*
- * there is a race between channel_free_all() killing children and
- * children dying before kill()
+ * there is a race between channel_detach_all() killing remaining
+ * children and children dying before kill()
*/
channel_detach_all();
- channel_stop_listening();
while (session_have_children()) {
pid = waitpid(-1, &status, 0);