Limit rate of syslog messages

Error messages caused by incoming packets need to be rate limited
to avoid filling up disk space.
This commit is contained in:
Miroslav Lichvar
2010-01-13 19:02:07 +01:00
parent 5e86eeacfb
commit 032ac800aa
5 changed files with 38 additions and 15 deletions

View File

@@ -40,6 +40,8 @@ static int initialised = 0;
static int is_detached = 0;
static time_t last_limited = 0;
#ifdef WINNT
static FILE *logfile;
#endif
@@ -213,6 +215,22 @@ LOG_GoDaemon(void)
#endif
}
/* ================================================== */
int
LOG_RateLimited(void)
{
time_t now;
now = time(NULL);
if (last_limited + 10 > now && last_limited <= now)
return 1;
last_limited = now;
return 0;
}
/* ================================================== */
/* Force a core dump and exit without doing abort() or assert(0).
These do funny things with the call stack in the core file that is