Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Redis from internal lua function names and comments #1102

Merged
merged 8 commits into from
Oct 4, 2024
19 changes: 12 additions & 7 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void sha1hex(char *digest, char *script, size_t len) {
digest[40] = '\0';
}

/* server.breakpoint()
/* Adds server.breakpoint() function used by lua debugger.
*
* Allows to stop execution during a debugging session from within
* the Lua code implementation, like if a breakpoint was set in the code
Expand All @@ -151,7 +151,7 @@ int luaServerBreakpointCommand(lua_State *lua) {
return 1;
}

/* server.debug()
/* Adds server.debug() function used by lua debugger
*
* Log a string message into the output console.
* Can take multiple arguments that will be separated by commas.
Expand All @@ -168,7 +168,7 @@ int luaServerDebugCommand(lua_State *lua) {
return 0;
}

/* server.replicate_commands()
/* Adds server.replicate_commands()
*
* DEPRECATED: Now do nothing and always return true.
* Turn on single commands replication if the script never called
Expand Down Expand Up @@ -208,7 +208,8 @@ void scriptingInit(int setup) {

luaRegisterServerAPI(lua);

/* register debug commands */
/* register debug commands. we only need to add it under 'server' as 'redis' is effectively aliased to 'server'
* table at this point. */
lua_getglobal(lua, "server");

/* server.breakpoint */
Expand All @@ -235,7 +236,7 @@ void scriptingInit(int setup) {
{
char *errh_func = "local dbg = debug\n"
"debug = nil\n"
"function __redis__err__handler(err)\n"
"function __server__err__handler(err)\n"
" local i = dbg.getinfo(2,'nSl')\n"
" if i and i.what == 'C' then\n"
" i = dbg.getinfo(3,'nSl')\n"
Expand All @@ -251,6 +252,9 @@ void scriptingInit(int setup) {
"end\n";
luaL_loadbuffer(lua, errh_func, strlen(errh_func), "@err_handler_def");
lua_pcall(lua, 0, 0, 0);
/* Duplicate the function with __redis__err_handler name for backwards compatibility */
lua_getglobal(lua, "__server__err__handler");
lua_setglobal(lua, "__redis__err__handler");
}

/* Create the (non connected) client that we use to execute server commands
Expand Down Expand Up @@ -577,7 +581,7 @@ void evalGenericCommand(client *c, int evalsha) {
evalCalcFunctionName(evalsha, c->argv[1]->ptr, funcname);

/* Push the pcall error handler function on the stack. */
lua_getglobal(lua, "__redis__err__handler");
lua_getglobal(lua, "__server__err__handler");

/* Try to lookup the Lua function */
lua_getfield(lua, LUA_REGISTRYINDEX, funcname);
Expand Down Expand Up @@ -1525,7 +1529,8 @@ void ldbServer(lua_State *lua, sds *argv, int argc) {
lua_getglobal(lua, "server");
lua_pushstring(lua, "call");
lua_gettable(lua, -2); /* Stack: server, server.call */
for (j = 1; j < argc; j++) lua_pushlstring(lua, argv[j], sdslen(argv[j]));
for (j = 1; j < argc; j++)
lua_pushlstring(lua, argv[j], sdslen(argv[j]));
ldb.step = 1; /* Force server.call() to log. */
lua_pcall(lua, argc - 1, 1, 0); /* Stack: server, result */
ldb.step = 0; /* Disable logging. */
Expand Down
2 changes: 1 addition & 1 deletion src/function_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ int luaEngineInitEngine(void) {

/* Register the library commands table and fields and store it to registry */
lua_newtable(lua_engine_ctx->lua); /* load library globals */
lua_newtable(lua_engine_ctx->lua); /* load library `redis` table */
lua_newtable(lua_engine_ctx->lua); /* load library `server` table */

lua_pushstring(lua_engine_ctx->lua, "register_function");
lua_pushcfunction(lua_engine_ctx->lua, luaRegisterFunction);
Expand Down
2 changes: 1 addition & 1 deletion src/rand.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
int32_t serverLrand48(void);
void serverSrand48(int32_t seedval);

#define REDIS_LRAND48_MAX INT32_MAX
#define SERVER_LRAND48_MAX INT32_MAX

#endif
Loading
Loading