summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/src/stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sendmail/src/stats.c')
-rw-r--r--contrib/sendmail/src/stats.c85
1 files changed, 53 insertions, 32 deletions
diff --git a/contrib/sendmail/src/stats.c b/contrib/sendmail/src/stats.c
index e03de5f..0ae8ff4 100644
--- a/contrib/sendmail/src/stats.c
+++ b/contrib/sendmail/src/stats.c
@@ -11,28 +11,26 @@
*
*/
-#ifndef lint
-static char id[] = "@(#)$Id: stats.c,v 8.36.14.5 2001/02/14 04:07:30 gshapiro Exp $";
-#endif /* ! lint */
-
#include <sendmail.h>
-#include <sendmail/mailstats.h>
+SM_RCSID("@(#)$Id: stats.c,v 8.52 2001/11/21 13:39:14 gshapiro Exp $")
+
+#include <sendmail/mailstats.h>
static struct statistics Stat;
-static bool GotStats = FALSE; /* set when we have stats to merge */
+static bool GotStats = false; /* set when we have stats to merge */
/* See http://physics.nist.gov/cuu/Units/binary.html */
#define ONE_K 1000 /* one thousand (twenty-four?) */
#define KBYTES(x) (((x) + (ONE_K - 1)) / ONE_K)
- /*
+/*
** MARKSTATS -- mark statistics
**
** Parameters:
** e -- the envelope.
** to -- to address.
-** reject -- whether this is a rejection.
+** type -- type of stats this represents.
**
** Returns:
** none.
@@ -42,13 +40,21 @@ static bool GotStats = FALSE; /* set when we have stats to merge */
*/
void
-markstats(e, to, reject)
+markstats(e, to, type)
register ENVELOPE *e;
register ADDRESS *to;
- bool reject;
+ int type;
{
- if (reject)
+ switch (type)
{
+#if _FFR_QUARANTINE
+ case STATS_QUARANTINE:
+ if (e->e_from.q_mailer != NULL)
+ Stat.stat_nq[e->e_from.q_mailer->m_mno]++;
+ break;
+#endif /* _FFR_QUARANTINE */
+
+ case STATS_REJECT:
if (e->e_from.q_mailer != NULL)
{
if (bitset(EF_DISCARD, e->e_flags))
@@ -57,28 +63,36 @@ markstats(e, to, reject)
Stat.stat_nr[e->e_from.q_mailer->m_mno]++;
}
Stat.stat_cr++;
- }
- else if (to == NULL)
- {
- Stat.stat_cf++;
- if (e->e_from.q_mailer != NULL)
+ break;
+
+ case STATS_NORMAL:
+ if (to == NULL)
{
- Stat.stat_nf[e->e_from.q_mailer->m_mno]++;
- Stat.stat_bf[e->e_from.q_mailer->m_mno] +=
- KBYTES(e->e_msgsize);
+ Stat.stat_cf++;
+ if (e->e_from.q_mailer != NULL)
+ {
+ Stat.stat_nf[e->e_from.q_mailer->m_mno]++;
+ Stat.stat_bf[e->e_from.q_mailer->m_mno] +=
+ KBYTES(e->e_msgsize);
+ }
}
- }
- else
- {
- Stat.stat_ct++;
- Stat.stat_nt[to->q_mailer->m_mno]++;
- Stat.stat_bt[to->q_mailer->m_mno] += KBYTES(e->e_msgsize);
+ else
+ {
+ Stat.stat_ct++;
+ Stat.stat_nt[to->q_mailer->m_mno]++;
+ Stat.stat_bt[to->q_mailer->m_mno] += KBYTES(e->e_msgsize);
+ }
+ break;
+
+ default:
+ /* Silently ignore bogus call */
+ return;
}
- GotStats = TRUE;
+ GotStats = true;
}
- /*
+/*
** CLEARSTATS -- clear statistics structure
**
** Parameters:
@@ -96,9 +110,9 @@ clearstats()
{
/* clear the structure to avoid future disappointment */
memset(&Stat, '\0', sizeof Stat);
- GotStats = FALSE;
+ GotStats = false;
}
- /*
+/*
** POSTSTATS -- post statistics in the statistics file
**
** Parameters:
@@ -115,13 +129,15 @@ void
poststats(sfile)
char *sfile;
{
- register int fd;
+ int fd;
+ static bool entered = false;
long sff = SFF_REGONLY|SFF_OPENASROOT;
struct statistics stats;
extern off_t lseek();
- if (sfile == NULL || !GotStats)
+ if (sfile == NULL || *sfile == '\0' || !GotStats || entered)
return;
+ entered = true;
(void) time(&Stat.stat_itime);
Stat.stat_size = sizeof Stat;
@@ -138,8 +154,9 @@ poststats(sfile)
{
if (LogLevel > 12)
sm_syslog(LOG_INFO, NOQID, "poststats: %s: %s",
- sfile, errstring(errno));
+ sfile, sm_errstring(errno));
errno = 0;
+ entered = false;
return;
}
if (read(fd, (char *) &stats, sizeof stats) == sizeof stats &&
@@ -158,6 +175,9 @@ poststats(sfile)
stats.stat_bt[i] += Stat.stat_bt[i];
stats.stat_nr[i] += Stat.stat_nr[i];
stats.stat_nd[i] += Stat.stat_nd[i];
+#if _FFR_QUARANTINE
+ stats.stat_nq[i] += Stat.stat_nq[i];
+#endif /* _FFR_QUARANTINE */
}
stats.stat_cr += Stat.stat_cr;
stats.stat_ct += Stat.stat_ct;
@@ -173,4 +193,5 @@ poststats(sfile)
/* clear the structure to avoid future disappointment */
clearstats();
+ entered = false;
}
OpenPOWER on IntegriCloud