MCPcopy Create free account
hub / github.com/F-Stack/f-stack / replicationFeedMonitors

Function replicationFeedMonitors

app/redis-6.2.6/src/replication.c:379–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379void replicationFeedMonitors(client *c, list *monitors, int dictid, robj **argv, int argc) {
380 if (!(listLength(server.monitors) && !server.loading)) return;
381 listNode *ln;
382 listIter li;
383 int j;
384 sds cmdrepr = sdsnew("+");
385 robj *cmdobj;
386 struct timeval tv;
387
388 gettimeofday(&tv,NULL);
389 cmdrepr = sdscatprintf(cmdrepr,"%ld.%06ld ",(long)tv.tv_sec,(long)tv.tv_usec);
390 if (c->flags & CLIENT_LUA) {
391 cmdrepr = sdscatprintf(cmdrepr,"[%d lua] ",dictid);
392 } else if (c->flags & CLIENT_UNIX_SOCKET) {
393 cmdrepr = sdscatprintf(cmdrepr,"[%d unix:%s] ",dictid,server.unixsocket);
394 } else {
395 cmdrepr = sdscatprintf(cmdrepr,"[%d %s] ",dictid,getClientPeerId(c));
396 }
397
398 for (j = 0; j < argc; j++) {
399 if (argv[j]->encoding == OBJ_ENCODING_INT) {
400 cmdrepr = sdscatprintf(cmdrepr, "\"%ld\"", (long)argv[j]->ptr);
401 } else {
402 cmdrepr = sdscatrepr(cmdrepr,(char*)argv[j]->ptr,
403 sdslen(argv[j]->ptr));
404 }
405 if (j != argc-1)
406 cmdrepr = sdscatlen(cmdrepr," ",1);
407 }
408 cmdrepr = sdscatlen(cmdrepr,"\r\n",2);
409 cmdobj = createObject(OBJ_STRING,cmdrepr);
410
411 listRewind(monitors,&li);
412 while((ln = listNext(&li))) {
413 client *monitor = ln->value;
414 addReply(monitor,cmdobj);
415 }
416 decrRefCount(cmdobj);
417}
418
419/* Feed the slave 'c' with the replication backlog starting from the
420 * specified 'offset' up to the end of the backlog. */

Callers 4

evalCommandFunction · 0.85
evalShaCommandFunction · 0.85
execCommandAbortFunction · 0.85
callFunction · 0.85

Calls 11

sdsnewFunction · 0.85
sdscatprintfFunction · 0.85
getClientPeerIdFunction · 0.85
sdscatreprFunction · 0.85
sdslenFunction · 0.85
sdscatlenFunction · 0.85
createObjectFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
addReplyFunction · 0.85
decrRefCountFunction · 0.85

Tested by

no test coverage detected