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
c3229c33
Commit
c3229c33
authored
May 22, 2013
by
ioddly
Browse files
Try to report source of bad Lua API calls
parent
5d0f408d
Changes
1
Show whitespace changes
Inline
Side-by-side
src/scripting.c
View file @
c3229c33
...
@@ -152,9 +152,20 @@ char *redisProtocolToLuaType_MultiBulk(lua_State *lua, char *reply) {
...
@@ -152,9 +152,20 @@ char *redisProtocolToLuaType_MultiBulk(lua_State *lua, char *reply) {
}
}
void
luaPushError
(
lua_State
*
lua
,
char
*
error
)
{
void
luaPushError
(
lua_State
*
lua
,
char
*
error
)
{
lua_Debug
dbg
;
lua_newtable
(
lua
);
lua_newtable
(
lua
);
lua_pushstring
(
lua
,
"err"
);
lua_pushstring
(
lua
,
"err"
);
/* Attempt to figure out where this function was called, if possible */
if
(
lua_getstack
(
lua
,
1
,
&
dbg
)
&&
lua_getinfo
(
lua
,
"nSl"
,
&
dbg
))
{
sds
msg
=
sdscatprintf
(
sdsempty
(),
"%s: %d: %s"
,
dbg
.
source
,
dbg
.
currentline
,
error
);
lua_pushstring
(
lua
,
msg
);
sdsfree
(
msg
);
}
else
{
lua_pushstring
(
lua
,
error
);
lua_pushstring
(
lua
,
error
);
}
lua_settable
(
lua
,
-
3
);
lua_settable
(
lua
,
-
3
);
}
}
...
@@ -866,9 +877,10 @@ void evalGenericCommand(redisClient *c, int evalsha) {
...
@@ -866,9 +877,10 @@ void evalGenericCommand(redisClient *c, int evalsha) {
delhook
=
1
;
delhook
=
1
;
}
}
/* At this point wh
atev
er this script was never seen before or if it was
/* At this point wh
eth
er this script was never seen before or if it was
* already defined, we can call it. We have zero arguments and expect
* already defined, we can call it. We have zero arguments and expect
* a single return value. */
* a single return value. */
err
=
lua_pcall
(
lua
,
0
,
1
,
0
);
err
=
lua_pcall
(
lua
,
0
,
1
,
0
);
/* Perform some cleanup that we need to do both on error and success. */
/* Perform some cleanup that we need to do both on error and success. */
...
...
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