diff options
author | dormando <dormando@rydia.net> | 2017-10-16 16:08:37 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-11-28 14:18:05 -0800 |
commit | 76d0a13a1e49caf5bbaea4e6165a3568090b5366 (patch) | |
tree | dac031d46c0792994c856e893d86b3bc500a293e /storage.c | |
parent | 2c4528697f404cdbfc9bfe319d7e2ed22c291a31 (diff) | |
download | memcached-76d0a13a1e49caf5bbaea4e6165a3568090b5366.tar.gz |
extstore: pause compaction thread with hash expand
could potentially cause weirdness when the hash table is swapped.
Diffstat (limited to 'storage.c')
-rw-r--r-- | storage.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -177,6 +177,7 @@ static int storage_compact_check(void *storage, logger *l, } static pthread_t storage_compact_tid; +static pthread_mutex_t storage_compact_plock; #define MIN_STORAGE_COMPACT_SLEEP 10000 #define MAX_STORAGE_COMPACT_SLEEP 2000000 @@ -328,12 +329,15 @@ static void *storage_compact_thread(void *arg) { wrap.io.len = settings.ext_wbuf_size; wrap.io.mode = OBJ_IO_READ; wrap.io.cb = _storage_compact_cb; + pthread_mutex_lock(&storage_compact_plock); while (1) { + pthread_mutex_unlock(&storage_compact_plock); if (to_sleep) { extstore_run_maint(storage); usleep(to_sleep); } + pthread_mutex_lock(&storage_compact_plock); if (!compacting && storage_compact_check(storage, l, &page_id, &page_version, &page_size, &drop_unread)) { @@ -393,6 +397,7 @@ static void *storage_compact_thread(void *arg) { } // TODO +// logger needs logger_destroy() to exist/work before this is safe. /*int stop_storage_compact_thread(void) { int ret; pthread_mutex_lock(&lru_maintainer_lock); @@ -406,9 +411,18 @@ static void *storage_compact_thread(void *arg) { return 0; }*/ +void storage_compact_pause(void) { + pthread_mutex_lock(&storage_compact_plock); +} + +void storage_compact_resume(void) { + pthread_mutex_unlock(&storage_compact_plock); +} + int start_storage_compact_thread(void *arg) { int ret; + pthread_mutex_init(&storage_compact_plock, NULL); if ((ret = pthread_create(&storage_compact_tid, NULL, storage_compact_thread, arg)) != 0) { fprintf(stderr, "Can't create storage_compact thread: %s\n", |