mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Close client connection and log the event when the client input buffer reaches 1GB.
This commit is contained in:
parent
6621b8ffa1
commit
becf5fdb0c
@ -903,6 +903,13 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
} else {
|
} else {
|
||||||
return;
|
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);
|
processInputBuffer(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,6 +843,7 @@ void initServerConfig() {
|
|||||||
server.dbnum = REDIS_DEFAULT_DBNUM;
|
server.dbnum = REDIS_DEFAULT_DBNUM;
|
||||||
server.verbosity = REDIS_VERBOSE;
|
server.verbosity = REDIS_VERBOSE;
|
||||||
server.maxidletime = REDIS_MAXIDLETIME;
|
server.maxidletime = REDIS_MAXIDLETIME;
|
||||||
|
server.client_max_querybuf_len = REDIS_MAX_QUERYBUF_LEN;
|
||||||
server.saveparams = NULL;
|
server.saveparams = NULL;
|
||||||
server.loading = 0;
|
server.loading = 0;
|
||||||
server.logfile = NULL; /* NULL = log on standard output */
|
server.logfile = NULL; /* NULL = log on standard output */
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
/* Static server configuration */
|
/* Static server configuration */
|
||||||
#define REDIS_SERVERPORT 6379 /* TCP port */
|
#define REDIS_SERVERPORT 6379 /* TCP port */
|
||||||
#define REDIS_MAXIDLETIME 0 /* default client timeout: infinite */
|
#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_IOBUF_LEN (1024*16)
|
||||||
#define REDIS_LOADBUF_LEN 1024
|
#define REDIS_LOADBUF_LEN 1024
|
||||||
#define REDIS_DEFAULT_DBNUM 16
|
#define REDIS_DEFAULT_DBNUM 16
|
||||||
@ -533,6 +534,7 @@ struct redisServer {
|
|||||||
/* Configuration */
|
/* Configuration */
|
||||||
int verbosity;
|
int verbosity;
|
||||||
int maxidletime;
|
int maxidletime;
|
||||||
|
size_t client_max_querybuf_len;
|
||||||
int dbnum;
|
int dbnum;
|
||||||
int daemonize;
|
int daemonize;
|
||||||
int appendonly;
|
int appendonly;
|
||||||
@ -765,6 +767,7 @@ void addReplyMultiBulkLen(redisClient *c, long length);
|
|||||||
void *dupClientReplyValue(void *o);
|
void *dupClientReplyValue(void *o);
|
||||||
void getClientsMaxBuffers(unsigned long *longest_output_list,
|
void getClientsMaxBuffers(unsigned long *longest_output_list,
|
||||||
unsigned long *biggest_input_buffer);
|
unsigned long *biggest_input_buffer);
|
||||||
|
sds getClientInfoString(redisClient *client);
|
||||||
void rewriteClientCommandVector(redisClient *c, int argc, ...);
|
void rewriteClientCommandVector(redisClient *c, int argc, ...);
|
||||||
void rewriteClientCommandArgument(redisClient *c, int i, robj *newval);
|
void rewriteClientCommandArgument(redisClient *c, int i, robj *newval);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user