Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d6c24ff6
"vscode:/vscode.git/clone" did not exist on "f8e2279e3a32d0fc88c09def807fe8a4b03771b2"
Commit
d6c24ff6
authored
Nov 05, 2015
by
antirez
Browse files
Initialize all Lua scripting related things into scripting.c
parent
1fb2b91a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/scripting.c
View file @
d6c24ff6
...
@@ -790,12 +790,26 @@ void scriptingEnableGlobalsProtection(lua_State *lua) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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."
);
}
}
...
...
src/server.c
View file @
d6c24ff6
...
@@ -1495,11 +1495,6 @@ void initServerConfig(void) {
...
@@ -1495,11 +1495,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
);
...
@@ -1951,7 +1946,7 @@ void initServer(void) {
...
@@ -1951,7 +1946,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
();
...
...
src/server.h
View file @
d6c24ff6
...
@@ -1441,7 +1441,7 @@ int redis_check_rdb(char *rdbfilename);
...
@@ -1441,7 +1441,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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment