addReplyBulkCBuffer(c,buf,len);
}
+/* Copy 'src' client output buffers into 'dst' client output buffers.
+ * The function takes care of freeing the old output buffers of the
+ * destination client. */
+void copyClientOutputBuffer(redisClient *dst, redisClient *src) {
+ listRelease(dst->reply);
+ dst->reply = listDup(src->reply);
+ memcpy(dst->buf,src->buf,src->bufpos);
+ dst->bufpos = src->bufpos;
+}
+
static void acceptCommonHandler(int fd) {
redisClient *c;
if ((c = createClient(fd)) == NULL) {
/* Case 2: we lost the connection with the master. */
if (c->flags & REDIS_MASTER) {
server.master = NULL;
- server.replstate = REDIS_REPL_CONNECT;
+ server.repl_state = REDIS_REPL_CONNECT;
server.repl_down_since = time(NULL);
/* Since we lost the connection with the master, we should also
* close the connection with all our slaves if we have any, so
/* 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;
}
listRewind(server.clients,&li);
while ((ln = listNext(&li)) != NULL) {
+ sds cs;
+
client = listNodeValue(ln);
- o = sdscatsds(o,getClientInfoString(client));
+ cs = getClientInfoString(client);
+ o = sdscatsds(o,cs);
+ sdsfree(cs);
o = sdscatlen(o,"\n",1);
}
return o;