Warn the user that will try to enable VM that VM sucks. But still allows him to enable VM with a special option.

This commit is contained in:
antirez
2011-06-06 18:41:54 +02:00
parent b590cedff1
commit a7982fed9e

View File

@ -30,6 +30,7 @@ void loadServerConfig(char *filename) {
char buf[REDIS_CONFIGLINE_MAX+1], *err = NULL; char buf[REDIS_CONFIGLINE_MAX+1], *err = NULL;
int linenum = 0; int linenum = 0;
sds line = NULL; sds line = NULL;
int really_use_vm = 0;
if (filename[0] == '-' && filename[1] == '\0') if (filename[0] == '-' && filename[1] == '\0')
fp = stdin; fp = stdin;
@ -243,6 +244,10 @@ void loadServerConfig(char *filename) {
if ((server.vm_enabled = yesnotoi(argv[1])) == -1) { if ((server.vm_enabled = yesnotoi(argv[1])) == -1) {
err = "argument must be 'yes' or 'no'"; goto loaderr; 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) { } else if (!strcasecmp(argv[0],"vm-swap-file") && argc == 2) {
zfree(server.vm_swap_file); zfree(server.vm_swap_file);
server.vm_swap_file = zstrdup(argv[1]); server.vm_swap_file = zstrdup(argv[1]);
@ -301,6 +306,7 @@ void loadServerConfig(char *filename) {
sdsfree(line); sdsfree(line);
} }
if (fp != stdin) fclose(fp); if (fp != stdin) fclose(fp);
if (server.vm_enabled && !really_use_vm) goto vm_warning;
return; return;
loaderr: loaderr:
@ -309,6 +315,15 @@ loaderr:
fprintf(stderr, ">>> '%s'\n", line); fprintf(stderr, ">>> '%s'\n", line);
fprintf(stderr, "%s\n", err); fprintf(stderr, "%s\n", err);
exit(1); 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);
} }
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------