summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-24 22:08:30 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-24 22:08:30 +0800
commitb472d2cfd7e0be60ca43d844b6ec2ddf322ffec0 (patch)
treecc3247547f24ef673a3be65915702dddec61a486
parentd328380ba6607c3da9d72084f4c6825b565a0bda (diff)
downloadpttbbs-b472d2cfd7e0be60ca43d844b6ec2ddf322ffec0.tar
pttbbs-b472d2cfd7e0be60ca43d844b6ec2ddf322ffec0.tar.gz
pttbbs-b472d2cfd7e0be60ca43d844b6ec2ddf322ffec0.tar.bz2
pttbbs-b472d2cfd7e0be60ca43d844b6ec2ddf322ffec0.tar.lz
pttbbs-b472d2cfd7e0be60ca43d844b6ec2ddf322ffec0.tar.xz
pttbbs-b472d2cfd7e0be60ca43d844b6ec2ddf322ffec0.tar.zst
pttbbs-b472d2cfd7e0be60ca43d844b6ec2ddf322ffec0.zip
chkload
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@490 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/mbbsd.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 419c13e9..0f224366 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1,4 +1,4 @@
-/* $Id: mbbsd.c,v 1.50 2002/08/23 18:01:30 in2 Exp $ */
+/* $Id: mbbsd.c,v 1.51 2002/08/24 14:08:30 in2 Exp $ */
#include "bbs.h"
#define SOCKET_QLEN 4
@@ -89,28 +89,25 @@ reapchild(int sig)
*/
/* check load and print approriate banner string in buf */
static int
-chkload(char *buf)
+chkload(char *buf, int length)
{
char cpu_load[30];
int i;
i = cpuload(cpu_load);
- sprintf(buf, BANNER " 系統負荷\r\n %s %s \r\n", cpu_load,
- (i > MAX_CPULOAD ? ",高負荷量,請稍後再來 "
- "(請利用port 3000~3010連線)" : ""));
#ifdef INSCREEN
- strlcpy(buf, (i > MAX_CPULOAD ? BANNER
- "高負荷量,請稍後再來(請利用port 3000~3010連線)" : ""),
- sizeof(buf));
+ if( i > MAX_CPULOAD ){
+ strlcpy(buf, BANNER "\r\n系統過載, 請稍後再來\r\n", length);
+ return 1;
+ }
+ buf[0] = 0;
+ return 0;
#else
sprintf(buf, BANNER "%s\r\n",
(i > MAX_CPULOAD ? "高負荷量,請稍後再來(請利用port 3000~3010連線)" : ""));
+ return i > MAX_CPULOAD ? 1 : 0;
#endif
- if (i > MAX_CPULOAD)
- return 1;
-
- return 0;
}
void
@@ -1317,7 +1314,7 @@ check_ban_and_load(int fd)
static int banned = 0;
if ((time(0) - chkload_time) > 1) {
- overload = chkload(buf);
+ overload = chkload(buf, sizeof(buf));
banned = !access(BBSHOME "/BAN", R_OK) &&
(strcmp(fromhost, "localhost") != 0);
chkload_time = time(0);