MCPcopy Create free account
hub / github.com/F-Stack/f-stack / scriptingInit

Function scriptingInit

app/redis-6.2.6/src/scripting.c:1131–1310  ·  view source on GitHub ↗

Initialize the scripting environment. * * This function is called the first time at server startup with * the 'setup' argument set to 1. * * 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

Source from the content-addressed store, hash-verified

1129 *
1130 * However it is simpler to just call scriptingReset() that does just that. */
1131void scriptingInit(int setup) {
1132 lua_State *lua = lua_open();
1133
1134 if (setup) {
1135 server.lua_client = NULL;
1136 server.lua_caller = NULL;
1137 server.lua_cur_script = NULL;
1138 server.lua_timedout = 0;
1139 ldbInit();
1140 }
1141
1142 luaLoadLibraries(lua);
1143 luaRemoveUnsupportedFunctions(lua);
1144
1145 /* Initialize a dictionary we use to map SHAs to scripts.
1146 * This is useful for replication, as we need to replicate EVALSHA
1147 * as EVAL, so we need to remember the associated script. */
1148 server.lua_scripts = dictCreate(&shaScriptObjectDictType,NULL);
1149 server.lua_scripts_mem = 0;
1150
1151 /* Register the redis commands table and fields */
1152 lua_newtable(lua);
1153
1154 /* redis.call */
1155 lua_pushstring(lua,"call");
1156 lua_pushcfunction(lua,luaRedisCallCommand);
1157 lua_settable(lua,-3);
1158
1159 /* redis.pcall */
1160 lua_pushstring(lua,"pcall");
1161 lua_pushcfunction(lua,luaRedisPCallCommand);
1162 lua_settable(lua,-3);
1163
1164 /* redis.log and log levels. */
1165 lua_pushstring(lua,"log");
1166 lua_pushcfunction(lua,luaLogCommand);
1167 lua_settable(lua,-3);
1168
1169 /* redis.setresp */
1170 lua_pushstring(lua,"setresp");
1171 lua_pushcfunction(lua,luaSetResp);
1172 lua_settable(lua,-3);
1173
1174 lua_pushstring(lua,"LOG_DEBUG");
1175 lua_pushnumber(lua,LL_DEBUG);
1176 lua_settable(lua,-3);
1177
1178 lua_pushstring(lua,"LOG_VERBOSE");
1179 lua_pushnumber(lua,LL_VERBOSE);
1180 lua_settable(lua,-3);
1181
1182 lua_pushstring(lua,"LOG_NOTICE");
1183 lua_pushnumber(lua,LL_NOTICE);
1184 lua_settable(lua,-3);
1185
1186 lua_pushstring(lua,"LOG_WARNING");
1187 lua_pushnumber(lua,LL_WARNING);
1188 lua_settable(lua,-3);

Callers 2

scriptingResetFunction · 0.85
initServerFunction · 0.85

Calls 13

ldbInitFunction · 0.85
luaLoadLibrariesFunction · 0.85
lua_setglobalFunction · 0.85
lua_getglobalFunction · 0.85
luaL_loadbufferFunction · 0.85
lua_pcallFunction · 0.85
dictCreateFunction · 0.70
createClientFunction · 0.70
lua_pushstringFunction · 0.50
lua_settableFunction · 0.50

Tested by

no test coverage detected