summaryrefslogtreecommitdiff
path: root/serverloop.c
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 /serverloop.c
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
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c12
1 files changed, 8 insertions, 4 deletions
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);