| 377 | } |
| 378 | |
| 379 | void 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. */ |
no test coverage detected