X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/498dc5557c31fc9a65a36f2e8da9accfa72fbc5a..d876678b5eb0db0df66a658faeb8fb71e236a634:/src/redis.h diff --git a/src/redis.h b/src/redis.h index 42ade8fc..66a51c83 100644 --- a/src/redis.h +++ b/src/redis.h @@ -20,6 +20,7 @@ #include #include #include +#include #include "ae.h" /* Event driven programming library */ #include "sds.h" /* Dynamic safe strings */ @@ -76,6 +77,7 @@ #define REDIS_CMD_PUBSUB 32 /* "p" flag */ #define REDIS_CMD_NOSCRIPT 64 /* "s" flag */ #define REDIS_CMD_RANDOM 128 /* "R" flag */ +#define REDIS_CMD_SORT_FOR_SCRIPT 256 /* "S" flag */ /* Object types */ #define REDIS_STRING 0 @@ -141,6 +143,7 @@ server.unblocked_clients */ #define REDIS_LUA_CLIENT 512 /* This is a non connected client used by Lua */ #define REDIS_ASKING 1024 /* Client issued the ASKING command */ +#define REDIS_CLOSE_ASAP 2048 /* Close this client ASAP */ /* Client request types */ #define REDIS_REQ_INLINE 1 @@ -151,6 +154,7 @@ #define REDIS_CLIENT_LIMIT_CLASS_NORMAL 0 #define REDIS_CLIENT_LIMIT_CLASS_SLAVE 1 #define REDIS_CLIENT_LIMIT_CLASS_PUBSUB 2 +#define REDIS_CLIENT_LIMIT_NUM_CLASSES 3 /* Slave replication state - slave side */ #define REDIS_REPL_NONE 0 /* No active replication */ @@ -314,6 +318,7 @@ typedef struct redisClient { unsigned long reply_bytes; /* Tot bytes of objects in reply list */ int sentlen; time_t lastinteraction; /* time of the last interaction, used for timeout */ + time_t obuf_soft_limit_reached_time; int flags; /* REDIS_SLAVE | REDIS_MONITOR | REDIS_MULTI ... */ int slaveseldb; /* slave selected db, if this client is a slave */ int authenticated; /* when requirepass is non-NULL */ @@ -373,6 +378,12 @@ typedef struct zset { zskiplist *zsl; } zset; +typedef struct clientBufferLimitsConfig { + unsigned long long hard_limit_bytes; + unsigned long long soft_limit_bytes; + time_t soft_limit_seconds; +} clientBufferLimitsConfig; + /*----------------------------------------------------------------------------- * Redis cluster data structures *----------------------------------------------------------------------------*/ @@ -516,6 +527,7 @@ struct redisServer { int activerehashing; /* Incremental rehash in serverCron() */ char *requirepass; /* Pass for AUTH command, or NULL */ char *pidfile; /* PID file path */ + int arch_bits; /* 32 or 64 depending on sizeof(long) */ /* Networking */ int port; /* TCP listening port */ char *bindaddr; /* Bind address or NULL */ @@ -525,6 +537,7 @@ struct redisServer { int sofd; /* Unix socket file descriptor */ int cfd; /* Cluster bus lisetning socket */ list *clients; /* List of active clients */ + list *clients_to_close; /* Clients to close asynchronously */ list *slaves, *monitors; /* List of slaves and MONITORs */ redisClient *current_client; /* Current client, only used on crash report */ char neterr[ANET_ERR_LEN]; /* Error buffer for anet.c */ @@ -558,6 +571,7 @@ struct redisServer { size_t client_max_querybuf_len; /* Limit for client query buffer length */ int dbnum; /* Total number of configured DBs */ int daemonize; /* True if running as a daemon */ + clientBufferLimitsConfig client_obuf_limits[REDIS_CLIENT_LIMIT_NUM_CLASSES]; /* AOF persistence */ int aof_state; /* REDIS_AOF_(ON|OFF|WAIT_REWRITE) */ int aof_fsync; /* Kind of fsync() policy */ @@ -614,6 +628,7 @@ struct redisServer { list *unblocked_clients; /* list of clients to unblock before next loop */ /* Sort parameters - qsort_r() is only available under BSD so we * have to take this state global, in order to pass it to sortCompare() */ + int sort_dontsort; int sort_desc; int sort_alpha; int sort_bypattern; @@ -791,6 +806,10 @@ sds getAllClientsInfoString(void); void rewriteClientCommandVector(redisClient *c, int argc, ...); void rewriteClientCommandArgument(redisClient *c, int i, robj *newval); unsigned long getClientOutputBufferMemoryUsage(redisClient *c); +void freeClientsInAsyncFreeQueue(void); +void asyncCloseClientOnOutputBufferLimitReached(redisClient *c); +int getClientLimitClassByName(char *name); +char *getClientLimitClassName(int class); #ifdef __GNUC__ void addReplyErrorFormat(redisClient *c, const char *fmt, ...) @@ -807,7 +826,7 @@ void listTypeTryConversion(robj *subject, robj *value); void listTypePush(robj *subject, robj *value, int where); robj *listTypePop(robj *subject, int where); unsigned long listTypeLength(robj *subject); -listTypeIterator *listTypeInitIterator(robj *subject, int index, unsigned char direction); +listTypeIterator *listTypeInitIterator(robj *subject, long index, unsigned char direction); void listTypeReleaseIterator(listTypeIterator *li); int listTypeNext(listTypeIterator *li, listTypeEntry *entry); robj *listTypeGet(listTypeEntry *entry); @@ -1169,5 +1188,6 @@ void _redisAssert(char *estr, char *file, int line); void _redisPanic(char *msg, char *file, int line); void bugReportStart(void); void redisLogObjectDebugInfo(robj *o); - +void sigsegvHandler(int sig, siginfo_t *info, void *secret); +sds genRedisInfoString(char *section); #endif