From ec8e6e442202ab18fad2de01f0bcb04943890f88 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 13 Jul 2007 07:11:25 +0000 Subject: - removed some now-unused fields from struct filed - move file size limit fields in struct field to the "right spot" (the file writing part of the union - f_un.f_file) --- ChangeLog | 3 +++ Makefile.am | 2 +- syslogd-types.h | 10 +++------- syslogd.c | 22 +++++++++++----------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 291cf7f2..82eec225 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ Version 1.16.0 (RGer/Peter Vrabec), 2007-07-1? thanks to varmojfekoj for the patch - begun to better modularize syslogd.c - this is an ongoing project; moved type definitions to a separate file +- removed some now-unused fields from struct filed +- move file size limit fiels in struct field to the "right spot" (the file + writing part of the union - f_un.f_file) --------------------------------------------------------------------------- Version 1.15.1 (RGer), 2007-07-10 - fixed a bug that caused a dynaFile selector to stall when there was diff --git a/Makefile.am b/Makefile.am index 59fa2c47..226d722c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ klogd_SOURCES=klogd.c syslog.c pidfile.c ksym.c ksym_mod.c rfc3195d_SOURCES=rfc3195d.c -syslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c +syslogd_SOURCES=syslogd.c pidfile.c template.c outchannel.c stringbuf.c srUtils.c parse.c syslogd-types.h syslogd_CPPFLAGS=$(mysql_includes) syslogd_LDADD=$(mysql_libs) $(zlib_libs) $(pthreads_libs) diff --git a/syslogd-types.h b/syslogd-types.h index ca608149..0261d6b6 100644 --- a/syslogd-types.h +++ b/syslogd-types.h @@ -170,8 +170,6 @@ struct filed { struct filed *f_next; /* next in linked list */ short f_type; /* entry type, see below */ short f_file; /* file descriptor */ - off_t f_sizeLimit; /* file size limit, 0 = no limit */ - char *f_sizeLimitCmd; /* command to carry out when size limit is reached */ time_t f_time; /* time this was last written */ /* filter properties */ enum { @@ -244,12 +242,10 @@ struct filed { * pointer points to the overall structure. */ dynaFileCacheEntry **dynCache; + off_t f_sizeLimit; /* file size limit, 0 = no limit */ + char *f_sizeLimitCmd; /* command to carry out when size limit is reached */ } f_file; } f_un; - char f_lasttime[16]; /* time of last occurrence */ - char f_prevhost[MAXHOSTNAMELEN+1]; /* host from which recd. */ - int f_prevpri; /* pri of f_prevline */ - int f_prevlen; /* length of f_prevline */ int f_prevcount; /* repetition cnt of prevline */ int f_repeatcount; /* number of "repeated" msgs */ int f_flags; /* store some additional flags */ @@ -259,7 +255,7 @@ struct filed { int f_iIovUsed; /* nbr of elements used in IOV */ char *f_psziov; /* iov as string */ int f_iLenpsziov; /* length of iov as string */ - struct msg* f_pMsg; /* pointer to the message (this wil + struct msg* f_pMsg; /* pointer to the message (this will * replace the other vars with msg * content later). This is preserved after * the message has been processed - it is diff --git a/syslogd.c b/syslogd.c index 0756e3b1..78b97980 100644 --- a/syslogd.c +++ b/syslogd.c @@ -5835,7 +5835,7 @@ int resolveFileSizeLimit(selector_t *f) off_t actualFileSize; assert(f != NULL); - if(f->f_sizeLimitCmd == NULL) + if(f->f_un.f_file.f_sizeLimitCmd == NULL) return 1; /* nothing we can do in this case... */ /* TODO: this is a really quick hack. We need something more @@ -5843,13 +5843,13 @@ int resolveFileSizeLimit(selector_t *f) * the overall idea works (I hope it won't survive...). * rgerhards 2005-06-21 */ - system(f->f_sizeLimitCmd); + system(f->f_un.f_file.f_sizeLimitCmd); f->f_file = open(f->f_un.f_file.f_fname, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY, f->f_un.f_file.fCreateMode); actualFileSize = lseek(f->f_file, 0, SEEK_END); - if(actualFileSize >= f->f_sizeLimit) { + if(actualFileSize >= f->f_un.f_file.f_sizeLimit) { /* OK, it didn't work out... */ return 1; } @@ -6046,9 +6046,9 @@ again: /* check if we have a file size limit and, if so, * obey to it. */ - if(f->f_sizeLimit != 0) { + if(f->f_un.f_file.f_sizeLimit != 0) { actualFileSize = lseek(f->f_file, 0, SEEK_END); - if(actualFileSize >= f->f_sizeLimit) { + if(actualFileSize >= f->f_un.f_file.f_sizeLimit) { char errMsg[256]; /* for now, we simply disable a file once it is * beyond the maximum size. This is better than having @@ -6061,14 +6061,14 @@ again: f->f_type = F_UNUSED; snprintf(errMsg, sizeof(errMsg), "no longer writing to file %s; grown beyond configured file size of %lld bytes, actual size %lld - configured command did not resolve situation", - f->f_un.f_file.f_fname, (long long) f->f_sizeLimit, (long long) actualFileSize); + f->f_un.f_file.f_fname, (long long) f->f_un.f_file.f_sizeLimit, (long long) actualFileSize); errno = 0; logerror(errMsg); return; } else { snprintf(errMsg, sizeof(errMsg), "file %s had grown beyond configured file size of %lld bytes, actual size was %lld - configured command resolved situation", - f->f_un.f_file.f_fname, (long long) f->f_sizeLimit, (long long) actualFileSize); + f->f_un.f_file.f_fname, (long long) f->f_un.f_file.f_sizeLimit, (long long) actualFileSize); errno = 0; logerror(errMsg); } @@ -7442,7 +7442,7 @@ static void init() nextp = f; /* be careful: the default below must be set BEFORE calling cfline()! */ - f->f_sizeLimit = 0; /* default value, use outchannels to configure! */ + f->f_un.f_file.f_sizeLimit = 0; /* default value, use outchannels to configure! */ #if CONT_LINE cfline(cbuf, f); #else @@ -7798,11 +7798,11 @@ static void cflineParseOutchannel(selector_t *f, uchar* p) /* OK, we finally got a correct template. So let's use it... */ strncpy(f->f_un.f_file.f_fname, pOch->pszFileTemplate, MAXFNAME); - f->f_sizeLimit = pOch->uSizeLimit; + f->f_un.f_file.f_sizeLimit = pOch->uSizeLimit; /* WARNING: It is dangerous "just" to pass the pointer. As we * never rebuild the output channel description, this is acceptable here. */ - f->f_sizeLimitCmd = pOch->cmdOnSizeLimit; + f->f_un.f_file.f_sizeLimitCmd = pOch->cmdOnSizeLimit; /* back to the input string - now let's look for the template to use * Just as a general precaution, we skip whitespace. @@ -7821,7 +7821,7 @@ static void cflineParseOutchannel(selector_t *f, uchar* p) cflineSetTemplateAndIOV(f, szBuf); dprintf("[outchannel]filename: '%s', template: '%s', size: %lu\n", f->f_un.f_file.f_fname, szBuf, - f->f_sizeLimit); + f->f_un.f_file.f_sizeLimit); } -- cgit