/* Helper function. Trims query buffer to make the function that processes
* multi bulk requests idempotent. */
static void setProtocolError(redisClient *c, int pos) {
+ if (server.verbosity >= REDIS_VERBOSE) {
+ sds client = getClientInfoString(c);
+ redisLog(REDIS_VERBOSE,
+ "Protocol error from client: %s", client);
+ sdsfree(client);
+ }
c->flags |= REDIS_CLOSE_AFTER_REPLY;
c->querybuf = sdsrange(c->querybuf,pos,-1);
}
return;
}
if (sdslen(c->querybuf) > server.client_max_querybuf_len) {
- sds ci = getClientInfoString(c);
- redisLog(REDIS_WARNING,"Closing client that reached max query buffer length: %s", ci);
+ sds ci = getClientInfoString(c), bytes = sdsempty();
+
+ bytes = sdscatrepr(bytes,c->querybuf,64);
+ redisLog(REDIS_WARNING,"Closing client that reached max query buffer length: %s (qbuf initial bytes: %s)", ci, bytes);
sdsfree(ci);
+ sdsfree(bytes);
freeClient(c);
return;
}
client->lastcmd ? client->lastcmd->name : "NULL");
}
+sds getAllClientsInfoString(void) {
+ listNode *ln;
+ listIter li;
+ redisClient *client;
+ sds o = sdsempty();
+
+ listRewind(server.clients,&li);
+ while ((ln = listNext(&li)) != NULL) {
+ sds cs;
+
+ client = listNodeValue(ln);
+ cs = getClientInfoString(client);
+ o = sdscatsds(o,cs);
+ sdsfree(cs);
+ o = sdscatlen(o,"\n",1);
+ }
+ return o;
+}
+
void clientCommand(redisClient *c) {
listNode *ln;
listIter li;
redisClient *client;
if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
- sds o = sdsempty();
-
- listRewind(server.clients,&li);
- while ((ln = listNext(&li)) != NULL) {
- client = listNodeValue(ln);
- o = sdscatsds(o,getClientInfoString(client));
- o = sdscatlen(o,"\n",1);
- }
+ sds o = getAllClientsInfoString();
addReplyBulkCBuffer(c,o,sdslen(o));
sdsfree(o);
} else if (!strcasecmp(c->argv[1]->ptr,"kill") && c->argc == 3) {