diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-04 01:17:49 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-04 01:17:49 +0800 |
commit | 6eadc41a587bb1f362470e42d6b615e1567a6343 (patch) | |
tree | 199490368505c416b06ed0a8bf22537a80bf0bce /mbbsd | |
parent | 9bba55fc1bd4fe8899faeb128fe58eff2165aa70 (diff) | |
download | pttbbs-6eadc41a587bb1f362470e42d6b615e1567a6343.tar pttbbs-6eadc41a587bb1f362470e42d6b615e1567a6343.tar.gz pttbbs-6eadc41a587bb1f362470e42d6b615e1567a6343.tar.bz2 pttbbs-6eadc41a587bb1f362470e42d6b615e1567a6343.tar.lz pttbbs-6eadc41a587bb1f362470e42d6b615e1567a6343.tar.xz pttbbs-6eadc41a587bb1f362470e42d6b615e1567a6343.tar.zst pttbbs-6eadc41a587bb1f362470e42d6b615e1567a6343.zip |
- bug fix: ssh still can login even overload
- change start_client calling. wish compiler will use tail call optimization to reduce stack use.
- code revise
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4491 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/mbbsd.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 4dca1e80..d3dfe234 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1365,8 +1365,8 @@ do_term_init(enum TermMode term_mode) raise(SIGWINCH); } -inline static void -start_client(enum TermMode term_mode) +inline static int +start_client(void) { #ifdef CPULIMIT struct rlimit rml; @@ -1397,9 +1397,7 @@ start_client(enum TermMode term_mode) signal_restart(SIGUSR1, talk_request); signal_restart(SIGUSR2, write_request); - dup2(0, 1); - do_term_init(term_mode); Signal(SIGALRM, abort_bbs); alarm(600); @@ -1412,6 +1410,8 @@ start_client(enum TermMode term_mode) Signal(SIGALRM, SIG_IGN); main_menu(); + + return 0; } static void @@ -1642,8 +1642,8 @@ bool parse_argv(int argc, char *argv[], struct ProgramOption *option) int main(int argc, char *argv[], char *envp[]) { + bool oklogin = false; struct ProgramOption *option; - enum TermMode term_mode; init(); @@ -1657,15 +1657,18 @@ main(int argc, char *argv[], char *envp[]) attach_SHM(); if (option->daemon_mode) - daemon_login(argv[0], option); + oklogin = daemon_login(argv[0], option); else - shell_login(argv[0], option); + oklogin = shell_login(argv[0], option); + if (!oklogin) { + free(option); + return 0; + } - term_mode = option->term_mode; + do_term_init(option->term_mode); free(option); - start_client(term_mode); - return 0; + return start_client(); } static int @@ -1818,6 +1821,7 @@ daemon_login(char *argv0, struct ProgramOption *option) close(msock); dup2(csock, 0); close(csock); + dup2(0, 1); XAUTH_GETREMOTENAME(getremotename(xsin.sin_addr, fromhost)); |