]> git.saurik.com Git - redis.git/blobdiff - src/redis.c
Lua scripts max execution time
[redis.git] / src / redis.c
index 96786df95667b1d40a5083158ccd6a03dfd18cb9..72477356f3e0c57bbd7e230601aea777b898e055 100644 (file)
@@ -193,7 +193,8 @@ struct redisCommand redisCommandTable[] = {
     {"migrate",migrateCommand,6,0,NULL,0,0,0,0,0},
     {"dump",dumpCommand,2,0,NULL,0,0,0,0,0},
     {"object",objectCommand,-2,0,NULL,0,0,0,0,0},
-    {"client",clientCommand,-2,0,NULL,0,0,0,0,0}
+    {"client",clientCommand,-2,0,NULL,0,0,0,0,0},
+    {"eval",evalCommand,-3,REDIS_CMD_DENYOOM,zunionInterGetKeys,0,0,0,0,0}
 };
 
 /*============================ Utility functions ============================ */
@@ -857,6 +858,7 @@ void initServerConfig() {
     server.cache_flush_delay = 0;
     server.cluster_enabled = 0;
     server.cluster.configfile = zstrdup("nodes.conf");
+    server.lua_time_limit = REDIS_LUA_TIME_LIMIT;
 
     updateLRUClock();
     resetServerSaveParams();
@@ -981,6 +983,7 @@ void initServer() {
 
     if (server.ds_enabled) dsInit();
     if (server.cluster_enabled) clusterInit();
+    scriptingInit();
     srand(time(NULL)^getpid());
 }
 
@@ -1096,13 +1099,15 @@ int processCommand(redisClient *c) {
             addReplyError(c,"The cluster is down. Check with CLUSTER INFO for more information");
             return REDIS_OK;
         } else {
-            clusterNode *n = getNodeByQuery(c,cmd,c->argv,c->argc,&hashslot);
+            int ask;
+            clusterNode *n = getNodeByQuery(c,cmd,c->argv,c->argc,&hashslot,&ask);
             if (n == NULL) {
-                addReplyError(c,"Invalid cross-node request");
+                addReplyError(c,"Multi keys request invalid in cluster");
                 return REDIS_OK;
             } else if (n != server.cluster.myself) {
                 addReplySds(c,sdscatprintf(sdsempty(),
-                    "-MOVED %d %s:%d\r\n",hashslot,n->ip,n->port));
+                    "-%s %d %s:%d\r\n", ask ? "ASK" : "MOVED",
+                    hashslot,n->ip,n->port));
                 return REDIS_OK;
             }
         }
@@ -1316,19 +1321,17 @@ sds genRedisInfoString(char *section) {
             "used_memory_rss:%zu\r\n"
             "used_memory_peak:%zu\r\n"
             "used_memory_peak_human:%s\r\n"
+            "used_memory_lua:%lld\r\n"
             "mem_fragmentation_ratio:%.2f\r\n"
-            "use_tcmalloc:%d\r\n",
+            "mem_allocator:%s\r\n",
             zmalloc_used_memory(),
             hmem,
             zmalloc_get_rss(),
             server.stat_peak_memory,
             peak_hmem,
+            ((long long)lua_gc(server.lua,LUA_GCCOUNT,0))*1024LL,
             zmalloc_get_fragmentation_ratio(),
-    #ifdef USE_TCMALLOC
-            1
-    #else
-            0
-    #endif
+            REDIS_MALLOC
             );
     }