summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-03-28 22:15:20 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-03-28 22:15:20 +0800
commit91fef437949c915b8666265b737f41263eda22bd (patch)
tree058f03b2bdbc0253d96b4f90d4f3e098ae04c2d6
parent498c803bd9ecf9f48cc28dc194869b7fbcf5a32b (diff)
downloadpttbbs-91fef437949c915b8666265b737f41263eda22bd.tar
pttbbs-91fef437949c915b8666265b737f41263eda22bd.tar.gz
pttbbs-91fef437949c915b8666265b737f41263eda22bd.tar.bz2
pttbbs-91fef437949c915b8666265b737f41263eda22bd.tar.lz
pttbbs-91fef437949c915b8666265b737f41263eda22bd.tar.xz
pttbbs-91fef437949c915b8666265b737f41263eda22bd.tar.zst
pttbbs-91fef437949c915b8666265b737f41263eda22bd.zip
PRE_FORK
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@741 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/mbbsd.c15
-rw-r--r--sample/pttbbs.conf4
2 files changed, 17 insertions, 2 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 00e4fa7a..97ba847a 100644
--- a/mbbsd/mbbsd.c
+++ b/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/sample/pttbbs.conf b/sample/pttbbs.conf
index 0b0e51d6..1903a6af 100644
--- a/sample/pttbbs.conf
+++ b/sample/pttbbs.conf
@@ -74,6 +74,10 @@
/* 設定最大可再買幾封信箱 (default: 1000) */
#define MAX_EXKEEPMAIL (1000)
+/* 對於 port 23的, 會預先 fork 幾隻出來. 如此在系統負荷高的時候,
+ 仍可有好的上站率 */
+//#define PRE_FORK 10
+
/* 前進站畫面 */
#define INSCREEN \
"前進站畫面 (請至 pttbbs.conf 修改您的前進站畫面)"