Skip to content

Commit

Permalink
Merge branch 'unstable' into RELEASE_0_9
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSully committed Jul 17, 2019
2 parents 0483047 + c8516f3 commit a220be1
Showing 1 changed file with 84 additions and 72 deletions.
156 changes: 84 additions & 72 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2184,99 +2184,99 @@ void afterSleep(struct aeEventLoop *eventLoop) {
void createSharedObjects(void) {
int j;

shared.crlf = createObject(OBJ_STRING,sdsnew("\r\n"));
shared.ok = createObject(OBJ_STRING,sdsnew("+OK\r\n"));
shared.err = createObject(OBJ_STRING,sdsnew("-ERR\r\n"));
shared.emptybulk = createObject(OBJ_STRING,sdsnew("$0\r\n\r\n"));
shared.emptymultibulk = createObject(OBJ_STRING,sdsnew("*0\r\n"));
shared.nullbulk = createObject(OBJ_STRING,sdsnew("$0\r\n\r\n"));
shared.czero = createObject(OBJ_STRING,sdsnew(":0\r\n"));
shared.cone = createObject(OBJ_STRING,sdsnew(":1\r\n"));
shared.emptyarray = createObject(OBJ_STRING,sdsnew("*0\r\n"));
shared.pong = createObject(OBJ_STRING,sdsnew("+PONG\r\n"));
shared.queued = createObject(OBJ_STRING,sdsnew("+QUEUED\r\n"));
shared.emptyscan = createObject(OBJ_STRING,sdsnew("*2\r\n$1\r\n0\r\n*0\r\n"));
shared.wrongtypeerr = createObject(OBJ_STRING,sdsnew(
"-WRONGTYPE Operation against a key holding the wrong kind of value\r\n"));
shared.nokeyerr = createObject(OBJ_STRING,sdsnew(
"-ERR no such key\r\n"));
shared.syntaxerr = createObject(OBJ_STRING,sdsnew(
"-ERR syntax error\r\n"));
shared.sameobjecterr = createObject(OBJ_STRING,sdsnew(
"-ERR source and destination objects are the same\r\n"));
shared.outofrangeerr = createObject(OBJ_STRING,sdsnew(
"-ERR index out of range\r\n"));
shared.noscripterr = createObject(OBJ_STRING,sdsnew(
"-NOSCRIPT No matching script. Please use EVAL.\r\n"));
shared.loadingerr = createObject(OBJ_STRING,sdsnew(
"-LOADING Redis is loading the dataset in memory\r\n"));
shared.slowscripterr = createObject(OBJ_STRING,sdsnew(
"-BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.\r\n"));
shared.masterdownerr = createObject(OBJ_STRING,sdsnew(
"-MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'.\r\n"));
shared.bgsaveerr = createObject(OBJ_STRING,sdsnew(
"-MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.\r\n"));
shared.roslaveerr = createObject(OBJ_STRING,sdsnew(
"-READONLY You can't write against a read only replica.\r\n"));
shared.noautherr = createObject(OBJ_STRING,sdsnew(
"-NOAUTH Authentication required.\r\n"));
shared.oomerr = createObject(OBJ_STRING,sdsnew(
"-OOM command not allowed when used memory > 'maxmemory'.\r\n"));
shared.execaborterr = createObject(OBJ_STRING,sdsnew(
"-EXECABORT Transaction discarded because of previous errors.\r\n"));
shared.noreplicaserr = createObject(OBJ_STRING,sdsnew(
"-NOREPLICAS Not enough good replicas to write.\r\n"));
shared.busykeyerr = createObject(OBJ_STRING,sdsnew(
"-BUSYKEY Target key name already exists.\r\n"));
shared.space = createObject(OBJ_STRING,sdsnew(" "));
shared.colon = createObject(OBJ_STRING,sdsnew(":"));
shared.plus = createObject(OBJ_STRING,sdsnew("+"));
shared.crlf = makeObjectShared(createObject(OBJ_STRING,sdsnew("\r\n")));
shared.ok = makeObjectShared(createObject(OBJ_STRING,sdsnew("+OK\r\n")));
shared.err = makeObjectShared(createObject(OBJ_STRING,sdsnew("-ERR\r\n")));
shared.emptybulk = makeObjectShared(createObject(OBJ_STRING,sdsnew("$0\r\n\r\n")));
shared.emptymultibulk = makeObjectShared(createObject(OBJ_STRING,sdsnew("*0\r\n")));
shared.nullbulk = makeObjectShared(createObject(OBJ_STRING,sdsnew("$0\r\n\r\n")));
shared.czero = makeObjectShared(createObject(OBJ_STRING,sdsnew(":0\r\n")));
shared.cone = makeObjectShared(createObject(OBJ_STRING,sdsnew(":1\r\n")));
shared.emptyarray = makeObjectShared(createObject(OBJ_STRING,sdsnew("*0\r\n")));
shared.pong = makeObjectShared(createObject(OBJ_STRING,sdsnew("+PONG\r\n")));
shared.queued = makeObjectShared(createObject(OBJ_STRING,sdsnew("+QUEUED\r\n")));
shared.emptyscan = makeObjectShared(createObject(OBJ_STRING,sdsnew("*2\r\n$1\r\n0\r\n*0\r\n")));
shared.wrongtypeerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-WRONGTYPE Operation against a key holding the wrong kind of value\r\n")));
shared.nokeyerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-ERR no such key\r\n")));
shared.syntaxerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-ERR syntax error\r\n")));
shared.sameobjecterr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-ERR source and destination objects are the same\r\n")));
shared.outofrangeerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-ERR index out of range\r\n")));
shared.noscripterr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-NOSCRIPT No matching script. Please use EVAL.\r\n")));
shared.loadingerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-LOADING Redis is loading the dataset in memory\r\n")));
shared.slowscripterr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.\r\n")));
shared.masterdownerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'.\r\n")));
shared.bgsaveerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.\r\n")));
shared.roslaveerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-READONLY You can't write against a read only replica.\r\n")));
shared.noautherr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-NOAUTH Authentication required.\r\n")));
shared.oomerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-OOM command not allowed when used memory > 'maxmemory'.\r\n")));
shared.execaborterr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-EXECABORT Transaction discarded because of previous errors.\r\n")));
shared.noreplicaserr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-NOREPLICAS Not enough good replicas to write.\r\n")));
shared.busykeyerr = makeObjectShared(createObject(OBJ_STRING,sdsnew(
"-BUSYKEY Target key name already exists.\r\n")));
shared.space = makeObjectShared(createObject(OBJ_STRING,sdsnew(" ")));
shared.colon = makeObjectShared(createObject(OBJ_STRING,sdsnew(":")));
shared.plus = makeObjectShared(createObject(OBJ_STRING,sdsnew("+")));

/* The shared NULL depends on the protocol version. */
shared.null[0] = NULL;
shared.null[1] = NULL;
shared.null[2] = createObject(OBJ_STRING,sdsnew("$-1\r\n"));
shared.null[3] = createObject(OBJ_STRING,sdsnew("_\r\n"));
shared.null[2] = makeObjectShared(createObject(OBJ_STRING,sdsnew("$-1\r\n")));
shared.null[3] = makeObjectShared(createObject(OBJ_STRING,sdsnew("_\r\n")));

shared.nullarray[0] = NULL;
shared.nullarray[1] = NULL;
shared.nullarray[2] = createObject(OBJ_STRING,sdsnew("*-1\r\n"));
shared.nullarray[3] = createObject(OBJ_STRING,sdsnew("_\r\n"));
shared.nullarray[2] = makeObjectShared(createObject(OBJ_STRING,sdsnew("*-1\r\n")));
shared.nullarray[3] = makeObjectShared(createObject(OBJ_STRING,sdsnew("_\r\n")));

for (j = 0; j < PROTO_SHARED_SELECT_CMDS; j++) {
char dictid_str[64];
int dictid_len;

dictid_len = ll2string(dictid_str,sizeof(dictid_str),j);
shared.select[j] = createObject(OBJ_STRING,
shared.select[j] = makeObjectShared(createObject(OBJ_STRING,
sdscatprintf(sdsempty(),
"*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n",
dictid_len, dictid_str));
}
shared.messagebulk = createStringObject("$7\r\nmessage\r\n",13);
shared.pmessagebulk = createStringObject("$8\r\npmessage\r\n",14);
shared.subscribebulk = createStringObject("$9\r\nsubscribe\r\n",15);
shared.unsubscribebulk = createStringObject("$11\r\nunsubscribe\r\n",18);
shared.psubscribebulk = createStringObject("$10\r\npsubscribe\r\n",17);
shared.punsubscribebulk = createStringObject("$12\r\npunsubscribe\r\n",19);
shared.del = createStringObject("DEL",3);
shared.unlink = createStringObject("UNLINK",6);
shared.rpop = createStringObject("RPOP",4);
shared.lpop = createStringObject("LPOP",4);
shared.lpush = createStringObject("LPUSH",5);
shared.rpoplpush = createStringObject("RPOPLPUSH",9);
shared.zpopmin = createStringObject("ZPOPMIN",7);
shared.zpopmax = createStringObject("ZPOPMAX",7);
dictid_len, dictid_str)));
}
shared.messagebulk = makeObjectShared(createStringObject("$7\r\nmessage\r\n",13));
shared.pmessagebulk = makeObjectShared(createStringObject("$8\r\npmessage\r\n",14));
shared.subscribebulk = makeObjectShared(createStringObject("$9\r\nsubscribe\r\n",15));
shared.unsubscribebulk = makeObjectShared(createStringObject("$11\r\nunsubscribe\r\n",18));
shared.psubscribebulk = makeObjectShared(createStringObject("$10\r\npsubscribe\r\n",17));
shared.punsubscribebulk = makeObjectShared(createStringObject("$12\r\npunsubscribe\r\n",19));
shared.del = makeObjectShared(createStringObject("DEL",3));
shared.unlink = makeObjectShared(createStringObject("UNLINK",6));
shared.rpop = makeObjectShared(createStringObject("RPOP",4));
shared.lpop = makeObjectShared(createStringObject("LPOP",4));
shared.lpush = makeObjectShared(createStringObject("LPUSH",5));
shared.rpoplpush = makeObjectShared(createStringObject("RPOPLPUSH",9));
shared.zpopmin = makeObjectShared(createStringObject("ZPOPMIN",7));
shared.zpopmax = makeObjectShared(createStringObject("ZPOPMAX",7));
for (j = 0; j < OBJ_SHARED_INTEGERS; j++) {
shared.integers[j] =
makeObjectShared(createObject(OBJ_STRING,(void*)(long)j));
shared.integers[j]->encoding = OBJ_ENCODING_INT;
}
for (j = 0; j < OBJ_SHARED_BULKHDR_LEN; j++) {
shared.mbulkhdr[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"*%d\r\n",j));
shared.bulkhdr[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"$%d\r\n",j));
shared.mbulkhdr[j] = makeObjectShared(createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"*%d\r\n",j)));
shared.bulkhdr[j] = makeObjectShared(createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"$%d\r\n",j)));
}
/* The following two shared objects, minstring and maxstrings, are not
* actually used for their value but as a special object meaning
Expand Down Expand Up @@ -2934,6 +2934,18 @@ void initServer(void) {
g_pserver->db[j].defrag_later = listCreate();
}

/* Fixup Master Client Database */
listIter li;
listNode *ln;
listRewind(g_pserver->masters, &li);
while ((ln = listNext(&li)))
{
redisMaster *mi = (redisMaster*)listNodeValue(ln);
serverAssert(mi->master == nullptr);
if (mi->cached_master != nullptr)
selectDb(mi->cached_master, 0);
}

if (g_pserver->syslog_enabled) {
openlog(g_pserver->syslog_ident, LOG_PID | LOG_NDELAY | LOG_NOWAIT,
g_pserver->syslog_facility);
Expand Down

0 comments on commit a220be1

Please sign in to comment.