Some refactroing using getClientType instead of CLIENT_SLAVE
This commit is contained in:
parent
f4c30fd74b
commit
084dc68128
@ -369,9 +369,10 @@ void addReplyErrorLength(client *c, const char *s, size_t len) {
|
|||||||
* Where the master must propagate the first change even if the second
|
* Where the master must propagate the first change even if the second
|
||||||
* will produce an error. However it is useful to log such events since
|
* will produce an error. However it is useful to log such events since
|
||||||
* they are rare and may hint at errors in a script or a bug in Redis. */
|
* they are rare and may hint at errors in a script or a bug in Redis. */
|
||||||
if (c->flags & (CLIENT_MASTER|CLIENT_SLAVE) && !(c->flags & CLIENT_MONITOR)) {
|
int ctype = getClientType(c);
|
||||||
char* to = c->flags & CLIENT_MASTER? "master": "replica";
|
if (ctype == CLIENT_TYPE_MASTER || ctype == CLIENT_TYPE_SLAVE) {
|
||||||
char* from = c->flags & CLIENT_MASTER? "replica": "master";
|
char* to = ctype == CLIENT_TYPE_MASTER? "master": "replica";
|
||||||
|
char* from = ctype == CLIENT_TYPE_MASTER? "replica": "master";
|
||||||
char *cmdname = c->lastcmd ? c->lastcmd->name : "<unknown>";
|
char *cmdname = c->lastcmd ? c->lastcmd->name : "<unknown>";
|
||||||
serverLog(LL_WARNING,"== CRITICAL == This %s is sending an error "
|
serverLog(LL_WARNING,"== CRITICAL == This %s is sending an error "
|
||||||
"to its %s: '%s' after processing the command "
|
"to its %s: '%s' after processing the command "
|
||||||
@ -1074,7 +1075,7 @@ void freeClient(client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Log link disconnection with slave */
|
/* Log link disconnection with slave */
|
||||||
if ((c->flags & CLIENT_SLAVE) && !(c->flags & CLIENT_MONITOR)) {
|
if (getClientType(c) == CLIENT_TYPE_SLAVE) {
|
||||||
serverLog(LL_WARNING,"Connection with replica %s lost.",
|
serverLog(LL_WARNING,"Connection with replica %s lost.",
|
||||||
replicationGetSlaveName(c));
|
replicationGetSlaveName(c));
|
||||||
}
|
}
|
||||||
|
35
src/object.c
35
src/object.c
@ -974,38 +974,29 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
|
|||||||
mh->repl_backlog = mem;
|
mh->repl_backlog = mem;
|
||||||
mem_total += mem;
|
mem_total += mem;
|
||||||
|
|
||||||
mem = 0;
|
|
||||||
if (listLength(server.slaves)) {
|
|
||||||
listIter li;
|
|
||||||
listNode *ln;
|
|
||||||
|
|
||||||
listRewind(server.slaves,&li);
|
|
||||||
while((ln = listNext(&li))) {
|
|
||||||
client *c = listNodeValue(ln);
|
|
||||||
mem += getClientOutputBufferMemoryUsage(c);
|
|
||||||
mem += sdsAllocSize(c->querybuf);
|
|
||||||
mem += sizeof(client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mh->clients_slaves = mem;
|
|
||||||
mem_total+=mem;
|
|
||||||
|
|
||||||
mem = 0;
|
mem = 0;
|
||||||
if (listLength(server.clients)) {
|
if (listLength(server.clients)) {
|
||||||
listIter li;
|
listIter li;
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
|
size_t mem_normal = 0, mem_slaves = 0;
|
||||||
|
|
||||||
listRewind(server.clients,&li);
|
listRewind(server.clients,&li);
|
||||||
while((ln = listNext(&li))) {
|
while((ln = listNext(&li))) {
|
||||||
|
size_t mem_curr = 0;
|
||||||
client *c = listNodeValue(ln);
|
client *c = listNodeValue(ln);
|
||||||
if (c->flags & CLIENT_SLAVE && !(c->flags & CLIENT_MONITOR))
|
int type = getClientType(c);
|
||||||
continue;
|
mem_curr += getClientOutputBufferMemoryUsage(c);
|
||||||
mem += getClientOutputBufferMemoryUsage(c);
|
mem_curr += sdsAllocSize(c->querybuf);
|
||||||
mem += sdsAllocSize(c->querybuf);
|
mem_curr += sizeof(client);
|
||||||
mem += sizeof(client);
|
if (type == CLIENT_TYPE_SLAVE)
|
||||||
|
mem_slaves += mem_curr;
|
||||||
|
else
|
||||||
|
mem_normal += mem_curr;
|
||||||
}
|
}
|
||||||
|
mh->clients_slaves = mem_slaves;
|
||||||
|
mh->clients_normal = mem_normal;
|
||||||
|
mem = mem_slaves + mem_normal;
|
||||||
}
|
}
|
||||||
mh->clients_normal = mem;
|
|
||||||
mem_total+=mem;
|
mem_total+=mem;
|
||||||
|
|
||||||
mem = 0;
|
mem = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user