summaryrefslogtreecommitdiff
path: root/items.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-07-16 16:28:09 -0700
committerdormando <dormando@rydia.net>2017-07-16 16:28:09 -0700
commit18316347865978868d70cc70dad54df2e3a8357e (patch)
treed5883c5845129fd149f8e2bf23cfb34a1baa2a5f /items.c
parent328629445c71e6c17074f6e9e0e3ef585b58f167 (diff)
downloadmemcached-18316347865978868d70cc70dad54df2e3a8357e.tar.gz
fix for musl libc: avoid huge stack allocation
too used to thread stacks being several megabytes, maybe :) The crawlerstats gets a bit big so do a normal memory allocation for it. seems to work, but I can't run tests on musl without making the debug binary build.
Diffstat (limited to 'items.c')
-rw-r--r--items.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/items.c b/items.c
index 83a2ea3..ccde768 100644
--- a/items.c
+++ b/items.c
@@ -1497,11 +1497,15 @@ static void *lru_maintainer_thread(void *arg) {
rel_time_t last_automove_check = 0;
useconds_t next_juggles[MAX_NUMBER_OF_SLAB_CLASSES];
useconds_t backoff_juggles[MAX_NUMBER_OF_SLAB_CLASSES];
- struct crawler_expired_data cdata;
- memset(&cdata, 0, sizeof(struct crawler_expired_data));
+ struct crawler_expired_data *cdata =
+ calloc(1, sizeof(struct crawler_expired_data));
+ if (cdata == NULL) {
+ fprintf(stderr, "Failed to allocate crawler data for LRU maintainer thread\n");
+ abort();
+ }
memset(next_juggles, 0, sizeof(next_juggles));
- pthread_mutex_init(&cdata.lock, NULL);
- cdata.crawl_complete = true; // kick off the crawler.
+ pthread_mutex_init(&cdata->lock, NULL);
+ cdata->crawl_complete = true; // kick off the crawler.
logger *l = logger_create();
if (l == NULL) {
fprintf(stderr, "Failed to allocate logger for LRU maintainer thread\n");
@@ -1566,7 +1570,7 @@ static void *lru_maintainer_thread(void *arg) {
/* Once per second at most */
if (settings.lru_crawler && last_crawler_check != current_time) {
- lru_maintainer_crawler_check(&cdata, l);
+ lru_maintainer_crawler_check(cdata, l);
last_crawler_check = current_time;
}
@@ -1595,6 +1599,8 @@ static void *lru_maintainer_thread(void *arg) {
}
pthread_mutex_unlock(&lru_maintainer_lock);
slab_automove_free(am);
+ // LRU crawler *must* be stopped.
+ free(cdata);
if (settings.verbose > 2)
fprintf(stderr, "LRU maintainer thread stopping\n");