summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2019-01-07 20:50:44 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2019-01-07 20:50:44 +0000
commit4b343b08b415591af499f18323dd4dcb8f30f34d (patch)
tree17d63d2791b6b9d520460f1e4259e73437d2e526 /bin
parent0555b9270b62a384d220dad75c726e7679db376d (diff)
short circuit mail check if MAIL is unset. ok anton
Diffstat (limited to 'bin')
-rw-r--r--bin/ksh/mail.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/bin/ksh/mail.c b/bin/ksh/mail.c
index f4b31e0c3bf..570722d57bc 100644
--- a/bin/ksh/mail.c
+++ b/bin/ksh/mail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mail.c,v 1.24 2018/06/25 15:22:30 cheloha Exp $ */
+/* $OpenBSD: mail.c,v 1.25 2019/01/07 20:50:43 tedu Exp $ */
/*
* Mailbox checking code by Robert J. Gibson, adapted for PD ksh by
@@ -47,6 +47,15 @@ mcheck(void)
struct stat stbuf;
static int first = 1;
+ if (mplist)
+ mbp = mplist;
+ else if ((vp = global("MAIL")) && (vp->flag & ISSET))
+ mbp = &mbox;
+ else
+ mbp = NULL;
+ if (mbp == NULL)
+ return;
+
clock_gettime(CLOCK_MONOTONIC, &now);
if (first) {
mlastchkd = now;
@@ -56,13 +65,6 @@ mcheck(void)
if (elapsed.tv_sec >= mailcheck_interval) {
mlastchkd = now;
- if (mplist)
- mbp = mplist;
- else if ((vp = global("MAIL")) && (vp->flag & ISSET))
- mbp = &mbox;
- else
- mbp = NULL;
-
while (mbp) {
if (mbp->mb_path && stat(mbp->mb_path, &stbuf) == 0 &&
S_ISREG(stbuf.st_mode)) {