summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-10-10 15:08:36 +1000
committerDamien Miller <djm@mindrot.org>2001-10-10 15:08:36 +1000
commitc71f4e40b6d8cdf1c0d83381945841e66c127a95 (patch)
tree8132842fd05322ca31d89d412f8799dd4077fed6
parentae45246696fed011e1a9941d33b89669c74b3198 (diff)
- 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
-rw-r--r--ChangeLog6
-rw-r--r--serverloop.c12
2 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 93f90af68..2eda5e1b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,6 +40,10 @@
40 - markus@cvs.openbsd.org 2001/10/09 19:32:49 40 - markus@cvs.openbsd.org 2001/10/09 19:32:49
41 [session.c] 41 [session.c]
42 stat subsystem command before calling do_exec, and return error to client. 42 stat subsystem command before calling do_exec, and return error to client.
43 - markus@cvs.openbsd.org 2001/10/09 19:51:18
44 [serverloop.c]
45 close all channels if the connection to the remote host has been closed,
46 should fix sshd's hanging with WCHAN==wait
43 47
4420011007 4820011007
45 - (bal) ssh-copy-id corrected permissions for .ssh/ and authorized_keys. 49 - (bal) ssh-copy-id corrected permissions for .ssh/ and authorized_keys.
@@ -6685,4 +6689,4 @@
6685 - Wrote replacements for strlcpy and mkdtemp 6689 - Wrote replacements for strlcpy and mkdtemp
6686 - Released 1.0pre1 6690 - Released 1.0pre1
6687 6691
6688$Id: ChangeLog,v 1.1596 2001/10/10 05:08:06 djm Exp $ 6692$Id: ChangeLog,v 1.1597 2001/10/10 05:08:36 djm Exp $
diff --git a/serverloop.c b/serverloop.c
index 4577cc804..d7282fe2a 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.79 2001/10/04 15:12:37 markus Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.80 2001/10/09 19:51:18 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -699,6 +699,7 @@ server_loop2(Authctxt *authctxt)
699 if (child_terminated) { 699 if (child_terminated) {
700 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) 700 while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
701 session_close_by_pid(pid, status); 701 session_close_by_pid(pid, status);
702 /* XXX race */
702 child_terminated = 0; 703 child_terminated = 0;
703 } 704 }
704 if (!rekeying) 705 if (!rekeying)
@@ -708,6 +709,9 @@ server_loop2(Authctxt *authctxt)
708 break; 709 break;
709 process_output(writeset); 710 process_output(writeset);
710 } 711 }
712 /* close all channels, no more reads and writes */
713 channel_close_all();
714
711 if (readset) 715 if (readset)
712 xfree(readset); 716 xfree(readset);
713 if (writeset) 717 if (writeset)
@@ -715,14 +719,14 @@ server_loop2(Authctxt *authctxt)
715 719
716 mysignal(SIGCHLD, SIG_DFL); 720 mysignal(SIGCHLD, SIG_DFL);
717 721
722 /* collect dead children */
718 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) 723 while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
719 session_close_by_pid(pid, status); 724 session_close_by_pid(pid, status);
720 /* 725 /*
721 * there is a race between channel_free_all() killing children and 726 * there is a race between channel_detach_all() killing remaining
722 * children dying before kill() 727 * children and children dying before kill()
723 */ 728 */
724 channel_detach_all(); 729 channel_detach_all();
725 channel_stop_listening();
726 730
727 while (session_have_children()) { 731 while (session_have_children()) {
728 pid = waitpid(-1, &status, 0); 732 pid = waitpid(-1, &status, 0);