mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 17:40:50 +00:00
Initialize all Lua scripting related things into scripting.c
This commit is contained in:
parent
9aa1f94449
commit
cd8f19e9ca
@ -790,12 +790,26 @@ void scriptingEnableGlobalsProtection(lua_State *lua) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the scripting environment.
|
/* Initialize the scripting environment.
|
||||||
* It is possible to call this function to reset the scripting environment
|
*
|
||||||
* assuming that we call scriptingRelease() before.
|
* This function is called the first time at server startup with
|
||||||
* See scriptingReset() for more information. */
|
* the 'setup' argument set to 1.
|
||||||
void scriptingInit(void) {
|
*
|
||||||
|
* It can be called again multiple times during the lifetime of the Redis
|
||||||
|
* process, with 'setup' set to 0, and following a scriptingRelease() call,
|
||||||
|
* in order to reset the Lua scripting environment.
|
||||||
|
*
|
||||||
|
* However it is simpler to just call scriptingReset() that does just that. */
|
||||||
|
void scriptingInit(int setup) {
|
||||||
lua_State *lua = lua_open();
|
lua_State *lua = lua_open();
|
||||||
|
|
||||||
|
if (setup) {
|
||||||
|
server.lua_client = NULL;
|
||||||
|
server.lua_caller = NULL;
|
||||||
|
server.lua_timedout = 0;
|
||||||
|
server.lua_always_replicate_commands = 0; /* Only DEBUG can change it.*/
|
||||||
|
server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT;
|
||||||
|
}
|
||||||
|
|
||||||
luaLoadLibraries(lua);
|
luaLoadLibraries(lua);
|
||||||
luaRemoveUnsupportedFunctions(lua);
|
luaRemoveUnsupportedFunctions(lua);
|
||||||
|
|
||||||
@ -952,7 +966,7 @@ void scriptingRelease(void) {
|
|||||||
|
|
||||||
void scriptingReset(void) {
|
void scriptingReset(void) {
|
||||||
scriptingRelease();
|
scriptingRelease();
|
||||||
scriptingInit();
|
scriptingInit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set an array of Redis String Objects as a Lua array (table) stored into a
|
/* Set an array of Redis String Objects as a Lua array (table) stored into a
|
||||||
@ -1011,6 +1025,15 @@ int redis_math_randomseed (lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------
|
||||||
|
* LDB: Redis Lua debugging facilities
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* Enable debug mode of Lua scripts for this client. */
|
||||||
|
void ldbEnable(client *c) {
|
||||||
|
c->flags |= CLIENT_LUA_DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------
|
/* ---------------------------------------------------------------------------
|
||||||
* EVAL and SCRIPT commands implementation
|
* EVAL and SCRIPT commands implementation
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
@ -1331,6 +1354,9 @@ void scriptCommand(client *c) {
|
|||||||
server.lua_kill = 1;
|
server.lua_kill = 1;
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.ok);
|
||||||
}
|
}
|
||||||
|
} else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"debug")) {
|
||||||
|
ldbEnable(c);
|
||||||
|
addReply(c,shared.ok);
|
||||||
} else {
|
} else {
|
||||||
addReplyError(c, "Unknown SCRIPT subcommand or wrong # of args.");
|
addReplyError(c, "Unknown SCRIPT subcommand or wrong # of args.");
|
||||||
}
|
}
|
||||||
|
@ -1508,11 +1508,6 @@ void initServerConfig(void) {
|
|||||||
server.cluster_slave_validity_factor = CLUSTER_DEFAULT_SLAVE_VALIDITY;
|
server.cluster_slave_validity_factor = CLUSTER_DEFAULT_SLAVE_VALIDITY;
|
||||||
server.cluster_require_full_coverage = CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE;
|
server.cluster_require_full_coverage = CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE;
|
||||||
server.cluster_configfile = zstrdup(CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
|
server.cluster_configfile = zstrdup(CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
|
||||||
server.lua_caller = NULL;
|
|
||||||
server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT;
|
|
||||||
server.lua_client = NULL;
|
|
||||||
server.lua_timedout = 0;
|
|
||||||
server.lua_always_replicate_commands = 0; /* Only DEBUG can change it. */
|
|
||||||
server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL);
|
server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL);
|
||||||
server.next_client_id = 1; /* Client IDs, start from 1 .*/
|
server.next_client_id = 1; /* Client IDs, start from 1 .*/
|
||||||
server.loading_process_events_interval_bytes = (1024*1024*2);
|
server.loading_process_events_interval_bytes = (1024*1024*2);
|
||||||
@ -1973,7 +1968,7 @@ void initServer(void) {
|
|||||||
|
|
||||||
if (server.cluster_enabled) clusterInit();
|
if (server.cluster_enabled) clusterInit();
|
||||||
replicationScriptCacheInit();
|
replicationScriptCacheInit();
|
||||||
scriptingInit();
|
scriptingInit(1);
|
||||||
slowlogInit();
|
slowlogInit();
|
||||||
latencyMonitorInit();
|
latencyMonitorInit();
|
||||||
bioInit();
|
bioInit();
|
||||||
|
@ -1468,7 +1468,7 @@ int redis_check_rdb(char *rdbfilename);
|
|||||||
int redis_check_rdb_main(char **argv, int argc);
|
int redis_check_rdb_main(char **argv, int argc);
|
||||||
|
|
||||||
/* Scripting */
|
/* Scripting */
|
||||||
void scriptingInit(void);
|
void scriptingInit(int setup);
|
||||||
|
|
||||||
/* Blocked clients */
|
/* Blocked clients */
|
||||||
void processUnblockedClients(void);
|
void processUnblockedClients(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user