redict/src
antirez 314043552b Modules: don't crash when Lua calls a module blocking command.
Lua scripting does not support calling blocking commands, however all
the native Redis commands are flagged as "s" (no scripting flag), so
this is not possible at all. With modules there is no such mechanism in
order to flag a command as non callable by the Lua scripting engine,
moreover we cannot trust the modules users from complying all the times:
it is likely that modules will be released to have blocking commands
without such commands being flagged correctly, even if we provide a way to
signal this fact.

This commit attempts to address the problem in a short term way, by
detecting that a module is trying to block in the context of the Lua
scripting engine client, and preventing to do this. The module will
actually believe to block as usually, but what happens is that the Lua
script receives an error immediately, and the background call is ignored
by the Redis engine (if not for the cleanup callbacks, once it
unblocks).

Long term, the more likely solution, is to introduce a new call called
RedisModule_GetClientFlags(), so that a command can detect if the caller
is a Lua script, and return an error, or avoid blocking at all.

Being the blocking API experimental right now, more work is needed in
this regard in order to reach a level well blocking module commands and
all the other Redis subsystems interact peacefully.

Now the effect is like the following:

    127.0.0.1:6379> eval "redis.call('hello.block',1,5000)" 0
    (error) ERR Error running script (call to
    f_b5ba35ff97bc1ef23debc4d6e9fd802da187ed53): @user_script:1: ERR
    Blocking module command called from Lua script

This commit fixes issue #4127 in the short term.
2017-07-23 12:55:37 +02:00
..
modules Allow certain modules APIs only defining REDISMODULE_EXPERIMENTAL_API. 2017-07-14 12:07:52 +02:00
.gitignore Ignore gcov/lcov artifacts 2012-04-13 17:52:33 -07:00
adlist.c minor fix in listJoin(). 2017-07-06 19:47:21 +08:00
adlist.h Modules TSC: Handling of RM_Reply* functions. 2017-05-02 15:05:39 +02:00
ae_epoll.c various cleanups and minor fixes 2016-04-25 16:49:57 +03:00
ae_evport.c ae.c event loop: API to resize the fd set size on the run. 2013-06-28 16:39:49 +02:00
ae_kqueue.c No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
ae_select.c Include 'fd_set' type name 2016-06-07 16:46:00 -04:00
ae.c Event loop: call after sleep() only from top level. 2017-07-11 00:13:52 +02:00
ae.h Event loop: call after sleep() only from top level. 2017-07-11 00:13:52 +02:00
anet.c Fix #3848 by closing the descriptor on error. 2017-04-18 16:24:06 +02:00
anet.h Fix ae.c to avoid timers infinite loop. 2016-04-04 08:50:58 +02:00
aof.c Aesthetic changes to #4068 PR to conform to Redis coding standard. 2017-06-22 11:00:34 +02:00
asciilogo.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
atomicvar.h atomicvar.h: show used API in INFO. Add macro to force __sync builtin. 2017-05-10 09:33:49 +02:00
bio.c Lazyfree: ability to free whole DBs in background. 2015-10-01 13:02:26 +02:00
bio.h Threaded lazyfree WIP #1. 2015-10-01 13:02:25 +02:00
bitops.c Use ARM unaligned accesses ifdefs for SPARC as well. 2017-02-23 22:39:44 +08:00
blocked.c Module: API to block clients with threading support. 2016-10-07 11:55:35 +02:00
childinfo.c Clear child data when opening the pipes. 2016-09-19 14:11:17 +02:00
cluster.c Make representClusterNodeFlags() more robust. 2017-07-20 15:17:35 +02:00
cluster.h Fixed comment in clusterMsg version field 2017-06-04 15:09:05 +01:00
config.c Use SipHash hash function to mitigate HashDos attempts. 2017-02-20 17:29:17 +01:00
config.h Use ARM unaligned accesses ifdefs for SPARC as well. 2017-02-23 22:39:44 +08:00
crc16.c RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
crc64.c Allow all code tests to run using Redis args 2014-12-23 09:31:03 -05:00
crc64.h Allow all code tests to run using Redis args 2014-12-23 09:31:03 -05:00
db.c Implement getKeys procedure for georadius and georadiusbymember 2017-06-14 18:15:48 +02:00
debug.c Modules: DEBUG DIGEST interface. 2017-07-06 11:04:46 +02:00
debugmacro.h Use the standard predefined identifier __func__ (since C99) 2016-08-04 15:12:12 +08:00
defrag.c Defrag: don't crash when a module value is encountered. 2017-01-12 09:50:40 +01:00
dict.c Use locale agnostic tolower() in dict.c hash function. 2017-02-20 17:39:44 +01:00
dict.h Use SipHash hash function to mitigate HashDos attempts. 2017-02-20 17:29:17 +01:00
endianconv.c Allow all code tests to run using Redis args 2014-12-23 09:31:03 -05:00
endianconv.h Allow all code tests to run using Redis args 2014-12-23 09:31:03 -05:00
evict.c Issue #4027: unify comment and modify return value in freeMemoryIfNeeded(). 2017-06-23 11:42:25 +02:00
expire.c Issue #4027: unify comment and modify return value in freeMemoryIfNeeded(). 2017-06-23 11:42:25 +02:00
fmacros.h Silence _BSD_SOURCE warnings in glibc 2.20 and forward 2014-12-05 12:41:59 +11:00
geo.c Added GEORADIUS(BYMEMBER)_RO variants for read-only operations. 2017-06-30 10:03:37 +02:00
geo.h RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
geohash_helper.c Fix GEORADIUS edge case with huge radius. 2017-07-03 19:38:31 +02:00
geohash_helper.h Fix definition of M_PI in geohash_helper.c. 2016-07-06 16:31:11 +02:00
geohash.c Multiple GEORADIUS bugs fixed. 2016-07-27 11:34:25 +02:00
geohash.h Multiple GEORADIUS bugs fixed. 2016-07-27 11:34:25 +02:00
help.h redis-cli help.h updated. 2016-06-14 14:45:28 +02:00
hyperloglog.c Fix isHLLObjectOrReply() to handle integer encoded strings. 2017-07-11 12:44:59 +02:00
intset.c Merge pull request #3242 from whatacold/unstable 2016-12-20 15:39:56 +01:00
intset.h Use const in Redis Module API where possible. 2016-06-20 23:08:06 +03:00
latency.c Use SipHash hash function to mitigate HashDos attempts. 2017-02-20 17:29:17 +01:00
latency.h Separate latency monitoring of eviction loop and eviction DELs. 2015-02-11 10:52:27 +01:00
lazyfree.c Simplify atomicvar.h usage by having the mutex name implicit. 2017-05-04 17:01:00 +02:00
lzf_c.c Upgrade LZF to 3.6 (2011) from 3.5 (2009) 2015-01-02 11:16:10 -05:00
lzf_d.c Upgrade LZF to 3.6 (2011) from 3.5 (2009) 2015-01-02 11:16:10 -05:00
lzf.h No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
lzfP.h Upgrade LZF to 3.6 (2011) from 3.5 (2009) 2015-01-02 11:16:10 -05:00
Makefile AOF check utility: ability to check files with RDB preamble. 2017-07-10 13:38:23 +02:00
memtest.c Hopefully better memory test on crash. 2015-12-16 17:41:22 +01:00
mkreleasehdr.sh suppress external diff program when using git diff. 2013-02-24 18:17:46 +01:00
module.c Modules: don't crash when Lua calls a module blocking command. 2017-07-23 12:55:37 +02:00
multi.c Fix replication of SLAVEOF inside transaction. 2017-07-12 11:07:28 +02:00
networking.c Clients blocked in modules: free argv/argc later. 2017-07-11 12:33:01 +02:00
notify.c RDMF: More consistent define names. 2015-07-27 14:37:58 +02:00
object.c Don't divide by zero 2017-01-27 16:24:14 +01:00
pqsort.c No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
pqsort.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
pubsub.c RDMF: More consistent define names. 2015-07-27 14:37:58 +02:00
quicklist.c fix a bug for quicklistDup() function 2016-10-28 19:47:29 +08:00
quicklist.h Use const in Redis Module API where possible. 2016-06-20 23:08:06 +03:00
rand.c Use 'void' for zero-argument functions 2014-08-08 10:05:32 +02:00
rand.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
rax_malloc.h Cluster: hash slots tracking using a radix tree. 2017-03-27 16:37:22 +02:00
rax.c Rax library updated. 2017-04-08 17:31:13 +02:00
rax.h Rax library updated. 2017-04-07 08:46:39 +02:00
rdb.c AOF check utility: ability to check files with RDB preamble. 2017-07-10 13:38:23 +02:00
rdb.h RDB modules values serialization format version 2. 2017-06-27 13:19:16 +02:00
redis-benchmark.c redis-benchmark: add -t hset target. 2017-06-19 09:41:11 +02:00
redis-check-aof.c redis-check-aof: tell users there is a --fix option. 2017-07-10 16:41:25 +02:00
redis-check-rdb.c AOF check utility: ability to check files with RDB preamble. 2017-07-10 13:38:23 +02:00
redis-cli.c redis-cli --latency: ability to run non interactively. 2017-06-30 15:41:58 +02:00
redis-trib.rb Refactor redis-trib.rb 2016-10-10 01:13:20 +09:00
redisassert.h Add panic() into redisassert.h. 2017-01-18 17:12:07 +01:00
redismodule.h Allow certain modules APIs only defining REDISMODULE_EXPERIMENTAL_API. 2017-07-14 12:07:52 +02:00
release.c No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
replication.c PSYNC2: fix master cleanup when caching it. 2017-04-27 17:08:37 +02:00
rio.c various cleanups and minor fixes 2016-04-25 16:49:57 +03:00
rio.h Modules: support for modules native data types. 2016-06-03 18:14:04 +02:00
scripting.c Fix abort typo in Lua debugger help screen. 2017-06-30 12:12:00 +02:00
sds.c sds: don't check for impossible string size in 32 bit systems. 2016-09-01 11:04:22 +02:00
sds.h Lua debugger: use sds_malloc() to allocate eval cli array. 2015-11-17 15:43:23 +01:00
sdsalloc.h SDS: changes to unify Redis SDS with antirez/sds repo. 2015-07-25 17:25:44 +02:00
sentinel.c Use SipHash hash function to mitigate HashDos attempts. 2017-02-20 17:29:17 +01:00
server.c AOF check utility: ability to check files with RDB preamble. 2017-07-10 13:38:23 +02:00
server.h Fix replication of SLAVEOF inside transaction. 2017-07-12 11:07:28 +02:00
setproctitle.c Set proctitle: avoid the use of __attribute__((constructor)). 2013-02-27 11:50:35 +01:00
sha1.c sha1.c: use standard uint32_t. 2015-04-27 12:07:49 +02:00
sha1.h sha1.c: use standard uint32_t. 2015-04-27 12:07:49 +02:00
siphash.c SipHash 2-4 -> SipHash 1-2. 2017-02-21 17:07:28 +01:00
slowlog.c SLOWLOG: log offending client address and name. 2017-06-15 12:57:54 +02:00
slowlog.h Merge pull request #4056 from season89/unstable 2017-06-20 16:55:29 +02:00
solarisfixes.h Check for __sun macro in solarisfixes.h, not in includers. 2015-01-09 11:23:22 +01:00
sort.c Lazyfree: Hash converted to use plain SDS WIP 4. 2015-10-01 13:02:25 +02:00
sparkline.c RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
sparkline.h LATENCY GRAPH implemented. 2014-07-02 16:31:22 +02:00
syncio.c syncWithMaster(): non blocking state machine. 2015-08-06 18:12:20 +02:00
t_hash.c HMSET and MSET implementations unified. HSET now variadic. 2017-06-29 17:38:46 +02:00
t_list.c Use const in Redis Module API where possible. 2016-06-20 23:08:06 +03:00
t_set.c Optimize repeated keyname hashing. 2016-09-12 13:19:05 +02:00
t_string.c Replication: fix the infamous key leakage of writable slaves + EXPIRE. 2016-12-13 10:59:54 +01:00
t_zset.c Use SipHash hash function to mitigate HashDos attempts. 2017-02-20 17:29:17 +01:00
testhelp.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
util.c Modules: first preview 31 March 2016. 2016-05-10 06:40:05 +02:00
util.h Fix HINCRBYFLOAT to work with long doubles. 2015-11-04 17:16:34 +01:00
valgrind.sup more valgrind friendly test 2011-07-06 15:22:00 +02:00
version.h Mark version of unstable branch in an unique way. 2015-09-29 17:30:24 +02:00
ziplist.c Fix ziplist fix... 2017-02-01 17:01:31 +01:00
ziplist.h DEBUG: new "ziplist" subcommand added. Dumps a ziplist on stdout. 2016-12-16 09:02:50 +01:00
zipmap.c Allow all code tests to run using Redis args 2014-12-23 09:31:03 -05:00
zipmap.h Allow all code tests to run using Redis args 2014-12-23 09:31:03 -05:00
zmalloc.c zmalloc.c: remove thread safe mode, it's the default way. 2017-05-09 16:59:51 +02:00
zmalloc.h zmalloc.c: remove thread safe mode, it's the default way. 2017-05-09 16:59:51 +02:00