summaryrefslogtreecommitdiff
path: root/minilogd.c
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2008-12-23 14:43:51 -0800
committerAaron Griffin <aaronmgriffin@gmail.com>2008-12-23 14:43:51 -0800
commitfa4f2f14870500eeab3233da07647a7c2c5e1648 (patch)
tree7376c2760ebd4e6a57ada39258de0d735aba11e3 /minilogd.c
parent0e4ff39e5a5c72b7d4e8d251d029d4342f68b7b6 (diff)
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 <aaronmgriffin@gmail.com>
Diffstat (limited to 'minilogd.c')
-rw-r--r--minilogd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/minilogd.c b/minilogd.c
index b24fb75..b48f0b1 100644
--- a/minilogd.c
+++ b/minilogd.c
@@ -18,6 +18,9 @@
#include <sys/stat.h>
#include <sys/un.h>
+#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