diff options
Diffstat (limited to 'src/stats.c')
-rw-r--r-- | src/stats.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/src/stats.c b/src/stats.c index cb0f9dd..b1162ff 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1,39 +1,17 @@ /* - * Copyright (c) 1983, 1995-1997 Eric P. Allman + * Copyright (c) 1998 Sendmail, Inc. All rights reserved. + * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the sendmail distribution. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. */ #ifndef lint -static char sccsid[] = "@(#)stats.c 8.11 (Berkeley) 4/9/97"; +static char sccsid[] = "@(#)stats.c 8.22 (Berkeley) 5/19/1998"; #endif /* not lint */ # include "sendmail.h" @@ -50,11 +28,22 @@ bool GotStats = FALSE; /* set when we have stats to merge */ */ void -markstats(e, to) +markstats(e, to, reject) register ENVELOPE *e; register ADDRESS *to; + bool reject; { - if (to == NULL) + if (reject == TRUE) + { + if (e->e_from.q_mailer != NULL) + { + if (bitset(EF_DISCARD, e->e_flags)) + Stat.stat_nd[e->e_from.q_mailer->m_mno]++; + else + Stat.stat_nr[e->e_from.q_mailer->m_mno]++; + } + } + else if (to == NULL) { if (e->e_from.q_mailer != NULL) { @@ -88,6 +77,7 @@ poststats(sfile) char *sfile; { register int fd; + int sff = SFF_REGONLY|SFF_OPENASROOT; struct statistics stat; extern off_t lseek(); @@ -96,15 +86,27 @@ poststats(sfile) (void) time(&Stat.stat_itime); Stat.stat_size = sizeof Stat; + Stat.stat_magic = STAT_MAGIC; + Stat.stat_version = STAT_VERSION; + + if (!bitset(DBS_WRITESTATSTOSYMLINK, DontBlameSendmail)) + sff |= SFF_NOSLINK; + if (!bitset(DBS_WRITESTATSTOHARDLINK, DontBlameSendmail)) + sff |= SFF_NOHLINK; - fd = safeopen(sfile, O_RDWR, 0644, SFF_REGONLY|SFF_NOLINK|SFF_OPENASROOT); + fd = safeopen(sfile, O_RDWR, 0644, sff); if (fd < 0) { + if (LogLevel > 12) + sm_syslog(LOG_INFO, NOQID, "poststats: %s: %s", + sfile, errstring(errno)); errno = 0; return; } if (read(fd, (char *) &stat, sizeof stat) == sizeof stat && - stat.stat_size == sizeof stat) + stat.stat_size == sizeof stat && + stat.stat_magic == Stat.stat_magic && + stat.stat_version == Stat.stat_version) { /* merge current statistics into statfile */ register int i; @@ -115,6 +117,8 @@ poststats(sfile) stat.stat_bf[i] += Stat.stat_bf[i]; stat.stat_nt[i] += Stat.stat_nt[i]; stat.stat_bt[i] += Stat.stat_bt[i]; + stat.stat_nr[i] += Stat.stat_nr[i]; + stat.stat_nd[i] += Stat.stat_nd[i]; } } else |