X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/51669c5ac11b250fcdc91382f52f515a11835a20..b80b1c5914435c3a013cfe9b19e39f9de35ab06e:/src/networking.c diff --git a/src/networking.c b/src/networking.c index b8f33865..3938f3f6 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1203,7 +1203,7 @@ void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) { * * Note: this function is very fast so can be called as many time as * the caller wishes. The main usage of this function currently is - * enforcing the client output lenght limits. */ + * enforcing the client output length limits. */ unsigned long getClientOutputBufferMemoryUsage(redisClient *c) { unsigned long list_item_size = sizeof(listNode); @@ -1225,6 +1225,22 @@ int getClientLimitClass(redisClient *c) { return REDIS_CLIENT_LIMIT_CLASS_NORMAL; } +int getClientLimitClassByName(char *name) { + if (!strcasecmp(name,"normal")) return REDIS_CLIENT_LIMIT_CLASS_NORMAL; + else if (!strcasecmp(name,"slave")) return REDIS_CLIENT_LIMIT_CLASS_SLAVE; + else if (!strcasecmp(name,"pubsub")) return REDIS_CLIENT_LIMIT_CLASS_PUBSUB; + else return -1; +} + +char *getClientLimitClassName(int class) { + switch(class) { + case REDIS_CLIENT_LIMIT_CLASS_NORMAL: return "normal"; + case REDIS_CLIENT_LIMIT_CLASS_SLAVE: return "slave"; + case REDIS_CLIENT_LIMIT_CLASS_PUBSUB: return "pubsub"; + default: return NULL; + } +} + /* The function checks if the client reached output buffer soft or hard * limit, and also update the state needed to check the soft limit as * a side effect. @@ -1266,21 +1282,19 @@ int checkClientOutputBufferLimits(redisClient *c) { } /* Asynchronously close a client if soft or hard limit is reached on the - * output buffer size. If the client will be closed 1 is returend, otherwise 0 - * is returned. + * output buffer size. The caller can check if the client will be closed + * checking if the client REDIS_CLOSE_ASAP flag is set. * * Note: we need to close the client asynchronously because this function is * called from contexts where the client can't be freed safely, i.e. from the * lower level functions pushing data inside the client output buffers. */ -int asyncCloseClientOnOutputBufferLimitReached(redisClient *c) { +void asyncCloseClientOnOutputBufferLimitReached(redisClient *c) { + if (c->flags & REDIS_CLOSE_ASAP) return; if (checkClientOutputBufferLimits(c)) { sds client = getClientInfoString(c); freeClientAsync(c); - redisLog(REDIS_NOTICE,"Client %s scheduled to be closed ASAP for overcoming of output buffer limits."); + redisLog(REDIS_WARNING,"Client %s scheduled to be closed ASAP for overcoming of output buffer limits.", client); sdsfree(client); - return 1; - } else { - return 0; } }