diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | serverloop.c | 20 | ||||
-rw-r--r-- | session.c | 18 | ||||
-rw-r--r-- | session.h | 3 |
4 files changed, 41 insertions, 6 deletions
@@ -114,6 +114,10 @@ | |||
114 | - stevesk@cvs.openbsd.org 2001/06/30 18:08:40 | 114 | - stevesk@cvs.openbsd.org 2001/06/30 18:08:40 |
115 | [channels.c channels.h clientloop.c] | 115 | [channels.c channels.h clientloop.c] |
116 | adress -> address; ok markus@ | 116 | adress -> address; ok markus@ |
117 | - markus@cvs.openbsd.org 2001/07/02 13:59:15 | ||
118 | [serverloop.c session.c session.h] | ||
119 | wait until !session_have_children(); bugreport from | ||
120 | Lutz.Jaenicke@aet.TU-Cottbus.DE | ||
117 | 121 | ||
118 | 20010629 | 122 | 20010629 |
119 | - (bal) Removed net_aton() since we don't use it any more | 123 | - (bal) Removed net_aton() since we don't use it any more |
@@ -5941,4 +5945,4 @@ | |||
5941 | - Wrote replacements for strlcpy and mkdtemp | 5945 | - Wrote replacements for strlcpy and mkdtemp |
5942 | - Released 1.0pre1 | 5946 | - Released 1.0pre1 |
5943 | 5947 | ||
5944 | $Id: ChangeLog,v 1.1372 2001/07/04 05:15:15 mouring Exp $ | 5948 | $Id: ChangeLog,v 1.1373 2001/07/04 05:17:40 mouring Exp $ |
diff --git a/serverloop.c b/serverloop.c index ecc7763a4..773292a94 100644 --- a/serverloop.c +++ b/serverloop.c | |||
@@ -35,7 +35,7 @@ | |||
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "includes.h" | 37 | #include "includes.h" |
38 | RCSID("$OpenBSD: serverloop.c,v 1.72 2001/06/27 02:12:52 markus Exp $"); | 38 | RCSID("$OpenBSD: serverloop.c,v 1.73 2001/07/02 13:59:14 markus Exp $"); |
39 | 39 | ||
40 | #include "xmalloc.h" | 40 | #include "xmalloc.h" |
41 | #include "packet.h" | 41 | #include "packet.h" |
@@ -703,11 +703,25 @@ server_loop2(Authctxt *authctxt) | |||
703 | if (writeset) | 703 | if (writeset) |
704 | xfree(writeset); | 704 | xfree(writeset); |
705 | 705 | ||
706 | channel_free_all(); | ||
707 | |||
708 | signal(SIGCHLD, SIG_DFL); | 706 | signal(SIGCHLD, SIG_DFL); |
707 | |||
709 | while ((pid = waitpid(-1, &status, WNOHANG)) > 0) | 708 | while ((pid = waitpid(-1, &status, WNOHANG)) > 0) |
710 | session_close_by_pid(pid, status); | 709 | session_close_by_pid(pid, status); |
710 | /* | ||
711 | * there is a race between channel_free_all() killing children and | ||
712 | * children dying before kill() | ||
713 | */ | ||
714 | channel_free_all(); | ||
715 | |||
716 | while (session_have_children()) { | ||
717 | pid = waitpid(-1, &status, 0); | ||
718 | if (pid > 0) | ||
719 | session_close_by_pid(pid, status); | ||
720 | else { | ||
721 | error("waitpid returned %d: %s", pid, strerror(errno)); | ||
722 | break; | ||
723 | } | ||
724 | } | ||
711 | } | 725 | } |
712 | 726 | ||
713 | static void | 727 | static void |
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include "includes.h" | 35 | #include "includes.h" |
36 | RCSID("$OpenBSD: session.c,v 1.97 2001/06/27 02:12:53 markus Exp $"); | 36 | RCSID("$OpenBSD: session.c,v 1.98 2001/07/02 13:59:15 markus Exp $"); |
37 | 37 | ||
38 | #include "ssh.h" | 38 | #include "ssh.h" |
39 | #include "ssh1.h" | 39 | #include "ssh1.h" |
@@ -1959,6 +1959,22 @@ session_close_by_pid(pid_t pid, int status) | |||
1959 | session_close(s); | 1959 | session_close(s); |
1960 | } | 1960 | } |
1961 | 1961 | ||
1962 | int | ||
1963 | session_have_children(void) | ||
1964 | { | ||
1965 | int i; | ||
1966 | |||
1967 | for(i = 0; i < MAX_SESSIONS; i++) { | ||
1968 | Session *s = &sessions[i]; | ||
1969 | if (s->used && s->pid != -1) { | ||
1970 | debug("session_have_children: id %d pid %d", i, s->pid); | ||
1971 | return 1; | ||
1972 | } | ||
1973 | } | ||
1974 | debug("session_have_children: no more children"); | ||
1975 | return 0; | ||
1976 | } | ||
1977 | |||
1962 | /* | 1978 | /* |
1963 | * this is called when a channel dies before | 1979 | * this is called when a channel dies before |
1964 | * the session 'child' itself dies | 1980 | * the session 'child' itself dies |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: session.h,v 1.10 2001/06/27 02:12:54 markus Exp $ */ | 1 | /* $OpenBSD: session.h,v 1.11 2001/07/02 13:59:15 markus Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. | 4 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. |
@@ -32,5 +32,6 @@ int session_open(Authctxt*, int); | |||
32 | void session_input_channel_req(int, void *); | 32 | void session_input_channel_req(int, void *); |
33 | void session_close_by_pid(pid_t, int); | 33 | void session_close_by_pid(pid_t, int); |
34 | void session_close_by_channel(int, void *); | 34 | void session_close_by_channel(int, void *); |
35 | int session_have_children(void); | ||
35 | 36 | ||
36 | #endif | 37 | #endif |