提交 becf5fdb 编写于 作者: A antirez

Close client connection and log the event when the client input buffer reaches 1GB.

上级 6621b8ff
......@@ -903,6 +903,13 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
} else {
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);
sdsfree(ci);
freeClient(c);
return;
}
processInputBuffer(c);
}
......
......@@ -843,6 +843,7 @@ void initServerConfig() {
server.dbnum = REDIS_DEFAULT_DBNUM;
server.verbosity = REDIS_VERBOSE;
server.maxidletime = REDIS_MAXIDLETIME;
server.client_max_querybuf_len = REDIS_MAX_QUERYBUF_LEN;
server.saveparams = NULL;
server.loading = 0;
server.logfile = NULL; /* NULL = log on standard output */
......
......@@ -40,6 +40,7 @@
/* Static server configuration */
#define REDIS_SERVERPORT 6379 /* TCP port */
#define REDIS_MAXIDLETIME 0 /* default client timeout: infinite */
#define REDIS_MAX_QUERYBUF_LEN (1024*1024*1024) /* 1GB max query buffer. */
#define REDIS_IOBUF_LEN (1024*16)
#define REDIS_LOADBUF_LEN 1024
#define REDIS_DEFAULT_DBNUM 16
......@@ -533,6 +534,7 @@ struct redisServer {
/* Configuration */
int verbosity;
int maxidletime;
size_t client_max_querybuf_len;
int dbnum;
int daemonize;
int appendonly;
......@@ -765,6 +767,7 @@ void addReplyMultiBulkLen(redisClient *c, long length);
void *dupClientReplyValue(void *o);
void getClientsMaxBuffers(unsigned long *longest_output_list,
unsigned long *biggest_input_buffer);
sds getClientInfoString(redisClient *client);
void rewriteClientCommandVector(redisClient *c, int argc, ...);
void rewriteClientCommandArgument(redisClient *c, int i, robj *newval);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册