作者allen501pc.bbs@bbs.sa.ncyu.edu.tw (靜養中..) 看板: itoc
標題[問題]m_quota
時間新綠園 (2007/03/24 Sat 01:15:43)
敝站板上信件過多的問題尚未解決,看了一下mail.c中的m_quota,發現有些疑問?
想請教各位大大~
#ifdef OVERDUE_MAILDEL
usint
m_quota()
{
usint status;
int fd, count, fsize, limit, xmode;
time_t mail_due, mark_due;
struct stat st;
HDR *head, *tail;
char *base, *folder, date[9];
if ((fd = open(folder = cmbox.dir, O_RDWR)) < 0)
return 0;
status = 0;
fsize = limit = 0;
if (!fstat(fd, &st) && (fsize = st.st_size) >= sizeof(HDR) &&
(base = (char *) malloc(fsize)))
{
/* flock(fd, LOCK_EX); */
/* Thor.981205: 用 fcntl 取代flock, POSIX標準用法 */
f_exlock(fd);
if ((fsize = read(fd, base, fsize)) >= sizeof(HDR))
* 初始fsize = read(fd, base, fsize)
{
int prune; /* number of pruned mail */
limit = time(0);
mail_due = limit - MAIL_DUE * 86400;
mark_due = limit - MARK_DUE * 86400;
st.st_mtime = limit + CHECK_PERIOD;
str_stamp(date, &st.st_mtime);
limit = cuser.userlevel;
limit = (limit & (PERM_ALLADMIN | PERM_MBOX)) ? MAX_BBSMAIL : (limit &
PERM_VALID) ? MAX_VALIDMAIL : MAX_NOVALIDMAIL;
count = fsize / sizeof(HDR);
head = (HDR *) base;
tail = (HDR *) (base + fsize);
prune = 0; *設定 prune為0
do
{
/* itoc.011013.註解: 這次加上了 MAIL_DELETE,要過 CHECK_PERIOD 下一次
才會真正刪除 */
/* itoc.011013.註解: 除了 m_quota() 以外,在 bpop3.c 裡面,若取信時要
求從伺服器上刪除,>也會加上 MAIL_DELETE 的旗標 */
xmode = head->xmode;
if (xmode & MAIL_DELETE)
{
char fpath[64];
hdr_fpath(fpath, folder, head);
unlink(fpath);
prune--; *prune 減1存回去!!
continue;
}
if (!(xmode & MAIL_READ))
status |= STATUS_BIFF;
if ((count > limit) ||
(head->chrono <= (xmode & MAIL_MARKED ? mark_due : mail_due)))
{
count--;
head->xmode = xmode | MAIL_DELETE;
strcpy(head->date, date);
status |= STATUS_MQUOTA;
}
if (prune) *若prune<0,則成立
head[prune] = head[0];
} while (++head < tail); * 若prune 都有動作,則prune<0
fsize += (prune * sizeof(HDR)); * fsize實際上是+ 負值
if ((fsize > 0) && (prune || (status & STATUS_MQUOTA)))
{
lseek(fd, 0, SEEK_SET);
write(fd, base, fsize);
ftruncate(fd, fsize);
}
}
/* flock(fd, LOCK_UN); */
/* Thor.981205: 用 fcntl 取代flock, POSIX標準用法 */
f_unlock(fd);
free(base);
}
close(fd);
/* if (fsize > limit) *這段因為不到100封仍然會
status ^= STATUS_MAILOVER; 出現警告,所以被我拿掉了!
else if (fsize < sizeof(HDR))
unlink(folder); */
if (fsize < sizeof(HDR))
unlink(folder);
return status;
}
#endif
請問一下,最後的 if(fsize > limit) 是怎麼判斷的?
怎麼會使用者連43封不到就送出 STATUS_MAILOVER ? (信件過多的訊息)
如有解釋錯誤,請各位大大指正,謝謝.
--
╒═╕
║ ║║║ ★愛過方知情重★
╠═╣║║╓═┐╭─╮
║ ║║║╠═╜║ ║ ★醉過方知酒濃★
║ ║║║╰─╯│ │
--
╭─ Origin ─╗ 新綠園 bbs.sa.ncyu.edu.tw ~ κλμ ─┤
├ Author ╡ 220-129-173-10.dynamic.hinet.net