summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Balcer <piotr.balcer@intel.com>2019-09-19 12:18:58 +0200
committerdormando <dormando@rydia.net>2019-09-19 14:40:47 -0700
commitc0a868b5b56433c0a01ea2ce9f0b30c111ab6e5c (patch)
tree1518a5c051f81902eac8020e0e04665842ec21a9
parent9485db55edf2dc6b75b2024770ae41ad6b68de18 (diff)
downloadmemcached-c0a868b5b56433c0a01ea2ce9f0b30c111ab6e5c.tar.gz
restart: add missing msync at close time
To make sure that the backing pages actually make it to the backing device prior to shutdown, munmap must be preceded by an msync call. Additionally, since the metadata file is used as a flag to check if the shutdown was graceful, the data needs to be sync'd prior to that file being written.
-rw-r--r--restart.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/restart.c b/restart.c
index 46f8cc2..591aea5 100644
--- a/restart.c
+++ b/restart.c
@@ -303,6 +303,8 @@ bool restart_mmap_open(const size_t limit, const char *file, void **mem_base) {
/* Gracefully stop/close the shared memory segment */
void restart_mmap_close(void) {
+ msync(mmap_base, slabmem_limit, MS_SYNC);
+
if (restart_save(memory_file) != 0) {
fprintf(stderr, "[restart] failed to save metadata");
}