summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-06-26 03:06:22 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-06-26 03:06:22 +0800
commitacc243fc5d8cd196664f64ccf68c47351a60260a (patch)
treed1689efff77a3a93e0dfeee0549e437dbefcceed
parent85d2b41177d66a43eb0a176c0a9c686569e9e460 (diff)
downloadpttbbs-acc243fc5d8cd196664f64ccf68c47351a60260a.tar
pttbbs-acc243fc5d8cd196664f64ccf68c47351a60260a.tar.gz
pttbbs-acc243fc5d8cd196664f64ccf68c47351a60260a.tar.bz2
pttbbs-acc243fc5d8cd196664f64ccf68c47351a60260a.tar.lz
pttbbs-acc243fc5d8cd196664f64ccf68c47351a60260a.tar.xz
pttbbs-acc243fc5d8cd196664f64ccf68c47351a60260a.tar.zst
pttbbs-acc243fc5d8cd196664f64ccf68c47351a60260a.zip
1.debug select_read problem with "SR" in board name.
2.cache mailsum. get_sum_record is a bad function that cause a lot of IO git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2087 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/bbs.c4
-rw-r--r--mbbsd/mail.c27
-rw-r--r--mbbsd/read.c9
3 files changed, 29 insertions, 11 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 1b8a77ce..f2f48a05 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1665,8 +1665,10 @@ del_range(int ent, fileheader_t *fhdr, char *direct)
#endif
fixkeep(direct, inum1);
- if (currmode & MODE_BOARD)
+ if (currmode & MODE_BOARD) // Ptt:update cache
setbtotal(currbid);
+ else if(currstat == RMAIL)
+ touchmailusage();
return DIRCHANGED;
}
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 792dc976..015776e3 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -137,10 +137,15 @@ m_init()
sethomedir(currmaildir, cuser.userid);
}
-int
-chkmailbox()
+void
+touchmailusage()
{
- if (!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT)) {
+ mailkeep=0;
+}
+
+void
+setupmailusage()
+{ // Ptt: get_sum_records is a bad function
int max_keepmail = MAX_KEEPMAIL;
if (HAS_PERM(PERM_SYSSUBOP) || HAS_PERM(PERM_SMG) ||
HAS_PERM(PERM_PRG) || HAS_PERM(PERM_ACTION) || HAS_PERM(PERM_PAINT)) {
@@ -155,11 +160,18 @@ chkmailbox()
mailsumlimit = 50;
mailsumlimit += (cuser.exmailbox + ADD_EXMAILBOX) * 10;
mailmaxkeep = max_keepmail + cuser.exmailbox;
+ mailkeep=get_num_records(currmaildir,sizeof(fileheader_t));
+ mailsum =get_sum_records(currmaildir, sizeof(fileheader_t));
+}
+
+int
+chkmailbox()
+{
+ if (!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT)) {
+ if(!mailkeep) setupmailusage();
m_init();
- if ((mailkeep = get_num_records(currmaildir, sizeof(fileheader_t))) >
- mailmaxkeep ||
- (mailsum = get_sum_records(currmaildir, sizeof(fileheader_t))) >
- mailsumlimit) {
+ if (mailkeep > mailmaxkeep ||
+ mailsum > mailsumlimit) {
bell();
bell();
vmsg("您保存信件數目或容量 %d 超出上限 %d, 請整理",
@@ -829,6 +841,7 @@ mail_del(int ent, fileheader_t * fhdr, char *direct)
if (getans(msg_del_ny) == 'y') {
if (!delete_record(direct, sizeof(*fhdr), ent)) {
+ touchmailusage();
setdirpath(genbuf, direct, fhdr->filename);
unlink(genbuf);
return DIRCHANGED;
diff --git a/mbbsd/read.c b/mbbsd/read.c
index 53bc09ba..cb0d397c 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -177,6 +177,9 @@ TagPruner(int bid)
TagNum = 0;
if (bid)
setbtotal(bid);
+ else if(currstat == RMAIL)
+ touchmailusage();
+
return NEWDIRECT;
}
return DONOTHING;
@@ -337,7 +340,7 @@ select_read(keeploc_t * locmem, int sr_mode)
fileheader_t fhs[READSIZE];
char newdirect[MAXPATHLEN];
char keyword[TTLEN + 1] = "";
- char genbuf[MAXPATHLEN], *p = strstr(currdirect, "SR");
+ char genbuf[MAXPATHLEN], *p = strstr(currdirect, "SR.");
static int _mode = 0;
int len, fd, fr, i, count=0, reference = 0;
@@ -374,8 +377,8 @@ select_read(keeploc_t * locmem, int sr_mode)
else
_mode |= sr_mode;
- snprintf(genbuf, sizeof(genbuf), "%s.%X.%X.%X",
- p ? p : "SR",
+ snprintf(genbuf, sizeof(genbuf), "%s%X.%X.%X",
+ p ? p : "SR.",
sr_mode, strlen(keyword), StringHash(keyword));
if( strlen(genbuf) > MAXPATHLEN - 50 )
return READ_REDRAW; // avoid overflow