*
* 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);
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.
}
/* 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;
}
}