From e8108591e441b331093f6ea9759d403ca071a811 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 6 Jun 2011 18:41:54 +0200 Subject: [PATCH] Warn the user that will try to enable VM that VM sucks. But still allows him to enable VM with a special option. --- src/config.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/config.c b/src/config.c index 44c0e21d5..a5d5ce2c5 100644 --- a/src/config.c +++ b/src/config.c @@ -30,6 +30,7 @@ void loadServerConfig(char *filename) { char buf[REDIS_CONFIGLINE_MAX+1], *err = NULL; int linenum = 0; sds line = NULL; + int really_use_vm = 0; if (filename[0] == '-' && filename[1] == '\0') fp = stdin; @@ -243,6 +244,10 @@ void loadServerConfig(char *filename) { if ((server.vm_enabled = yesnotoi(argv[1])) == -1) { err = "argument must be 'yes' or 'no'"; goto loaderr; } + } else if (!strcasecmp(argv[0],"really-use-vm") && argc == 2) { + if ((really_use_vm = yesnotoi(argv[1])) == -1) { + err = "argument must be 'yes' or 'no'"; goto loaderr; + } } else if (!strcasecmp(argv[0],"vm-swap-file") && argc == 2) { zfree(server.vm_swap_file); server.vm_swap_file = zstrdup(argv[1]); @@ -303,6 +308,7 @@ void loadServerConfig(char *filename) { sdsfree(line); } if (fp != stdin) fclose(fp); + if (server.vm_enabled && !really_use_vm) goto vm_warning; return; loaderr: @@ -311,6 +317,15 @@ loaderr: fprintf(stderr, ">>> '%s'\n", line); fprintf(stderr, "%s\n", err); exit(1); + +vm_warning: + fprintf(stderr, "\nARE YOU SURE YOU WANT TO USE VM?\n\n"); + fprintf(stderr, "Redis Virtual Memory is going to be deprecated soon,\n"); + fprintf(stderr, "we think you should NOT use it, but use Redis only if\n"); + fprintf(stderr, "your data is suitable for an in-memory database.\n"); + fprintf(stderr, "If you *really* want VM add this in the config file:\n"); + fprintf(stderr, "\n really-use-vm yes\n\n"); + exit(1); } /*----------------------------------------------------------------------------- -- GitLab