From 372812302ef4bf1808c00f8adfa1f00a5f6ad984 Mon Sep 17 00:00:00 2001 From: in2 Date: Fri, 28 Mar 2003 14:15:20 +0000 Subject: PRE_FORK git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@741 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/mbbsd/mbbsd.c | 15 +++++++++++++-- pttbbs/sample/pttbbs.conf | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c index 00e4fa7a..97ba847a 100644 --- a/pttbbs/mbbsd/mbbsd.c +++ b/pttbbs/mbbsd/mbbsd.c @@ -1,4 +1,4 @@ -/* $Id: mbbsd.c,v 1.68 2003/03/24 10:28:24 in2 Exp $ */ +/* $Id: mbbsd.c,v 1.69 2003/03/28 14:15:20 in2 Exp $ */ #include "bbs.h" #define SOCKET_QLEN 4 @@ -1256,7 +1256,18 @@ daemon_login(int argc, char *argv[], char *envp[]) setuid(BBSUID); chdir(BBSHOME); - snprintf(buf, sizeof(buf), "run/mbbsd.%d.pid", listen_port); +#ifndef NO_FORK +#ifdef PRE_FORK + if( listen_port == 23 ){ // only pre-fork in port 23 + int i; + for( i = 0 ; i < PRE_FORK ; ++i ) + if( fork() <= 0 ) + break; + } +#endif +#endif + + snprintf(buf, sizeof(buf), "run/mbbsd.%d.%d.pid", listen_port, getpid()); if ((fp = fopen(buf, "w"))) { fprintf(fp, "%d\n", getpid()); fclose(fp); diff --git a/pttbbs/sample/pttbbs.conf b/pttbbs/sample/pttbbs.conf index 0b0e51d6..1903a6af 100644 --- a/pttbbs/sample/pttbbs.conf +++ b/pttbbs/sample/pttbbs.conf @@ -74,6 +74,10 @@ /* 設定最大可再買幾封信箱 (default: 1000) */ #define MAX_EXKEEPMAIL (1000) +/* 對於 port 23的, 會預先 fork 幾隻出來. 如此在系統負荷高的時候, + 仍可有好的上站率 */ +//#define PRE_FORK 10 + /* 前進站畫面 */ #define INSCREEN \ "前進站畫面 (請至 pttbbs.conf 修改您的前進站畫面)" -- cgit v1.2.3