summaryrefslogtreecommitdiffstats
path: root/mbbsd/mail.c
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-12-22 01:03:41 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-12-22 01:03:41 +0800
commit6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3 (patch)
treebe492524f969d0bdf5ba7493e10e1bec178083a3 /mbbsd/mail.c
parent2fba7bc2ff8950d79b8c98674f8233236e2696c3 (diff)
downloadpttbbs-6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3.tar
pttbbs-6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3.tar.gz
pttbbs-6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3.tar.bz2
pttbbs-6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3.tar.lz
pttbbs-6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3.tar.xz
pttbbs-6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3.tar.zst
pttbbs-6eac320f0270a36f06b9c1f0fe51e37ba9ed3fc3.zip
save IO from check mail
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3257 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/mail.c')
-rw-r--r--mbbsd/mail.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 67ef0ec8..3bf0dd47 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -1868,7 +1868,7 @@ load_mailalert(const char *userid)
struct stat st;
char maildir[MAXPATHLEN];
int fd;
- register int numfiles;
+ register int num;
fileheader_t my_mail;
sethomedir(maildir, userid);
@@ -1876,14 +1876,15 @@ load_mailalert(const char *userid)
return 0;
if (stat(maildir, &st) < 0)
return 0;
- numfiles = st.st_size / sizeof(fileheader_t);
- if (numfiles <= 0)
+ num = st.st_size / sizeof(fileheader_t);
+ if (num <= 0)
return 0;
+ if (num > 50) num = 50; //check only 50 mails
/* 看看有沒有信件還沒讀過?從檔尾回頭檢查,效率較高 */
if ((fd = open(maildir, O_RDONLY)) > 0) {
lseek(fd, st.st_size - sizeof(fileheader_t), SEEK_SET);
- while (numfiles--) {
+ while (num--) {
read(fd, &my_mail, sizeof(fileheader_t));
if (!(my_mail.filemode & FILE_READ)) {
close(fd);