diff --git a/logger.c b/logger.c index 4a387349b..5a1ef6612 100644 --- a/logger.c +++ b/logger.c @@ -510,7 +510,6 @@ static void logger_thread_sum_stats(struct logger_stats *ls) { STATS_UNLOCK(); } -#define MAX_LOGGER_SLEEP 1000000 #define MIN_LOGGER_SLEEP 1000 /* Primary logger thread routine */ @@ -541,10 +540,10 @@ static void *logger_thread(void *arg) { /* TODO: abstract into a function and share with lru_crawler */ if (!found_logs) { - if (to_sleep < MAX_LOGGER_SLEEP) + if (to_sleep < settings.logger_max_sleep) to_sleep += to_sleep / 8; - if (to_sleep > MAX_LOGGER_SLEEP) - to_sleep = MAX_LOGGER_SLEEP; + if (to_sleep > settings.logger_max_sleep) + to_sleep = settings.logger_max_sleep; } else { to_sleep /= 2; if (to_sleep < MIN_LOGGER_SLEEP) diff --git a/memcached.c b/memcached.c index d4e1f0cd3..3501602fc 100644 --- a/memcached.c +++ b/memcached.c @@ -282,6 +282,7 @@ static void settings_init(void) { settings.crawls_persleep = 1000; settings.logger_watcher_buf_size = LOGGER_WATCHER_BUF_SIZE; settings.logger_buf_size = LOGGER_BUF_SIZE; + settings.logger_max_sleep = 1000000; settings.drop_privileges = false; settings.watch_enabled = true; settings.read_buf_mem_limit = 0; @@ -3885,6 +3886,7 @@ static void usage(void) { " - watcher_logbuf_size: size in kilobytes of per-watcher write buffer. (default: %u)\n" " - worker_logbuf_size: size in kilobytes of per-worker-thread buffer\n" " read by background thread, then written to watchers. (default: %u)\n" + " - logger_max_sleep: time in miliseconds of logger maximum sleep.\n" " - track_sizes: enable dynamic reports for 'stats sizes' command.\n" " - no_hashexpand: disables hash table expansion (dangerous)\n" " - modern: enables options which will be default in future.\n" @@ -4553,6 +4555,7 @@ int main (int argc, char **argv) { IDLE_TIMEOUT, WATCHER_LOGBUF_SIZE, WORKER_LOGBUF_SIZE, + LOGGER_MAX_SLEEP, SLAB_SIZES, SLAB_CHUNK_MAX, TRACK_SIZES, @@ -4606,6 +4609,7 @@ int main (int argc, char **argv) { [IDLE_TIMEOUT] = "idle_timeout", [WATCHER_LOGBUF_SIZE] = "watcher_logbuf_size", [WORKER_LOGBUF_SIZE] = "worker_logbuf_size", + [LOGGER_MAX_SLEEP] = "logger_max_sleep", [SLAB_SIZES] = "slab_sizes", [SLAB_CHUNK_MAX] = "slab_chunk_max", [TRACK_SIZES] = "track_sizes", @@ -5181,6 +5185,17 @@ int main (int argc, char **argv) { case SLAB_SIZES: slab_sizes_unparsed = strdup(subopts_value); break; + case LOGGER_MAX_SLEEP: + if (subopts_value == NULL) { + fprintf(stderr, "Missing logger_max_sleep argument\n"); + return 1; + } + if (!safe_strtoul(subopts_value, &settings.logger_max_sleep)) { + fprintf(stderr, "could not parse argument to logger_max_sleep\n"); + return 1; + } + settings.logger_max_sleep *= 1000; /* microseconds */ + break; case SLAB_CHUNK_MAX: if (subopts_value == NULL) { fprintf(stderr, "Missing slab_chunk_max argument\n"); diff --git a/memcached.h b/memcached.h index ba2ac593c..e124e1641 100644 --- a/memcached.h +++ b/memcached.h @@ -455,6 +455,7 @@ struct settings { int idle_timeout; /* Number of seconds to let connections idle */ unsigned int logger_watcher_buf_size; /* size of logger's per-watcher buffer */ unsigned int logger_buf_size; /* size of per-thread logger buffer */ + unsigned int logger_max_sleep; /* max sleep time of logger */ unsigned int read_buf_mem_limit; /* total megabytes allowable for net buffers */ bool drop_privileges; /* Whether or not to drop unnecessary process privileges */ bool watch_enabled; /* allows watch commands to be dropped */