From fa4f2f14870500eeab3233da07647a7c2c5e1648 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 23 Dec 2008 14:43:51 -0800 Subject: Adjust minilogd's maximums A max of 200000 lines stored, at 8K per line, was a little ridiculous and soaked up way to much memory if a syslogger was not started. Drop the max to 10000 so that we don't kill the user's system. Signed-off-by: Aaron Griffin --- minilogd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'minilogd.c') diff --git a/minilogd.c b/minilogd.c index b24fb75..b48f0b1 100644 --- a/minilogd.c +++ b/minilogd.c @@ -18,6 +18,9 @@ #include #include +#define MAX_BUF_LINES 10000 +#define BUF_LINE_SIZE 8192 + static int we_own_log=0; static char **buffer=NULL; static int buflines=0; @@ -103,16 +106,16 @@ void runDaemon(int sock) { cleanup(-1); } if ( (x>0) && pfds.revents & (POLLIN | POLLPRI)) { - message = calloc(8192,sizeof(char)); + message = calloc(BUF_LINE_SIZE,sizeof(char)); recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen); alarm(2); signal(SIGALRM, alarm_handler); - len = read(recvsock,message,8192); + len = read(recvsock,message,BUF_LINE_SIZE); alarm(0); close(recvsock); if (len>0) { /*printf("line recv'd: %s\n", message);*/ - if (buflines < 200000) { + if (buflines < MAX_BUF_LINES) { if (buffer) buffer = realloc(buffer,(buflines+1)*sizeof(char *)); else -- cgit v1.2.3