diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-10-11 17:11:00 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-10-11 17:11:00 +0200 |
commit | 8c3d40b798e3ed68fb03629d87b55140cb6bc044 (patch) | |
tree | b6320896b01d58c083e82a0b5c22e13240dcc6f2 | |
parent | ed324a9a610f91f54514eb713ff5593bde1012e6 (diff) | |
download | rsyslog-8c3d40b798e3ed68fb03629d87b55140cb6bc044.tar.gz rsyslog-8c3d40b798e3ed68fb03629d87b55140cb6bc044.tar.xz rsyslog-8c3d40b798e3ed68fb03629d87b55140cb6bc044.zip |
removed need for math library
by doing math a little bit more optimal in hash table code. Also reduced
memory requirement for imuxsock hash tables (expected number of connections
was set too high -- table can be extended dynamically).
-rw-r--r-- | doc/imuxsock.html | 6 | ||||
-rw-r--r-- | plugins/imuxsock/imuxsock.c | 4 | ||||
-rw-r--r-- | runtime/hashtable.c | 16 | ||||
-rw-r--r-- | tools/Makefile.am | 2 |
4 files changed, 22 insertions, 6 deletions
diff --git a/doc/imuxsock.html b/doc/imuxsock.html index 4dd28f26..ee5db22d 100644 --- a/doc/imuxsock.html +++ b/doc/imuxsock.html @@ -139,6 +139,12 @@ the $InputUnixListenSocketCreatePath and the $InputUnixListenSocketHostName.</p> $InputUnixListenSocketCreatePath on # turn on for *next* socket $InputUnixListenSocketHostName /var/run/sshd/dev/log </textarea> +<p>The following sample is used to turn off input rate limiting on the system log +socket. +<textarea rows="6" cols="70">$ModLoad imuxsock # needs to be done just once + +$SystemLogRateLimitInterval 0 # turn off rate limiting +</textarea> <p>[<a href="rsyslog_conf.html">rsyslog.conf overview</a>] [<a href="manual.html">manual index</a>] [<a href="http://www.rsyslog.com/">rsyslog site</a>]</p> <p><font size="2">This documentation is part of the diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index 566dde1b..0eee1122 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -283,7 +283,7 @@ addLstnSocketName(void __attribute__((unused)) *pVal, uchar *pNewVal) } CHKiRet(prop.ConstructFinalize(listeners[nfd].hostName)); if(ratelimitInterval > 0) { - if((listeners[nfd].ht = create_hashtable(1000, hash_from_key_fn, key_equals_fn, NULL)) == NULL) { + if((listeners[nfd].ht = create_hashtable(100, hash_from_key_fn, key_equals_fn, NULL)) == NULL) { /* in this case, we simply turn of rate-limiting */ dbgprintf("imuxsock: turning off rate limiting because we could not " "create hash table\n"); @@ -761,7 +761,7 @@ CODESTARTwillRun if(pLogSockName != NULL) listeners[0].sockName = pLogSockName; if(ratelimitIntervalSysSock > 0) { - if((listeners[0].ht = create_hashtable(1000, hash_from_key_fn, key_equals_fn, NULL)) == NULL) { + if((listeners[0].ht = create_hashtable(100, hash_from_key_fn, key_equals_fn, NULL)) == NULL) { /* in this case, we simply turn of rate-limiting */ dbgprintf("imuxsock: turning off rate limiting because we could not " "create hash table\n"); diff --git a/runtime/hashtable.c b/runtime/hashtable.c index 41fc60fe..a01fa7d9 100644 --- a/runtime/hashtable.c +++ b/runtime/hashtable.c @@ -23,7 +23,17 @@ static const unsigned int primes[] = { 805306457, 1610612741 }; const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]); -const float max_load_factor = 0.65; + +#define MAX_LOAD_FACTOR 65 /* to get real factor, divide by 100! */ + +/* compute max load. We use a constant factor of 0.65, but do + * everything times 100, so that we do not need floats. + */ +static inline unsigned +getLoadLimit(unsigned size) +{ + return (unsigned int) ((unsigned long long) size * MAX_LOAD_FACTOR) / 100; +} /*****************************************************************************/ struct hashtable * @@ -50,7 +60,7 @@ create_hashtable(unsigned int minsize, h->hashfn = hashf; h->eqfn = eqf; h->dest = dest; - h->loadlimit = (unsigned int) ceil(size * max_load_factor); + h->loadlimit = getLoadLimit(size); return h; } @@ -123,7 +133,7 @@ hashtable_expand(struct hashtable *h) } } h->tablelength = newsize; - h->loadlimit = (unsigned int) ceil(newsize * max_load_factor); + h->loadlimit = getLoadLimit(newsize); return -1; } diff --git a/tools/Makefile.am b/tools/Makefile.am index 6541194a..96657ad4 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -36,7 +36,7 @@ rsyslogd_SOURCES = \ \ ../dirty.h rsyslogd_CPPFLAGS = $(PTHREADS_CFLAGS) $(RSRT_CFLAGS) -rsyslogd_LDADD = $(ZLIB_LIBS) $(PTHREADS_LIBS) $(RSRT_LIBS) $(SOL_LIBS) -lm +rsyslogd_LDADD = $(ZLIB_LIBS) $(PTHREADS_LIBS) $(RSRT_LIBS) $(SOL_LIBS) rsyslogd_LDFLAGS = -export-dynamic if ENABLE_DIAGTOOLS |