[serverloop.c]
     close all channels if the connection to the remote host has been closed,
     should fix sshd's hanging with WCHAN==wait
This commit is contained in:
Damien Miller 2001-10-10 15:08:36 +10:00
parent ae45246696
commit c71f4e40b6
2 changed files with 13 additions and 5 deletions

View File

@ -40,6 +40,10 @@
- markus@cvs.openbsd.org 2001/10/09 19:32:49 - markus@cvs.openbsd.org 2001/10/09 19:32:49
[session.c] [session.c]
stat subsystem command before calling do_exec, and return error to client. stat subsystem command before calling do_exec, and return error to client.
- markus@cvs.openbsd.org 2001/10/09 19:51:18
[serverloop.c]
close all channels if the connection to the remote host has been closed,
should fix sshd's hanging with WCHAN==wait
20011007 20011007
- (bal) ssh-copy-id corrected permissions for .ssh/ and authorized_keys. - (bal) ssh-copy-id corrected permissions for .ssh/ and authorized_keys.
@ -6685,4 +6689,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.1596 2001/10/10 05:08:06 djm Exp $ $Id: ChangeLog,v 1.1597 2001/10/10 05:08:36 djm Exp $

View File

@ -35,7 +35,7 @@
*/ */
#include "includes.h" #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 "xmalloc.h"
#include "packet.h" #include "packet.h"
@ -699,6 +699,7 @@ server_loop2(Authctxt *authctxt)
if (child_terminated) { if (child_terminated) {
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
session_close_by_pid(pid, status); session_close_by_pid(pid, status);
/* XXX race */
child_terminated = 0; child_terminated = 0;
} }
if (!rekeying) if (!rekeying)
@ -708,6 +709,9 @@ server_loop2(Authctxt *authctxt)
break; break;
process_output(writeset); process_output(writeset);
} }
/* close all channels, no more reads and writes */
channel_close_all();
if (readset) if (readset)
xfree(readset); xfree(readset);
if (writeset) if (writeset)
@ -715,14 +719,14 @@ server_loop2(Authctxt *authctxt)
mysignal(SIGCHLD, SIG_DFL); mysignal(SIGCHLD, SIG_DFL);
/* collect dead children */
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
session_close_by_pid(pid, status); session_close_by_pid(pid, status);
/* /*
* there is a race between channel_free_all() killing children and * there is a race between channel_detach_all() killing remaining
* children dying before kill() * children and children dying before kill()
*/ */
channel_detach_all(); channel_detach_all();
channel_stop_listening();
while (session_have_children()) { while (session_have_children()) {
pid = waitpid(-1, &status, 0); pid = waitpid(-1, &status, 0);