/*================================= Globals ================================= */
-/* Alternate stack for SIGSEGV/etc handlers */
-char altstack[SIGSTKSZ];
-
/* Global vars */
struct redisServer server; /* server global state */
struct redisCommand *commandTable;
* keys that can be removed from the keyspace. */
void activeExpireCycle(void) {
int j;
+ long long start = mstime();
for (j = 0; j < server.dbnum; j++) {
- int expired;
+ int expired, iteration = 0;
redisDb *db = server.db+j;
/* Continue to expire if at the end of the cycle more than 25%
server.stat_expiredkeys++;
}
}
+ /* We can't block forever here even if there are many keys to
+ * expire. So after a given amount of milliseconds return to the
+ * caller waiting for the other active expire cycle. */
+ iteration++;
+ if ((iteration & 0xff) == 0 && /* Check once every 255 iterations */
+ (mstime()-start) > REDIS_EXPIRELOOKUPS_TIME_LIMIT) return;
} while (expired > REDIS_EXPIRELOOKUPS_PER_CRON/4);
}
}
"-LOADING Redis is loading the dataset in memory\r\n"));
shared.slowscripterr = createObject(REDIS_STRING,sdsnew(
"-BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.\r\n"));
+ shared.masterdownerr = createObject(REDIS_STRING,sdsnew(
+ "-MASTERDOWN Link with MASTER is down and slave-serve-stale-data is set to 'no'.\r\n"));
shared.bgsaveerr = createObject(REDIS_STRING,sdsnew(
"-MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.\r\n"));
shared.roslaveerr = createObject(REDIS_STRING,sdsnew(
server.repl_serve_stale_data == 0 &&
c->cmd->proc != infoCommand && c->cmd->proc != slaveofCommand)
{
- addReplyError(c,
- "link with MASTER is down and slave-serve-stale-data is set to no");
+ addReply(c, shared.masterdownerr);
return REDIS_OK;
}
/* Lua script too slow? Only allow SHUTDOWN NOSAVE and SCRIPT KILL. */
if (server.lua_timedout &&
- !(c->cmd->proc != shutdownCommand &&
+ !(c->cmd->proc == shutdownCommand &&
c->argc == 2 &&
tolower(((char*)c->argv[1]->ptr)[0]) == 'n') &&
!(c->cmd->proc == scriptCommand &&
void setupSignalHandlers(void) {
struct sigaction act;
- stack_t stack;
-
- stack.ss_sp = altstack;
- stack.ss_flags = 0;
- stack.ss_size = SIGSTKSZ;
-
- sigaltstack(&stack, NULL);
/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction is used.
* Otherwise, sa_handler is used. */
sigaction(SIGTERM, &act, NULL);
#ifdef HAVE_BACKTRACE
- /* Use alternate stack so we don't clobber stack in case of segv, or when we run out of stack ..
- * also resethand & nodefer so we can get interrupted (and killed) if we cause SEGV during SEGV handler */
sigemptyset(&act.sa_mask);
- act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
+ act.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
act.sa_sigaction = sigsegvHandler;
sigaction(SIGSEGV, &act, NULL);
sigaction(SIGBUS, &act, NULL);