├── INSTALL ├── tests ├── tmp │ └── .gitignore ├── cluster │ ├── tmp │ │ └── .gitignore │ ├── tests │ │ ├── helpers │ │ │ └── onlydots.tcl │ │ ├── 01-faildet.tcl │ │ ├── 09-pubsub.tcl │ │ ├── 15-cluster-slots.tcl │ │ ├── 11-manual-takeover.tcl │ │ ├── 02-failover.tcl │ │ └── 13-no-failover-option.tcl │ └── run.tcl ├── sentinel │ ├── tmp │ │ └── .gitignore │ ├── tests │ │ ├── 03-runtime-reconf.tcl │ │ ├── 04-slave-selection.tcl │ │ ├── 06-ckquorum.tcl │ │ ├── 01-conf-update.tcl │ │ └── 05-manual.tcl │ └── run.tcl ├── assets │ ├── encodings.rdb │ ├── hash-zipmap.rdb │ └── default.conf ├── unit │ ├── printver.tcl │ ├── type │ │ └── list-common.tcl │ ├── limits.tcl │ ├── auth.tcl │ ├── moduleapi │ │ ├── fork.tcl │ │ ├── scan.tcl │ │ └── datatype.tcl │ ├── quit.tcl │ ├── pendingquerybuf.tcl │ ├── lazyfree.tcl │ └── wait.tcl ├── helpers │ ├── bg_complex_data.tcl │ ├── gen_write_load.tcl │ └── bg_block_op.tcl ├── support │ ├── tmpfile.tcl │ └── cli.tcl ├── integration │ ├── logging.tcl │ ├── convert-zipmap-hash-on-load.tcl │ └── aof-race.tcl └── modules │ └── Makefile ├── deps ├── jemalloc │ ├── config.stamp.in │ ├── VERSION │ ├── .gitattributes │ ├── test │ │ ├── unit │ │ │ ├── junk_alloc.c │ │ │ ├── junk_free.c │ │ │ ├── arena_reset_prof.sh │ │ │ ├── decay.sh │ │ │ ├── arena_reset_prof.c │ │ │ ├── junk.sh │ │ │ ├── pack.sh │ │ │ ├── prof_tctx.sh │ │ │ ├── zero.sh │ │ │ ├── junk_alloc.sh │ │ │ ├── junk_free.sh │ │ │ ├── prof_thread_name.sh │ │ │ ├── prof_reset.sh │ │ │ ├── prof_gdump.sh │ │ │ ├── prof_active.sh │ │ │ ├── prof_accum.sh │ │ │ ├── prof_idump.sh │ │ │ ├── a0.c │ │ │ ├── spin.c │ │ │ ├── div.c │ │ │ ├── pages.c │ │ │ ├── hooks.c │ │ │ ├── prof_idump.c │ │ │ ├── slab.c │ │ │ ├── mtx.c │ │ │ ├── prof_tctx.c │ │ │ ├── zero.c │ │ │ └── bit_util.c │ │ ├── src │ │ │ ├── math.c │ │ │ ├── btalloc_0.c │ │ │ ├── btalloc_1.c │ │ │ ├── btalloc.c │ │ │ ├── mq.c │ │ │ ├── thd.c │ │ │ ├── timer.c │ │ │ └── mtx.c │ │ ├── integration │ │ │ ├── extent.sh │ │ │ ├── mallocx.sh │ │ │ ├── xallocx.sh │ │ │ ├── cpp │ │ │ │ └── basic.cpp │ │ │ ├── sdallocx.c │ │ │ ├── overflow.c │ │ │ └── MALLOCX_ARENA.c │ │ └── include │ │ │ └── test │ │ │ ├── thd.h │ │ │ ├── jemalloc_test_defs.h.in │ │ │ ├── timer.h │ │ │ ├── mtx.h │ │ │ └── btalloc.h │ ├── run_tests.sh │ ├── msvc │ │ ├── test_threads │ │ │ ├── test_threads.h │ │ │ └── test_threads_main.cpp │ │ ├── ReadMe.txt │ │ └── projects │ │ │ ├── vc2015 │ │ │ └── test_threads │ │ │ │ └── test_threads.vcxproj.filters │ │ │ └── vc2017 │ │ │ └── test_threads │ │ │ └── test_threads.vcxproj.filters │ ├── .autom4te.cfg │ ├── src │ │ ├── hash.c │ │ ├── prng.c │ │ ├── ticker.c │ │ ├── hooks.c │ │ ├── mutex_pool.c │ │ ├── extent_mmap.c │ │ └── bin.c │ ├── include │ │ ├── jemalloc │ │ │ ├── internal │ │ │ │ ├── private_namespace.sh │ │ │ │ ├── public_unnamespace.sh │ │ │ │ ├── public_namespace.sh │ │ │ │ ├── tsd_types.h │ │ │ │ ├── arena_structs_a.h │ │ │ │ ├── base_inlines.h │ │ │ │ ├── extent_mmap.h │ │ │ │ ├── extent_types.h │ │ │ │ ├── spin.h │ │ │ │ ├── extent_dss.h │ │ │ │ ├── hooks.h │ │ │ │ ├── base_externs.h │ │ │ │ ├── stats.h │ │ │ │ ├── jemalloc_internal_macros.h │ │ │ │ ├── base_types.h │ │ │ │ ├── div.h │ │ │ │ ├── large_externs.h │ │ │ │ ├── tsd_tls.h │ │ │ │ ├── private_symbols.sh │ │ │ │ ├── tsd_malloc_thread_cleanup.h │ │ │ │ ├── nstime.h │ │ │ │ ├── background_thread_externs.h │ │ │ │ ├── bin_stats.h │ │ │ │ ├── assert.h │ │ │ │ ├── arena_types.h │ │ │ │ ├── arena_inlines_a.h │ │ │ │ └── util.h │ │ │ ├── jemalloc_rename.sh │ │ │ ├── jemalloc.sh │ │ │ ├── jemalloc_defs.h.in │ │ │ └── jemalloc_mangle.sh │ │ └── msvc_compat │ │ │ ├── windows_extra.h │ │ │ ├── C99 │ │ │ └── stdbool.h │ │ │ └── strings.h │ ├── bin │ │ └── jemalloc.sh.in │ ├── doc │ │ ├── manpages.xsl.in │ │ ├── html.xsl.in │ │ └── stylesheet.xsl │ ├── autogen.sh │ ├── jemalloc.pc.in │ ├── README │ └── .appveyor.yml ├── linenoise │ ├── .gitignore │ └── Makefile ├── lua │ ├── doc │ │ ├── logo.gif │ │ ├── cover.png │ │ ├── manual.css │ │ ├── readme.html │ │ └── lua.css │ ├── etc │ │ ├── lua.ico │ │ ├── lua.hpp │ │ ├── lua.pc │ │ ├── all.c │ │ ├── min.c │ │ ├── Makefile │ │ ├── strict.lua │ │ ├── README │ │ ├── luavs.bat │ │ └── noparser.c │ ├── test │ │ ├── life.lua │ │ ├── echo.lua │ │ ├── hello.lua │ │ ├── printf.lua │ │ ├── env.lua │ │ ├── luac.lua │ │ ├── fibfor.lua │ │ ├── readonly.lua │ │ ├── table.lua │ │ ├── cf.lua │ │ ├── xd.lua │ │ ├── globals.lua │ │ ├── bisect.lua │ │ ├── fib.lua │ │ ├── factorial.lua │ │ ├── sieve.lua │ │ ├── trace-calls.lua │ │ ├── trace-globals.lua │ │ └── README │ ├── src │ │ ├── lapi.h │ │ ├── fpconv.h │ │ ├── linit.c │ │ ├── lstring.h │ │ ├── lundump.h │ │ ├── ldebug.h │ │ ├── ltm.h │ │ ├── lualib.h │ │ ├── lfunc.h │ │ ├── lvm.h │ │ ├── ltable.h │ │ └── lmem.h │ ├── README │ └── COPYRIGHT ├── hiredis │ ├── .gitignore │ ├── fmacros.h │ ├── hiredis_ssl.pc.in │ ├── hiredis.pc.in │ ├── examples │ │ ├── example-qt.h │ │ ├── example-qt.cpp │ │ ├── CMakeLists.txt │ │ ├── example-libev.c │ │ ├── example-ivykis.c │ │ └── example-libuv.c │ ├── appveyor.yml │ ├── win32.h │ └── COPYING └── update-jemalloc.sh ├── utils ├── hyperloglog │ ├── .gitignore │ └── hll-err.rb ├── create-cluster │ ├── .gitignore │ └── README ├── releasetools │ ├── 02_upload_tarball.sh │ ├── 01_create_tarball.sh │ ├── 04_release_hash.sh │ ├── 03_test_release.sh │ └── changelog.tcl ├── hashtable │ └── README ├── srandmember │ ├── showfreq.rb │ ├── README.md │ └── showdist.rb ├── build-static-symbols.tcl ├── gen-test-certs.sh ├── graphs │ └── commits-over-time │ │ └── README.md ├── whatisdoing.sh ├── lru │ └── README ├── redis_init_script.tpl ├── corrupt_rdb.c ├── redis-copy.rb ├── systemd-redis_multiple_servers@.service ├── cluster_fail_time.tcl ├── redis_init_script └── systemd-redis_server.service ├── src ├── modules │ ├── .gitignore │ └── gendoc.rb ├── version.h ├── .gitignore ├── crc64.h ├── valgrind.sup ├── geo.h ├── sha1.h ├── mkreleasehdr.sh └── sha256.h ├── BUGS ├── Makefile ├── runtest ├── runtest-cluster ├── runtest-sentinel ├── .gitignore ├── runtest-moduleapi ├── .github └── workflows │ └── ci.yml └── COPYING /INSTALL: -------------------------------------------------------------------------------- 1 | See README 2 | -------------------------------------------------------------------------------- /tests/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /deps/jemalloc/config.stamp.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /deps/jemalloc/VERSION: -------------------------------------------------------------------------------- 1 | 5.1.0-0-g0 2 | -------------------------------------------------------------------------------- /utils/hyperloglog/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | -------------------------------------------------------------------------------- /src/modules/.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.xo 3 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | #define REDIS_VERSION "6.0.5" 2 | -------------------------------------------------------------------------------- /deps/jemalloc/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_alloc.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_free.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /tests/cluster/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /tests/sentinel/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | Please check https://github.com/antirez/redis/issues 2 | -------------------------------------------------------------------------------- /deps/jemalloc/run_tests.sh: -------------------------------------------------------------------------------- 1 | $(dirname "$)")/scripts/gen_run_tests.py | bash 2 | -------------------------------------------------------------------------------- /deps/linenoise/.gitignore: -------------------------------------------------------------------------------- 1 | linenoise_example 2 | *.dSYM 3 | history.txt 4 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.gcda 2 | *.gcno 3 | *.gcov 4 | redis.info 5 | lcov-html 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/math.c: -------------------------------------------------------------------------------- 1 | #define MATH_C_ 2 | #include "test/jemalloc_test.h" 3 | -------------------------------------------------------------------------------- /deps/lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmem/redis/HEAD/deps/lua/doc/logo.gif -------------------------------------------------------------------------------- /deps/lua/etc/lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmem/redis/HEAD/deps/lua/etc/lua.ico -------------------------------------------------------------------------------- /utils/create-cluster/.gitignore: -------------------------------------------------------------------------------- 1 | config.sh 2 | *.rdb 3 | *.aof 4 | *.conf 5 | *.log 6 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/test_threads/test_threads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int test_threads(); 4 | -------------------------------------------------------------------------------- /deps/lua/doc/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmem/redis/HEAD/deps/lua/doc/cover.png -------------------------------------------------------------------------------- /deps/lua/test/life.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmem/redis/HEAD/deps/lua/test/life.lua -------------------------------------------------------------------------------- /deps/jemalloc/test/src/btalloc_0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(0) 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/btalloc_1.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(1) 4 | -------------------------------------------------------------------------------- /tests/assets/encodings.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmem/redis/HEAD/tests/assets/encodings.rdb -------------------------------------------------------------------------------- /tests/assets/hash-zipmap.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmem/redis/HEAD/tests/assets/hash-zipmap.rdb -------------------------------------------------------------------------------- /tests/sentinel/tests/03-runtime-reconf.tcl: -------------------------------------------------------------------------------- 1 | # Test runtime reconfiguration command SENTINEL SET. 2 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/arena_reset_prof.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 4 | -------------------------------------------------------------------------------- /deps/lua/test/echo.lua: -------------------------------------------------------------------------------- 1 | -- echo command line arguments 2 | 3 | for i=0,table.getn(arg) do 4 | print(i,arg[i]) 5 | end 6 | -------------------------------------------------------------------------------- /deps/lua/test/hello.lua: -------------------------------------------------------------------------------- 1 | -- the first program in every language 2 | 3 | io.write("Hello world, from ",_VERSION,"!\n") 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/decay.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="dirty_decay_ms:1000,muzzy_decay_ms:1000,lg_tcache_max:0" 4 | -------------------------------------------------------------------------------- /deps/hiredis/.gitignore: -------------------------------------------------------------------------------- 1 | /hiredis-test 2 | /examples/hiredis-example* 3 | /*.o 4 | /*.so 5 | /*.dylib 6 | /*.a 7 | /*.pc 8 | *.dSYM 9 | -------------------------------------------------------------------------------- /deps/jemalloc/.autom4te.cfg: -------------------------------------------------------------------------------- 1 | begin-language: "Autoconf-without-aclocal-m4" 2 | args: --no-cache 3 | end-language: "Autoconf-without-aclocal-m4" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/extent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/mallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/xallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/arena_reset_prof.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | #define ARENA_RESET_PROF_C_ 3 | 4 | #include "arena_reset.c" 5 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:true" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/pack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Immediately purge to minimize fragmentation. 4 | export MALLOC_CONF="dirty_decay_ms:0,muzzy_decay_ms:0" 5 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_tctx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,junk:false,zero:true" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/src/hash.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_HASH_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/src/prng.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_PRNG_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/btalloc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | void * 4 | btalloc(size_t size, unsigned bits) { 5 | return btalloc_0(size, bits); 6 | } 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_alloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:alloc" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/junk_free.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:free" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_thread_name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/src/ticker.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_TICKER_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/private_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for symbol in `cat "$@"` ; do 4 | echo "#define ${symbol} JEMALLOC_N(${symbol})" 5 | done 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_reset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_gdump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,prof_gdump:true" 5 | fi 6 | 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_active.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_thread_active_init:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/public_unnamespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#undef je_${n}" 6 | done 7 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_accum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /deps/jemalloc/include/msvc_compat/windows_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef MSVC_COMPAT_WINDOWS_EXTRA_H 2 | #define MSVC_COMPAT_WINDOWS_EXTRA_H 3 | 4 | #include 5 | 6 | #endif /* MSVC_COMPAT_WINDOWS_EXTRA_H */ 7 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/public_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#define je_${n} JEMALLOC_N(${n})" 6 | done 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Top level makefile, the real shit is at src/Makefile 2 | 3 | default: all 4 | 5 | .DEFAULT: 6 | cd src && $(MAKE) $@ 7 | 8 | install: 9 | cd src && $(MAKE) $@ 10 | 11 | .PHONY: install 12 | -------------------------------------------------------------------------------- /deps/lua/test/printf.lua: -------------------------------------------------------------------------------- 1 | -- an implementation of printf 2 | 3 | function printf(...) 4 | io.write(string.format(...)) 5 | end 6 | 7 | printf("Hello %s from %s on %s\n",os.getenv"USER" or "there",_VERSION,os.date()) 8 | -------------------------------------------------------------------------------- /deps/jemalloc/bin/jemalloc.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | 7 | @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@ 8 | export @LD_PRELOAD_VAR@ 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /deps/lua/test/env.lua: -------------------------------------------------------------------------------- 1 | -- read environment variables as if they were global variables 2 | 3 | local f=function (t,i) return os.getenv(i) end 4 | setmetatable(getfenv(),{__index=f}) 5 | 6 | -- an example 7 | print(a,USER,PATH) 8 | -------------------------------------------------------------------------------- /tests/unit/printver.tcl: -------------------------------------------------------------------------------- 1 | start_server {} { 2 | set i [r info] 3 | regexp {redis_version:(.*?)\r\n} $i - version 4 | regexp {redis_git_sha1:(.*?)\r\n} $i - sha1 5 | puts "Testing Redis version $version ($sha1)" 6 | } 7 | -------------------------------------------------------------------------------- /deps/jemalloc/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /deps/lua/etc/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /tests/sentinel/tests/04-slave-selection.tcl: -------------------------------------------------------------------------------- 1 | # Test slave selection algorithm. 2 | # 3 | # This unit should test: 4 | # 1) That when there are no suitable slaves no failover is performed. 5 | # 2) That among the available slaves, the one with better offset is picked. 6 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_idump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="tcache:false" 4 | if [ "x${enable_prof}" = "x1" ] ; then 5 | export MALLOC_CONF="${MALLOC_CONF},prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0" 6 | fi 7 | 8 | 9 | -------------------------------------------------------------------------------- /deps/lua/test/luac.lua: -------------------------------------------------------------------------------- 1 | -- bare-bones luac in Lua 2 | -- usage: lua luac.lua file.lua 3 | 4 | assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua") 5 | f=assert(io.open("luac.out","wb")) 6 | assert(f:write(string.dump(assert(loadfile(arg[1]))))) 7 | assert(f:close()) 8 | -------------------------------------------------------------------------------- /src/crc64.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC64_H 2 | #define CRC64_H 3 | 4 | #include 5 | 6 | void crc64_init(void); 7 | uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); 8 | 9 | #ifdef REDIS_TEST 10 | int crc64Test(int argc, char *argv[]); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /tests/unit/type/list-common.tcl: -------------------------------------------------------------------------------- 1 | # We need a value larger than list-max-ziplist-value to make sure 2 | # the list has the right encoding when it is swapped in again. 3 | array set largevalue {} 4 | set largevalue(ziplist) "hello" 5 | set largevalue(linkedlist) [string repeat "hello" 4] 6 | -------------------------------------------------------------------------------- /deps/jemalloc/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /deps/hiredis/fmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_FMACRO_H 2 | #define __HIREDIS_FMACRO_H 3 | 4 | #define _XOPEN_SOURCE 600 5 | #define _POSIX_C_SOURCE 200112L 6 | 7 | #if defined(__APPLE__) && defined(__MACH__) 8 | /* Enable TCP_KEEPALIVE */ 9 | #define _DARWIN_C_SOURCE 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/thd.h: -------------------------------------------------------------------------------- 1 | /* Abstraction layer for threading in tests. */ 2 | #ifdef _WIN32 3 | typedef HANDLE thd_t; 4 | #else 5 | typedef pthread_t thd_t; 6 | #endif 7 | 8 | void thd_create(thd_t *thd, void *(*proc)(void *), void *arg); 9 | void thd_join(thd_t thd, void **ret); 10 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/test_threads/test_threads_main.cpp: -------------------------------------------------------------------------------- 1 | #include "test_threads.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std::chrono_literals; 7 | 8 | int main(int argc, char** argv) { 9 | int rc = test_threads(); 10 | return rc; 11 | } 12 | -------------------------------------------------------------------------------- /src/valgrind.sup: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | fun:lzf_compress 5 | } 6 | 7 | { 8 | 9 | Memcheck:Value4 10 | fun:lzf_compress 11 | } 12 | 13 | { 14 | 15 | Memcheck:Value8 16 | fun:lzf_compress 17 | } 18 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/a0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_a0) { 4 | void *p; 5 | 6 | p = a0malloc(1); 7 | assert_ptr_not_null(p, "Unexpected a0malloc() error"); 8 | a0dalloc(p); 9 | } 10 | TEST_END 11 | 12 | int 13 | main(void) { 14 | return test_no_malloc_init( 15 | test_a0); 16 | } 17 | -------------------------------------------------------------------------------- /deps/lua/test/fibfor.lua: -------------------------------------------------------------------------------- 1 | -- example of for with generator functions 2 | 3 | function generatefib (n) 4 | return coroutine.wrap(function () 5 | local a,b = 1, 1 6 | while a <= n do 7 | coroutine.yield(a) 8 | a, b = b, a+b 9 | end 10 | end) 11 | end 12 | 13 | for i in generatefib(1000) do print(i) end 14 | -------------------------------------------------------------------------------- /deps/lua/test/readonly.lua: -------------------------------------------------------------------------------- 1 | -- make global variables readonly 2 | 3 | local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end 4 | local g={} 5 | local G=getfenv() 6 | setmetatable(g,{__index=G,__newindex=f}) 7 | setfenv(1,g) 8 | 9 | -- an example 10 | rawset(g,"x",3) 11 | x=2 12 | y=1 -- cannot redefine `y' 13 | -------------------------------------------------------------------------------- /deps/update-jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | VER=$1 3 | URL="http://www.canonware.com/download/jemalloc/jemalloc-${VER}.tar.bz2" 4 | echo "Downloading $URL" 5 | curl $URL > /tmp/jemalloc.tar.bz2 6 | tar xvjf /tmp/jemalloc.tar.bz2 7 | rm -rf jemalloc 8 | mv jemalloc-${VER} jemalloc 9 | echo "Use git status, add all files and commit changes." 10 | -------------------------------------------------------------------------------- /runtest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis test" 12 | exit 1 13 | fi 14 | $TCLSH tests/test_helper.tcl "${@}" 15 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/tsd_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_TSD_TYPES_H 2 | #define JEMALLOC_INTERNAL_TSD_TYPES_H 3 | 4 | #define MALLOC_TSD_CLEANUPS_MAX 2 5 | 6 | typedef struct tsd_s tsd_t; 7 | typedef struct tsdn_s tsdn_t; 8 | typedef bool (*malloc_tsd_cleanup_t)(void); 9 | 10 | #endif /* JEMALLOC_INTERNAL_TSD_TYPES_H */ 11 | -------------------------------------------------------------------------------- /deps/lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /deps/lua/test/table.lua: -------------------------------------------------------------------------------- 1 | -- make table, grouping all data for the same item 2 | -- input is 2 columns (item, data) 3 | 4 | local A 5 | while 1 do 6 | local l=io.read() 7 | if l==nil then break end 8 | local _,_,a,b=string.find(l,'"?([_%w]+)"?%s*(.*)$') 9 | if a~=A then A=a io.write("\n",a,":") end 10 | io.write(" ",b) 11 | end 12 | io.write("\n") 13 | -------------------------------------------------------------------------------- /runtest-cluster: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" 12 | exit 1 13 | fi 14 | $TCLSH tests/cluster/run.tcl $* 15 | -------------------------------------------------------------------------------- /runtest-sentinel: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" 12 | exit 1 13 | fi 14 | $TCLSH tests/sentinel/run.tcl $* 15 | -------------------------------------------------------------------------------- /utils/releasetools/02_upload_tarball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Uploading..." 3 | scp /tmp/redis-${1}.tar.gz antirez@antirez.com:/var/virtual/download.redis.io/httpdocs/releases/ 4 | echo "Updating web site... (press any key if it is a stable release, or Ctrl+C)" 5 | read x 6 | ssh antirez@antirez.com "cd /var/virtual/download.redis.io/httpdocs; ./update.sh ${1}" 7 | -------------------------------------------------------------------------------- /deps/jemalloc/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in autoconf; do 4 | echo "$i" 5 | $i 6 | if [ $? -ne 0 ]; then 7 | echo "Error $? in $i" 8 | exit 1 9 | fi 10 | done 11 | 12 | echo "./configure --enable-autogen $@" 13 | ./configure --enable-autogen $@ 14 | if [ $? -ne 0 ]; then 15 | echo "Error $? in ./configure" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/spin.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/spin.h" 4 | 5 | TEST_BEGIN(test_spin) { 6 | spin_t spinner = SPIN_INITIALIZER; 7 | 8 | for (unsigned i = 0; i < 100; i++) { 9 | spin_adaptive(&spinner); 10 | } 11 | } 12 | TEST_END 13 | 14 | int 15 | main(void) { 16 | return test( 17 | test_spin); 18 | } 19 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/jemalloc_test_defs.h.in: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_internal_defs.h" 2 | #include "jemalloc/internal/jemalloc_internal_decls.h" 3 | 4 | /* 5 | * For use by SFMT. configure.ac doesn't actually define HAVE_SSE2 because its 6 | * dependencies are notoriously unportable in practice. 7 | */ 8 | #undef HAVE_SSE2 9 | #undef HAVE_ALTIVEC 10 | -------------------------------------------------------------------------------- /deps/hiredis/hiredis_ssl.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | pkgincludedir=${includedir}/hiredis 6 | 7 | Name: hiredis_ssl 8 | Description: SSL Support for hiredis. 9 | Version: @PROJECT_VERSION@ 10 | Requires: hiredis 11 | Libs: -L${libdir} -lhiredis_ssl 12 | Libs.private: -lssl -lcrypto 13 | -------------------------------------------------------------------------------- /deps/lua/test/cf.lua: -------------------------------------------------------------------------------- 1 | -- temperature conversion table (celsius to farenheit) 2 | 3 | for c0=-20,50-1,10 do 4 | io.write("C ") 5 | for c=c0,c0+10-1 do 6 | io.write(string.format("%3.0f ",c)) 7 | end 8 | io.write("\n") 9 | 10 | io.write("F ") 11 | for c=c0,c0+10-1 do 12 | f=(9/5)*c+32 13 | io.write(string.format("%3.0f ",f)) 14 | end 15 | io.write("\n\n") 16 | end 17 | -------------------------------------------------------------------------------- /deps/hiredis/hiredis.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | pkgincludedir=${includedir}/hiredis 6 | 7 | Name: hiredis 8 | Description: Minimalistic C client library for Redis. 9 | Version: @PROJECT_VERSION@ 10 | Libs: -L${libdir} -lhiredis 11 | Cflags: -I${pkgincludedir} -D_FILE_OFFSET_BITS=64 12 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/arena_structs_a.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H 2 | #define JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H 3 | 4 | #include "jemalloc/internal/bitmap.h" 5 | 6 | struct arena_slab_data_s { 7 | /* Per region allocated/deallocated bitmap. */ 8 | bitmap_t bitmap[BITMAP_GROUPS_MAX]; 9 | }; 10 | 11 | #endif /* JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H */ 12 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/timer.h: -------------------------------------------------------------------------------- 1 | /* Simple timer, for use in benchmark reporting. */ 2 | 3 | typedef struct { 4 | nstime_t t0; 5 | nstime_t t1; 6 | } timedelta_t; 7 | 8 | void timer_start(timedelta_t *timer); 9 | void timer_stop(timedelta_t *timer); 10 | uint64_t timer_usec(const timedelta_t *timer); 11 | void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen); 12 | -------------------------------------------------------------------------------- /tests/helpers/bg_complex_data.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | source tests/support/util.tcl 3 | 4 | set ::tlsdir "tests/tls" 5 | 6 | proc bg_complex_data {host port db ops tls} { 7 | set r [redis $host $port 0 $tls] 8 | $r select $db 9 | createComplexDataset $r $ops 10 | } 11 | 12 | bg_complex_data [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] 13 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/base_inlines.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BASE_INLINES_H 2 | #define JEMALLOC_INTERNAL_BASE_INLINES_H 3 | 4 | static inline unsigned 5 | base_ind_get(const base_t *base) { 6 | return base->ind; 7 | } 8 | 9 | static inline bool 10 | metadata_thp_enabled(void) { 11 | return (opt_metadata_thp != metadata_thp_disabled); 12 | } 13 | #endif /* JEMALLOC_INTERNAL_BASE_INLINES_H */ 14 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/extent_mmap.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 3 | 4 | extern bool opt_retain; 5 | 6 | void *extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, 7 | bool *zero, bool *commit); 8 | bool extent_dalloc_mmap(void *addr, size_t size); 9 | 10 | #endif /* JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H */ 11 | -------------------------------------------------------------------------------- /utils/releasetools/01_create_tarball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ $# != "1" ] 3 | then 4 | echo "Usage: ./mkrelease.sh " 5 | exit 1 6 | fi 7 | 8 | TAG=$1 9 | TARNAME="redis-${TAG}.tar" 10 | echo "Generating /tmp/${TARNAME}" 11 | cd ~/hack/redis 12 | git archive $TAG --prefix redis-${TAG}/ > /tmp/$TARNAME || exit 1 13 | echo "Gizipping the archive" 14 | rm -f /tmp/$TARNAME.gz 15 | gzip -9 /tmp/$TARNAME 16 | -------------------------------------------------------------------------------- /deps/linenoise/Makefile: -------------------------------------------------------------------------------- 1 | STD= 2 | WARN= -Wall 3 | OPT= -Os 4 | 5 | R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) 6 | R_LDFLAGS= $(LDFLAGS) 7 | DEBUG= -g 8 | 9 | R_CC=$(CC) $(R_CFLAGS) 10 | R_LD=$(CC) $(R_LDFLAGS) 11 | 12 | linenoise.o: linenoise.h linenoise.c 13 | 14 | linenoise_example: linenoise.o example.o 15 | $(R_LD) -o $@ $^ 16 | 17 | .c.o: 18 | $(R_CC) -c $< 19 | 20 | clean: 21 | rm -f linenoise_example *.o 22 | -------------------------------------------------------------------------------- /deps/lua/test/xd.lua: -------------------------------------------------------------------------------- 1 | -- hex dump 2 | -- usage: lua xd.lua < file 3 | 4 | local offset=0 5 | while true do 6 | local s=io.read(16) 7 | if s==nil then return end 8 | io.write(string.format("%08X ",offset)) 9 | string.gsub(s,"(.)", 10 | function (c) io.write(string.format("%02X ",string.byte(c))) end) 11 | io.write(string.rep(" ",3*(16-string.len(s)))) 12 | io.write(" ",string.gsub(s,"%c","."),"\n") 13 | offset=offset+16 14 | end 15 | -------------------------------------------------------------------------------- /utils/releasetools/04_release_hash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SHA=$(curl -s http://download.redis.io/releases/redis-${1}.tar.gz | shasum -a 256 | cut -f 1 -d' ') 3 | ENTRY="hash redis-${1}.tar.gz sha256 $SHA http://download.redis.io/releases/redis-${1}.tar.gz" 4 | echo $ENTRY >> ~/hack/redis-hashes/README 5 | vi ~/hack/redis-hashes/README 6 | echo "Press any key to commit, Ctrl-C to abort)." 7 | read yes 8 | (cd ~/hack/redis-hashes; git commit -a -m "${1} hash."; git push) 9 | -------------------------------------------------------------------------------- /deps/jemalloc/src/hooks.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | 3 | /* 4 | * The hooks are a little bit screwy -- they're not genuinely exported in the 5 | * sense that we want them available to end-users, but we do want them visible 6 | * from outside the generated library, so that we can use them in test code. 7 | */ 8 | JEMALLOC_EXPORT 9 | void (*hooks_arena_new_hook)() = NULL; 10 | 11 | JEMALLOC_EXPORT 12 | void (*hooks_libc_hook)() = NULL; 13 | -------------------------------------------------------------------------------- /deps/lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 30px ; 22 | margin-left: -30px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /utils/hashtable/README: -------------------------------------------------------------------------------- 1 | Hash table implementation related utilities. 2 | 3 | rehashing.c 4 | --- 5 | 6 | Visually show buckets in the two hash tables between rehashings. Also stress 7 | test getRandomKeys() implementation, that may actually disappear from 8 | Redis soon, however visualization some code is reusable in new bugs 9 | investigation. 10 | 11 | Compile with: 12 | 13 | cc -I ../../src/ rehashing.c ../../src/zmalloc.c ../../src/dict.c -o rehashing_test 14 | -------------------------------------------------------------------------------- /deps/jemalloc/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/support/tmpfile.tcl: -------------------------------------------------------------------------------- 1 | set ::tmpcounter 0 2 | set ::tmproot "./tests/tmp" 3 | file mkdir $::tmproot 4 | 5 | # returns a dirname unique to this process to write to 6 | proc tmpdir {basename} { 7 | set dir [file join $::tmproot $basename.[pid].[incr ::tmpcounter]] 8 | file mkdir $dir 9 | set _ $dir 10 | } 11 | 12 | # return a filename unique to this process to write to 13 | proc tmpfile {basename} { 14 | file join $::tmproot $basename.[pid].[incr ::tmpcounter] 15 | } 16 | -------------------------------------------------------------------------------- /deps/lua/test/globals.lua: -------------------------------------------------------------------------------- 1 | -- reads luac listings and reports global variable usage 2 | -- lines where a global is written to are marked with "*" 3 | -- typical usage: luac -p -l file.lua | lua globals.lua | sort | lua table.lua 4 | 5 | while 1 do 6 | local s=io.read() 7 | if s==nil then break end 8 | local ok,_,l,op,g=string.find(s,"%[%-?(%d*)%]%s*([GS])ETGLOBAL.-;%s+(.*)$") 9 | if ok then 10 | if op=="S" then op="*" else op="" end 11 | io.write(g,"\t",l,op,"\n") 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /src/geo.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEO_H__ 2 | #define __GEO_H__ 3 | 4 | #include "server.h" 5 | 6 | /* Structures used inside geo.c in order to represent points and array of 7 | * points on the earth. */ 8 | typedef struct geoPoint { 9 | double longitude; 10 | double latitude; 11 | double dist; 12 | double score; 13 | char *member; 14 | } geoPoint; 15 | 16 | typedef struct geoArray { 17 | struct geoPoint *array; 18 | size_t buckets; 19 | size_t used; 20 | } geoArray; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tests/helpers/gen_write_load.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | 3 | set ::tlsdir "tests/tls" 4 | 5 | proc gen_write_load {host port seconds tls} { 6 | set start_time [clock seconds] 7 | set r [redis $host $port 1 $tls] 8 | $r select 9 9 | while 1 { 10 | $r set [expr rand()] [expr rand()] 11 | if {[clock seconds]-$start_time > $seconds} { 12 | exit 0 13 | } 14 | } 15 | } 16 | 17 | gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] 18 | -------------------------------------------------------------------------------- /deps/jemalloc/jemalloc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | install_suffix=@install_suffix@ 6 | 7 | Name: jemalloc 8 | Description: A general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. 9 | URL: http://jemalloc.net/ 10 | Version: @jemalloc_version_major@.@jemalloc_version_minor@.@jemalloc_version_bugfix@_@jemalloc_version_nrev@ 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -ljemalloc${install_suffix} 13 | -------------------------------------------------------------------------------- /utils/srandmember/showfreq.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 500.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Print the frequency each element was yeld to process it with gnuplot 21 | freq.each{|item,count| 22 | puts "#{item} #{count}" 23 | } 24 | -------------------------------------------------------------------------------- /tests/assets/default.conf: -------------------------------------------------------------------------------- 1 | # Redis configuration for testing. 2 | 3 | always-show-logo yes 4 | notify-keyspace-events KEA 5 | daemonize no 6 | pidfile /var/run/redis.pid 7 | port 6379 8 | timeout 0 9 | bind 127.0.0.1 10 | loglevel verbose 11 | logfile '' 12 | databases 16 13 | latency-monitor-threshold 1 14 | 15 | save 900 1 16 | save 300 10 17 | save 60 10000 18 | 19 | rdbcompression yes 20 | dbfilename dump.rdb 21 | dir ./ 22 | 23 | slave-serve-stale-data yes 24 | appendonly no 25 | appendfsync everysec 26 | no-appendfsync-on-rewrite no 27 | activerehashing yes 28 | -------------------------------------------------------------------------------- /tests/cluster/tests/helpers/onlydots.tcl: -------------------------------------------------------------------------------- 1 | # Read the standard input and only shows dots in the output, filtering out 2 | # all the other characters. Designed to avoid bufferization so that when 3 | # we get the output of redis-trib and want to show just the dots, we'll see 4 | # the dots as soon as redis-trib will output them. 5 | 6 | fconfigure stdin -buffering none 7 | 8 | while 1 { 9 | set c [read stdin 1] 10 | if {$c eq {}} { 11 | exit 0; # EOF 12 | } elseif {$c eq {.}} { 13 | puts -nonewline . 14 | flush stdout 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.o 3 | *.xo 4 | *.so 5 | *.d 6 | *.log 7 | dump.rdb 8 | redis-benchmark 9 | redis-check-aof 10 | redis-check-rdb 11 | redis-check-dump 12 | redis-cli 13 | redis-sentinel 14 | redis-server 15 | doc-tools 16 | release 17 | misc/* 18 | src/release.h 19 | appendonly.aof 20 | SHORT_TERM_TODO 21 | release.h 22 | src/transfer.sh 23 | src/configs 24 | redis.ds 25 | src/redis.conf 26 | src/nodes.conf 27 | deps/lua/src/lua 28 | deps/lua/src/luac 29 | deps/lua/src/liblua.a 30 | .make-* 31 | .prerequisites 32 | *.dSYM 33 | Makefile.dep 34 | .vscode/* 35 | .idea/* 36 | -------------------------------------------------------------------------------- /deps/jemalloc/include/msvc_compat/C99/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef stdbool_h 2 | #define stdbool_h 3 | 4 | #include 5 | 6 | /* MSVC doesn't define _Bool or bool in C, but does have BOOL */ 7 | /* Note this doesn't pass autoconf's test because (bool) 0.5 != true */ 8 | /* Clang-cl uses MSVC headers, so needs msvc_compat, but has _Bool as 9 | * a built-in type. */ 10 | #ifndef __clang__ 11 | typedef BOOL _Bool; 12 | #endif 13 | 14 | #define bool _Bool 15 | #define true 1 16 | #define false 0 17 | 18 | #define __bool_true_false_are_defined 1 19 | 20 | #endif /* stdbool_h */ 21 | -------------------------------------------------------------------------------- /deps/jemalloc/src/mutex_pool.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MUTEX_POOL_C_ 2 | 3 | #include "jemalloc/internal/jemalloc_preamble.h" 4 | #include "jemalloc/internal/jemalloc_internal_includes.h" 5 | 6 | #include "jemalloc/internal/mutex.h" 7 | #include "jemalloc/internal/mutex_pool.h" 8 | 9 | bool 10 | mutex_pool_init(mutex_pool_t *pool, const char *name, witness_rank_t rank) { 11 | for (int i = 0; i < MUTEX_POOL_SIZE; ++i) { 12 | if (malloc_mutex_init(&pool->mutexes[i], name, rank, 13 | malloc_mutex_address_ordered)) { 14 | return true; 15 | } 16 | } 17 | return false; 18 | } 19 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/cpp/basic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test/jemalloc_test.h" 3 | 4 | TEST_BEGIN(test_basic) { 5 | auto foo = new long(4); 6 | assert_ptr_not_null(foo, "Unexpected new[] failure"); 7 | delete foo; 8 | // Test nullptr handling. 9 | foo = nullptr; 10 | delete foo; 11 | 12 | auto bar = new long; 13 | assert_ptr_not_null(bar, "Unexpected new failure"); 14 | delete bar; 15 | // Test nullptr handling. 16 | bar = nullptr; 17 | delete bar; 18 | } 19 | TEST_END 20 | 21 | int 22 | main() { 23 | return test( 24 | test_basic); 25 | } 26 | -------------------------------------------------------------------------------- /tests/support/cli.tcl: -------------------------------------------------------------------------------- 1 | proc rediscli_tls_config {testsdir} { 2 | set tlsdir [file join $testsdir tls] 3 | set cert [file join $tlsdir redis.crt] 4 | set key [file join $tlsdir redis.key] 5 | set cacert [file join $tlsdir ca.crt] 6 | 7 | if {$::tls} { 8 | return [list --tls --cert $cert --key $key --cacert $cacert] 9 | } else { 10 | return {} 11 | } 12 | } 13 | 14 | proc rediscli {port {opts {}}} { 15 | set cmd [list src/redis-cli -p $port] 16 | lappend cmd {*}[rediscli_tls_config "tests"] 17 | lappend cmd {*}$opts 18 | return $cmd 19 | } 20 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/jemalloc_rename.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | public_symbols_txt=$1 4 | 5 | cat < 8 && $c <= 10} 19 | set e 20 | } $expected_code 21 | } 22 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | How to build jemalloc for Windows 3 | ================================= 4 | 5 | 1. Install Cygwin with at least the following packages: 6 | * autoconf 7 | * autogen 8 | * gawk 9 | * grep 10 | * sed 11 | 12 | 2. Install Visual Studio 2015 or 2017 with Visual C++ 13 | 14 | 3. Add Cygwin\bin to the PATH environment variable 15 | 16 | 4. Open "x64 Native Tools Command Prompt for VS 2017" 17 | (note: x86/x64 doesn't matter at this point) 18 | 19 | 5. Generate header files: 20 | sh -c "CC=cl ./autogen.sh" 21 | 22 | 6. Now the project can be opened and built in Visual Studio: 23 | msvc\jemalloc_vc2017.sln 24 | -------------------------------------------------------------------------------- /src/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef SHA1_H 2 | #define SHA1_H 3 | /* ================ sha1.h ================ */ 4 | /* 5 | SHA-1 in C 6 | By Steve Reid 7 | 100% Public Domain 8 | */ 9 | 10 | typedef struct { 11 | uint32_t state[5]; 12 | uint32_t count[2]; 13 | unsigned char buffer[64]; 14 | } SHA1_CTX; 15 | 16 | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]); 17 | void SHA1Init(SHA1_CTX* context); 18 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len); 19 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 20 | 21 | #ifdef REDIS_TEST 22 | int sha1Test(int argc, char **argv); 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /utils/srandmember/README.md: -------------------------------------------------------------------------------- 1 | The utilities in this directory plot the distribution of SRANDMEMBER to 2 | evaluate how fair it is. 3 | 4 | See http://theshfl.com/redis_sets for more information on the topic that lead 5 | to such investigation fix. 6 | 7 | showdist.rb -- shows the distribution of the frequency elements are returned. 8 | The x axis is the number of times elements were returned, and 9 | the y axis is how many elements were returned with such 10 | frequency. 11 | 12 | showfreq.rb -- shows the frequency each element was returned. 13 | The x axis is the element number. 14 | The y axis is the times it was returned. 15 | -------------------------------------------------------------------------------- /tests/sentinel/run.tcl: -------------------------------------------------------------------------------- 1 | # Sentinel test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com 2 | # This software is released under the BSD License. See the COPYING file for 3 | # more information. 4 | 5 | cd tests/sentinel 6 | source ../instances.tcl 7 | 8 | set ::instances_count 5 ; # How many instances we use at max. 9 | set ::tlsdir "../../tls" 10 | 11 | proc main {} { 12 | parse_options 13 | spawn_instance sentinel $::sentinel_base_port $::instances_count 14 | spawn_instance redis $::redis_base_port $::instances_count 15 | run_tests 16 | cleanup 17 | end_tests 18 | } 19 | 20 | if {[catch main e]} { 21 | puts $::errorInfo 22 | cleanup 23 | exit 1 24 | } 25 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/mtx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mtx is a slightly simplified version of malloc_mutex. This code duplication 3 | * is unfortunate, but there are allocator bootstrapping considerations that 4 | * would leak into the test infrastructure if malloc_mutex were used directly 5 | * in tests. 6 | */ 7 | 8 | typedef struct { 9 | #ifdef _WIN32 10 | CRITICAL_SECTION lock; 11 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 12 | os_unfair_lock lock; 13 | #elif (defined(JEMALLOC_OSSPIN)) 14 | OSSpinLock lock; 15 | #else 16 | pthread_mutex_t lock; 17 | #endif 18 | } mtx_t; 19 | 20 | bool mtx_init(mtx_t *mtx); 21 | void mtx_fini(mtx_t *mtx); 22 | void mtx_lock(mtx_t *mtx); 23 | void mtx_unlock(mtx_t *mtx); 24 | -------------------------------------------------------------------------------- /utils/build-static-symbols.tcl: -------------------------------------------------------------------------------- 1 | # Build a symbol table for static symbols of redis.c 2 | # Useful to get stack traces on segfault without a debugger. See redis.c 3 | # for more information. 4 | # 5 | # Copyright(C) 2009 Salvatore Sanfilippo, under the BSD license. 6 | 7 | set fd [open redis.c] 8 | set symlist {} 9 | while {[gets $fd line] != -1} { 10 | if {[regexp {^static +[A-z0-9]+[ *]+([A-z0-9]*)\(} $line - sym]} { 11 | lappend symlist $sym 12 | } 13 | } 14 | set symlist [lsort -unique $symlist] 15 | puts "static struct redisFunctionSym symsTable\[\] = {" 16 | foreach sym $symlist { 17 | puts "{\"$sym\",(unsigned long)$sym}," 18 | } 19 | puts "{NULL,0}" 20 | puts "};" 21 | 22 | close $fd 23 | -------------------------------------------------------------------------------- /utils/srandmember/showdist.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 100.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Convert into frequency distribution 21 | dist = {} 22 | freq.each{|item,count| 23 | dist[count] = 0 if dist[count] == nil 24 | dist[count] += 1 25 | } 26 | 27 | min = dist.keys.min 28 | max = dist.keys.max 29 | (min..max).each{|x| 30 | count = dist[x] 31 | count = 0 if count == nil 32 | puts "#{x} -> #{"*"*count}" 33 | } 34 | -------------------------------------------------------------------------------- /utils/gen-test-certs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p tests/tls 3 | openssl genrsa -out tests/tls/ca.key 4096 4 | openssl req \ 5 | -x509 -new -nodes -sha256 \ 6 | -key tests/tls/ca.key \ 7 | -days 3650 \ 8 | -subj '/O=Redis Test/CN=Certificate Authority' \ 9 | -out tests/tls/ca.crt 10 | openssl genrsa -out tests/tls/redis.key 2048 11 | openssl req \ 12 | -new -sha256 \ 13 | -key tests/tls/redis.key \ 14 | -subj '/O=Redis Test/CN=Server' | \ 15 | openssl x509 \ 16 | -req -sha256 \ 17 | -CA tests/tls/ca.crt \ 18 | -CAkey tests/tls/ca.key \ 19 | -CAserial tests/tls/ca.txt \ 20 | -CAcreateserial \ 21 | -days 365 \ 22 | -out tests/tls/redis.crt 23 | openssl dhparam -out tests/tls/redis.dh 2048 24 | -------------------------------------------------------------------------------- /utils/hyperloglog/hll-err.rb: -------------------------------------------------------------------------------- 1 | # hll-err.rb - Copyright (C) 2014 Salvatore Sanfilippo 2 | # BSD license, See the COPYING file for more information. 3 | # 4 | # Check error of HyperLogLog Redis implementation for different set sizes. 5 | 6 | require 'rubygems' 7 | require 'redis' 8 | require 'digest/sha1' 9 | 10 | r = Redis.new 11 | r.del('hll') 12 | i = 0 13 | while true do 14 | 100.times { 15 | elements = [] 16 | 1000.times { 17 | ele = Digest::SHA1.hexdigest(i.to_s) 18 | elements << ele 19 | i += 1 20 | } 21 | r.pfadd('hll',elements) 22 | } 23 | approx = r.pfcount('hll') 24 | abs_err = (approx-i).abs 25 | rel_err = 100.to_f*abs_err/i 26 | puts "#{i} vs #{approx}: #{rel_err}%" 27 | end 28 | -------------------------------------------------------------------------------- /deps/lua/test/bisect.lua: -------------------------------------------------------------------------------- 1 | -- bisection method for solving non-linear equations 2 | 3 | delta=1e-6 -- tolerance 4 | 5 | function bisect(f,a,b,fa,fb) 6 | local c=(a+b)/2 7 | io.write(n," c=",c," a=",a," b=",b,"\n") 8 | if c==a or c==b or math.abs(a-b) 5 | 6 | class ExampleQt : public QObject { 7 | 8 | Q_OBJECT 9 | 10 | public: 11 | ExampleQt(const char * value, QObject * parent = 0) 12 | : QObject(parent), m_value(value) {} 13 | 14 | signals: 15 | void finished(); 16 | 17 | public slots: 18 | void run(); 19 | 20 | private: 21 | void finish() { emit finished(); } 22 | 23 | private: 24 | const char * m_value; 25 | redisAsyncContext * m_ctx; 26 | RedisQtAdapter m_adapter; 27 | 28 | friend 29 | void getCallback(redisAsyncContext *, void *, void *); 30 | }; 31 | 32 | #endif /* !__HIREDIS_EXAMPLE_QT_H */ 33 | -------------------------------------------------------------------------------- /utils/graphs/commits-over-time/README.md: -------------------------------------------------------------------------------- 1 | This Tcl script is what I used in order to generate the graph you 2 | can find at http://antirez.com/news/98. It's really quick & dirty, more 3 | a trow away program than anything else, but probably could be reused or 4 | modified in the future in order to visualize other similar data or an 5 | updated version of the same data. 6 | 7 | The usage is trivial: 8 | 9 | ./genhtml.tcl > output.html 10 | 11 | The generated HTML is quite broken but good enough to grab a screenshot 12 | from the browser. Feel free to improve it if you got time / interest. 13 | 14 | Note that the code filtering the tags, and the hardcoded branch name, does 15 | not make the script, as it is, able to analyze a different repository. 16 | However the changes needed are trivial. 17 | -------------------------------------------------------------------------------- /deps/lua/test/fib.lua: -------------------------------------------------------------------------------- 1 | -- fibonacci function with cache 2 | 3 | -- very inefficient fibonacci function 4 | function fib(n) 5 | N=N+1 6 | if n<2 then 7 | return n 8 | else 9 | return fib(n-1)+fib(n-2) 10 | end 11 | end 12 | 13 | -- a general-purpose value cache 14 | function cache(f) 15 | local c={} 16 | return function (x) 17 | local y=c[x] 18 | if not y then 19 | y=f(x) 20 | c[x]=y 21 | end 22 | return y 23 | end 24 | end 25 | 26 | -- run and time it 27 | function test(s,f) 28 | N=0 29 | local c=os.clock() 30 | local v=f(n) 31 | local t=os.clock()-c 32 | print(s,n,v,t,N) 33 | end 34 | 35 | n=arg[1] or 24 -- for other values, do lua fib.lua XX 36 | n=tonumber(n) 37 | print("","n","value","time","evals") 38 | test("plain",fib) 39 | fib=cache(fib) 40 | test("cached",fib) 41 | -------------------------------------------------------------------------------- /src/mkreleasehdr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1` 3 | GIT_DIRTY=`git diff --no-ext-diff 2> /dev/null | wc -l` 4 | BUILD_ID=`uname -n`"-"`date +%s` 5 | if [ -n "$SOURCE_DATE_EPOCH" ]; then 6 | BUILD_ID=$(date -u -d "@$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u +%s) 7 | fi 8 | test -f release.h || touch release.h 9 | (cat release.h | grep SHA1 | grep $GIT_SHA1) && \ 10 | (cat release.h | grep DIRTY | grep $GIT_DIRTY) && exit 0 # Already up-to-date 11 | echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h 12 | echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h 13 | echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h 14 | touch release.c # Force recompile of release.c 15 | -------------------------------------------------------------------------------- /deps/lua/etc/lua.pc: -------------------------------------------------------------------------------- 1 | # lua.pc -- pkg-config data for Lua 2 | 3 | # vars from install Makefile 4 | 5 | # grep '^V=' ../Makefile 6 | V= 5.1 7 | # grep '^R=' ../Makefile 8 | R= 5.1.5 9 | 10 | # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' 11 | prefix= /usr/local 12 | INSTALL_BIN= ${prefix}/bin 13 | INSTALL_INC= ${prefix}/include 14 | INSTALL_LIB= ${prefix}/lib 15 | INSTALL_MAN= ${prefix}/man/man1 16 | INSTALL_LMOD= ${prefix}/share/lua/${V} 17 | INSTALL_CMOD= ${prefix}/lib/lua/${V} 18 | 19 | # canonical vars 20 | exec_prefix=${prefix} 21 | libdir=${exec_prefix}/lib 22 | includedir=${prefix}/include 23 | 24 | Name: Lua 25 | Description: An Extensible Extension Language 26 | Version: ${R} 27 | Requires: 28 | Libs: -L${libdir} -llua -lm 29 | Cflags: -I${includedir} 30 | 31 | # (end of lua.pc) 32 | -------------------------------------------------------------------------------- /runtest-moduleapi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis test" 12 | exit 1 13 | fi 14 | 15 | make -C tests/modules && \ 16 | $TCLSH tests/test_helper.tcl \ 17 | --single unit/moduleapi/commandfilter \ 18 | --single unit/moduleapi/fork \ 19 | --single unit/moduleapi/testrdb \ 20 | --single unit/moduleapi/infotest \ 21 | --single unit/moduleapi/propagate \ 22 | --single unit/moduleapi/hooks \ 23 | --single unit/moduleapi/misc \ 24 | --single unit/moduleapi/blockonkeys \ 25 | --single unit/moduleapi/scan \ 26 | --single unit/moduleapi/datatype \ 27 | --single unit/moduleapi/auth \ 28 | "${@}" 29 | -------------------------------------------------------------------------------- /utils/whatisdoing.sh: -------------------------------------------------------------------------------- 1 | # This script is from http://poormansprofiler.org/ 2 | # 3 | # NOTE: Instead of using this script, you should use the Redis 4 | # Software Watchdog, which provides a similar functionality but in 5 | # a more reliable / easy to use way. 6 | # 7 | # Check http://redis.io/topics/latency for more information. 8 | 9 | #!/bin/bash 10 | nsamples=1 11 | sleeptime=0 12 | pid=$(ps auxww | grep '[r]edis-server' | awk '{print $2}') 13 | 14 | for x in $(seq 1 $nsamples) 15 | do 16 | gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid 17 | sleep $sleeptime 18 | done | \ 19 | awk ' 20 | BEGIN { s = ""; } 21 | /Thread/ { print s; s = ""; } 22 | /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } } 23 | END { print s }' | \ 24 | sort | uniq -c | sort -r -n -k 1,1 25 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/spin.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_SPIN_H 2 | #define JEMALLOC_INTERNAL_SPIN_H 3 | 4 | #define SPIN_INITIALIZER {0U} 5 | 6 | typedef struct { 7 | unsigned iteration; 8 | } spin_t; 9 | 10 | static inline void 11 | spin_cpu_spinwait() { 12 | # if HAVE_CPU_SPINWAIT 13 | CPU_SPINWAIT; 14 | # else 15 | volatile int x = 0; 16 | x = x; 17 | # endif 18 | } 19 | 20 | static inline void 21 | spin_adaptive(spin_t *spin) { 22 | volatile uint32_t i; 23 | 24 | if (spin->iteration < 5) { 25 | for (i = 0; i < (1U << spin->iteration); i++) { 26 | spin_cpu_spinwait(); 27 | } 28 | spin->iteration++; 29 | } else { 30 | #ifdef _WIN32 31 | SwitchToThread(); 32 | #else 33 | sched_yield(); 34 | #endif 35 | } 36 | } 37 | 38 | #undef SPIN_INLINE 39 | 40 | #endif /* JEMALLOC_INTERNAL_SPIN_H */ 41 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/div.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/div.h" 4 | 5 | TEST_BEGIN(test_div_exhaustive) { 6 | for (size_t divisor = 2; divisor < 1000 * 1000; ++divisor) { 7 | div_info_t div_info; 8 | div_init(&div_info, divisor); 9 | size_t max = 1000 * divisor; 10 | if (max < 1000 * 1000) { 11 | max = 1000 * 1000; 12 | } 13 | for (size_t dividend = 0; dividend < 1000 * divisor; 14 | dividend += divisor) { 15 | size_t quotient = div_compute( 16 | &div_info, dividend); 17 | assert_zu_eq(dividend, quotient * divisor, 18 | "With divisor = %zu, dividend = %zu, " 19 | "got quotient %zu", divisor, dividend, quotient); 20 | } 21 | } 22 | } 23 | TEST_END 24 | 25 | int 26 | main(void) { 27 | return test_no_reentrancy( 28 | test_div_exhaustive); 29 | } 30 | -------------------------------------------------------------------------------- /tests/cluster/run.tcl: -------------------------------------------------------------------------------- 1 | # Cluster test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com 2 | # This software is released under the BSD License. See the COPYING file for 3 | # more information. 4 | 5 | cd tests/cluster 6 | source cluster.tcl 7 | source ../instances.tcl 8 | source ../../support/cluster.tcl ; # Redis Cluster client. 9 | 10 | set ::instances_count 20 ; # How many instances we use at max. 11 | set ::tlsdir "../../tls" 12 | 13 | proc main {} { 14 | parse_options 15 | spawn_instance redis $::redis_base_port $::instances_count { 16 | "cluster-enabled yes" 17 | "appendonly yes" 18 | } 19 | run_tests 20 | cleanup 21 | end_tests 22 | } 23 | 24 | if {[catch main e]} { 25 | puts $::errorInfo 26 | if {$::pause_on_error} pause_on_error 27 | cleanup 28 | exit 1 29 | } 30 | -------------------------------------------------------------------------------- /utils/lru/README: -------------------------------------------------------------------------------- 1 | The test-lru.rb program can be used in order to check the behavior of the 2 | Redis approximated LRU algorithm against the theoretical output of true 3 | LRU algorithm. 4 | 5 | In order to use the program you need to recompile Redis setting the define 6 | REDIS_LRU_CLOCK_RESOLUTION to 1, by editing the file server.h. 7 | This allows to execute the program in a fast way since the 1 ms resolution 8 | is enough for all the objects to have a different enough time stamp during 9 | the test. 10 | 11 | The program is executed like this: 12 | 13 | ruby test-lru.rb /tmp/lru.html 14 | 15 | You can optionally specify a number of times to run, so that the program 16 | will output averages of different runs, by adding an additional argument. 17 | For instance in order to run the test 10 times use: 18 | 19 | ruby test-lru.rb /tmp/lru.html 10 20 | -------------------------------------------------------------------------------- /deps/lua/etc/all.c: -------------------------------------------------------------------------------- 1 | /* 2 | * all.c -- Lua core, libraries and interpreter in a single file 3 | */ 4 | 5 | #define luaall_c 6 | 7 | #include "lapi.c" 8 | #include "lcode.c" 9 | #include "ldebug.c" 10 | #include "ldo.c" 11 | #include "ldump.c" 12 | #include "lfunc.c" 13 | #include "lgc.c" 14 | #include "llex.c" 15 | #include "lmem.c" 16 | #include "lobject.c" 17 | #include "lopcodes.c" 18 | #include "lparser.c" 19 | #include "lstate.c" 20 | #include "lstring.c" 21 | #include "ltable.c" 22 | #include "ltm.c" 23 | #include "lundump.c" 24 | #include "lvm.c" 25 | #include "lzio.c" 26 | 27 | #include "lauxlib.c" 28 | #include "lbaselib.c" 29 | #include "ldblib.c" 30 | #include "liolib.c" 31 | #include "linit.c" 32 | #include "lmathlib.c" 33 | #include "loadlib.c" 34 | #include "loslib.c" 35 | #include "lstrlib.c" 36 | #include "ltablib.c" 37 | 38 | #include "lua.c" 39 | -------------------------------------------------------------------------------- /deps/hiredis/appveyor.yml: -------------------------------------------------------------------------------- 1 | # Appveyor configuration file for CI build of hiredis on Windows (under Cygwin) 2 | environment: 3 | matrix: 4 | - CYG_BASH: C:\cygwin64\bin\bash 5 | CC: gcc 6 | - CYG_BASH: C:\cygwin\bin\bash 7 | CC: gcc 8 | CFLAGS: -m32 9 | CXXFLAGS: -m32 10 | LDFLAGS: -m32 11 | 12 | clone_depth: 1 13 | 14 | # Attempt to ensure we don't try to convert line endings to Win32 CRLF as this will cause build to fail 15 | init: 16 | - git config --global core.autocrlf input 17 | 18 | # Install needed build dependencies 19 | install: 20 | - '%CYG_BASH% -lc "cygcheck -dc cygwin"' 21 | 22 | build_script: 23 | - 'echo building...' 24 | - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0" 5 | exit 1 6 | fi 7 | 8 | TAG=$1 9 | TARNAME="redis-${TAG}.tar.gz" 10 | DOWNLOADURL="http://download.redis.io/releases/${TARNAME}" 11 | 12 | ssh antirez@metal "export TERM=xterm; 13 | cd /tmp; 14 | rm -rf test_release_tmp_dir; 15 | cd test_release_tmp_dir; 16 | rm -f $TARNAME; 17 | rm -rf redis-${TAG}; 18 | wget $DOWNLOADURL; 19 | tar xvzf $TARNAME; 20 | cd redis-${TAG}; 21 | make; 22 | ./runtest; 23 | ./runtest-sentinel; 24 | if [ -x runtest-cluster ]; then 25 | ./runtest-cluster; 26 | fi" 27 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/extent_dss.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_DSS_H 2 | #define JEMALLOC_INTERNAL_EXTENT_DSS_H 3 | 4 | typedef enum { 5 | dss_prec_disabled = 0, 6 | dss_prec_primary = 1, 7 | dss_prec_secondary = 2, 8 | 9 | dss_prec_limit = 3 10 | } dss_prec_t; 11 | #define DSS_PREC_DEFAULT dss_prec_secondary 12 | #define DSS_DEFAULT "secondary" 13 | 14 | extern const char *dss_prec_names[]; 15 | 16 | extern const char *opt_dss; 17 | 18 | dss_prec_t extent_dss_prec_get(void); 19 | bool extent_dss_prec_set(dss_prec_t dss_prec); 20 | void *extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, 21 | size_t size, size_t alignment, bool *zero, bool *commit); 22 | bool extent_in_dss(void *addr); 23 | bool extent_dss_mergeable(void *addr_a, void *addr_b); 24 | void extent_dss_boot(void); 25 | 26 | #endif /* JEMALLOC_INTERNAL_EXTENT_DSS_H */ 27 | -------------------------------------------------------------------------------- /deps/lua/test/sieve.lua: -------------------------------------------------------------------------------- 1 | -- the sieve of of Eratosthenes programmed with coroutines 2 | -- typical usage: lua -e N=1000 sieve.lua | column 3 | 4 | -- generate all the numbers from 2 to n 5 | function gen (n) 6 | return coroutine.wrap(function () 7 | for i=2,n do coroutine.yield(i) end 8 | end) 9 | end 10 | 11 | -- filter the numbers generated by `g', removing multiples of `p' 12 | function filter (p, g) 13 | return coroutine.wrap(function () 14 | while 1 do 15 | local n = g() 16 | if n == nil then return end 17 | if math.mod(n, p) ~= 0 then coroutine.yield(n) end 18 | end 19 | end) 20 | end 21 | 22 | N=N or 1000 -- from command line 23 | x = gen(N) -- generate primes up to N 24 | while 1 do 25 | local n = x() -- pick a number until done 26 | if n == nil then break end 27 | print(n) -- must be a prime number 28 | x = filter(n, x) -- now remove its multiples 29 | end 30 | -------------------------------------------------------------------------------- /deps/lua/test/trace-calls.lua: -------------------------------------------------------------------------------- 1 | -- trace calls 2 | -- example: lua -ltrace-calls bisect.lua 3 | 4 | local level=0 5 | 6 | local function hook(event) 7 | local t=debug.getinfo(3) 8 | io.write(level," >>> ",string.rep(" ",level)) 9 | if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end 10 | t=debug.getinfo(2) 11 | if event=="call" then 12 | level=level+1 13 | else 14 | level=level-1 if level<0 then level=0 end 15 | end 16 | if t.what=="main" then 17 | if event=="call" then 18 | io.write("begin ",t.short_src) 19 | else 20 | io.write("end ",t.short_src) 21 | end 22 | elseif t.what=="Lua" then 23 | -- table.foreach(t,print) 24 | io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") 25 | else 26 | io.write(event," ",t.name or "(C)"," [",t.what,"] ") 27 | end 28 | io.write("\n") 29 | end 30 | 31 | debug.sethook(hook,"cr") 32 | level=0 33 | -------------------------------------------------------------------------------- /deps/lua/test/trace-globals.lua: -------------------------------------------------------------------------------- 1 | -- trace assigments to global variables 2 | 3 | do 4 | -- a tostring that quotes strings. note the use of the original tostring. 5 | local _tostring=tostring 6 | local tostring=function(a) 7 | if type(a)=="string" then 8 | return string.format("%q",a) 9 | else 10 | return _tostring(a) 11 | end 12 | end 13 | 14 | local log=function (name,old,new) 15 | local t=debug.getinfo(3,"Sl") 16 | local line=t.currentline 17 | io.write(t.short_src) 18 | if line>=0 then io.write(":",line) end 19 | io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") 20 | end 21 | 22 | local g={} 23 | local set=function (t,name,value) 24 | log(name,g[name],value) 25 | g[name]=value 26 | end 27 | setmetatable(getfenv(),{__index=g,__newindex=set}) 28 | end 29 | 30 | -- an example 31 | 32 | a=1 33 | b=2 34 | a=10 35 | b=20 36 | b=nil 37 | b=200 38 | print(a,b,c) 39 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/hooks.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_HOOKS_H 2 | #define JEMALLOC_INTERNAL_HOOKS_H 3 | 4 | extern JEMALLOC_EXPORT void (*hooks_arena_new_hook)(); 5 | extern JEMALLOC_EXPORT void (*hooks_libc_hook)(); 6 | 7 | #define JEMALLOC_HOOK(fn, hook) ((void)(hook != NULL && (hook(), 0)), fn) 8 | 9 | #define open JEMALLOC_HOOK(open, hooks_libc_hook) 10 | #define read JEMALLOC_HOOK(read, hooks_libc_hook) 11 | #define write JEMALLOC_HOOK(write, hooks_libc_hook) 12 | #define readlink JEMALLOC_HOOK(readlink, hooks_libc_hook) 13 | #define close JEMALLOC_HOOK(close, hooks_libc_hook) 14 | #define creat JEMALLOC_HOOK(creat, hooks_libc_hook) 15 | #define secure_getenv JEMALLOC_HOOK(secure_getenv, hooks_libc_hook) 16 | /* Note that this is undef'd and re-define'd in src/prof.c. */ 17 | #define _Unwind_Backtrace JEMALLOC_HOOK(_Unwind_Backtrace, hooks_libc_hook) 18 | 19 | #endif /* JEMALLOC_INTERNAL_HOOKS_H */ 20 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/thd.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifdef _WIN32 4 | void 5 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) { 6 | LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc; 7 | *thd = CreateThread(NULL, 0, routine, arg, 0, NULL); 8 | if (*thd == NULL) { 9 | test_fail("Error in CreateThread()\n"); 10 | } 11 | } 12 | 13 | void 14 | thd_join(thd_t thd, void **ret) { 15 | if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) { 16 | DWORD exit_code; 17 | GetExitCodeThread(thd, (LPDWORD) &exit_code); 18 | *ret = (void *)(uintptr_t)exit_code; 19 | } 20 | } 21 | 22 | #else 23 | void 24 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) { 25 | if (pthread_create(thd, NULL, proc, arg) != 0) { 26 | test_fail("Error in pthread_create()\n"); 27 | } 28 | } 29 | 30 | void 31 | thd_join(thd_t thd, void **ret) { 32 | pthread_join(thd, ret); 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/hooks.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | static bool hook_called = false; 4 | 5 | static void 6 | hook() { 7 | hook_called = true; 8 | } 9 | 10 | static int 11 | func_to_hook(int arg1, int arg2) { 12 | return arg1 + arg2; 13 | } 14 | 15 | #define func_to_hook JEMALLOC_HOOK(func_to_hook, hooks_libc_hook) 16 | 17 | TEST_BEGIN(unhooked_call) { 18 | hooks_libc_hook = NULL; 19 | hook_called = false; 20 | assert_d_eq(3, func_to_hook(1, 2), "Hooking changed return value."); 21 | assert_false(hook_called, "Nulling out hook didn't take."); 22 | } 23 | TEST_END 24 | 25 | TEST_BEGIN(hooked_call) { 26 | hooks_libc_hook = &hook; 27 | hook_called = false; 28 | assert_d_eq(3, func_to_hook(1, 2), "Hooking changed return value."); 29 | assert_true(hook_called, "Hook should have executed."); 30 | } 31 | TEST_END 32 | 33 | int 34 | main(void) { 35 | return test( 36 | unhooked_call, 37 | hooked_call); 38 | } 39 | -------------------------------------------------------------------------------- /deps/lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | 16 | 17 | static const luaL_Reg lualibs[] = { 18 | {"", luaopen_base}, 19 | {LUA_LOADLIBNAME, luaopen_package}, 20 | {LUA_TABLIBNAME, luaopen_table}, 21 | {LUA_IOLIBNAME, luaopen_io}, 22 | {LUA_OSLIBNAME, luaopen_os}, 23 | {LUA_STRLIBNAME, luaopen_string}, 24 | {LUA_MATHLIBNAME, luaopen_math}, 25 | {LUA_DBLIBNAME, luaopen_debug}, 26 | {NULL, NULL} 27 | }; 28 | 29 | 30 | LUALIB_API void luaL_openlibs (lua_State *L) { 31 | const luaL_Reg *lib = lualibs; 32 | for (; lib->func; lib++) { 33 | lua_pushcfunction(L, lib->func); 34 | lua_pushstring(L, lib->name); 35 | lua_call(L, 1, 0); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /tests/integration/logging.tcl: -------------------------------------------------------------------------------- 1 | set server_path [tmpdir server.log] 2 | set system_name [string tolower [exec uname -s]] 3 | 4 | if {$system_name eq {linux} || $system_name eq {darwin}} { 5 | start_server [list overrides [list dir $server_path]] { 6 | test "Server is able to generate a stack trace on selected systems" { 7 | r config set watchdog-period 200 8 | r debug sleep 1 9 | set pattern "*debugCommand*" 10 | set retry 10 11 | while {$retry} { 12 | set result [exec tail -100 < [srv 0 stdout]] 13 | if {[string match $pattern $result]} { 14 | break 15 | } 16 | incr retry -1 17 | after 1000 18 | } 19 | if {$retry == 0} { 20 | error "assertion:expected stack trace not found into log file" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/cluster/tests/01-faildet.tcl: -------------------------------------------------------------------------------- 1 | # Check the basic monitoring and failover capabilities. 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "Create a 5 nodes cluster" { 6 | create_cluster 5 5 7 | } 8 | 9 | test "Cluster should start ok" { 10 | assert_cluster_state ok 11 | } 12 | 13 | test "Killing two slave nodes" { 14 | kill_instance redis 5 15 | kill_instance redis 6 16 | } 17 | 18 | test "Cluster should be still up" { 19 | assert_cluster_state ok 20 | } 21 | 22 | test "Killing one master node" { 23 | kill_instance redis 0 24 | } 25 | 26 | # Note: the only slave of instance 0 is already down so no 27 | # failover is possible, that would change the state back to ok. 28 | test "Cluster should be down now" { 29 | assert_cluster_state fail 30 | } 31 | 32 | test "Restarting master node" { 33 | restart_instance redis 0 34 | } 35 | 36 | test "Cluster should be up again" { 37 | assert_cluster_state ok 38 | } 39 | -------------------------------------------------------------------------------- /deps/lua/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 25 | 26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tests/unit/moduleapi/fork.tcl: -------------------------------------------------------------------------------- 1 | set testmodule [file normalize tests/modules/fork.so] 2 | 3 | proc count_log_message {pattern} { 4 | set result [exec grep -c $pattern < [srv 0 stdout]] 5 | } 6 | 7 | start_server {tags {"modules"}} { 8 | r module load $testmodule 9 | 10 | test {Module fork} { 11 | # the argument to fork.create is the exitcode on termination 12 | r fork.create 3 13 | wait_for_condition 20 100 { 14 | [r fork.exitcode] != -1 15 | } else { 16 | fail "fork didn't terminate" 17 | } 18 | r fork.exitcode 19 | } {3} 20 | 21 | test {Module fork kill} { 22 | r fork.create 3 23 | after 250 24 | r fork.kill 25 | 26 | assert {[count_log_message "fork child started"] eq "2"} 27 | assert {[count_log_message "Received SIGUSR1 in child"] eq "1"} 28 | assert {[count_log_message "fork child exiting"] eq "1"} 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /deps/jemalloc/test/include/test/btalloc.h: -------------------------------------------------------------------------------- 1 | /* btalloc() provides a mechanism for allocating via permuted backtraces. */ 2 | void *btalloc(size_t size, unsigned bits); 3 | 4 | #define btalloc_n_proto(n) \ 5 | void *btalloc_##n(size_t size, unsigned bits); 6 | btalloc_n_proto(0) 7 | btalloc_n_proto(1) 8 | 9 | #define btalloc_n_gen(n) \ 10 | void * \ 11 | btalloc_##n(size_t size, unsigned bits) { \ 12 | void *p; \ 13 | \ 14 | if (bits == 0) { \ 15 | p = mallocx(size, 0); \ 16 | } else { \ 17 | switch (bits & 0x1U) { \ 18 | case 0: \ 19 | p = (btalloc_0(size, bits >> 1)); \ 20 | break; \ 21 | case 1: \ 22 | p = (btalloc_1(size, bits >> 1)); \ 23 | break; \ 24 | default: not_reached(); \ 25 | } \ 26 | } \ 27 | /* Intentionally sabotage tail call optimization. */ \ 28 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); \ 29 | return p; \ 30 | } 31 | -------------------------------------------------------------------------------- /deps/lua/etc/min.c: -------------------------------------------------------------------------------- 1 | /* 2 | * min.c -- a minimal Lua interpreter 3 | * loads stdin only with minimal error handling. 4 | * no interaction, and no standard library, only a "print" function. 5 | */ 6 | 7 | #include 8 | 9 | #include "lua.h" 10 | #include "lauxlib.h" 11 | 12 | static int print(lua_State *L) 13 | { 14 | int n=lua_gettop(L); 15 | int i; 16 | for (i=1; i<=n; i++) 17 | { 18 | if (i>1) printf("\t"); 19 | if (lua_isstring(L,i)) 20 | printf("%s",lua_tostring(L,i)); 21 | else if (lua_isnil(L,i)) 22 | printf("%s","nil"); 23 | else if (lua_isboolean(L,i)) 24 | printf("%s",lua_toboolean(L,i) ? "true" : "false"); 25 | else 26 | printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i)); 27 | } 28 | printf("\n"); 29 | return 0; 30 | } 31 | 32 | int main(void) 33 | { 34 | lua_State *L=lua_open(); 35 | lua_register(L,"print",print); 36 | if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1)); 37 | lua_close(L); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /deps/lua/doc/readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Lua documentation 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | Lua 12 | Documentation 13 |

14 | 15 | This is the documentation included in the source distribution of Lua 5.1.5. 16 | 17 | 25 | 26 | Lua's 27 | official web site 28 | contains updated documentation, 29 | especially the 30 | reference manual. 31 |

32 | 33 |


34 | 35 | Last update: 36 | Fri Feb 3 09:44:42 BRST 2012 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_idump.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | static bool did_prof_dump_open; 4 | 5 | static int 6 | prof_dump_open_intercept(bool propagate_err, const char *filename) { 7 | int fd; 8 | 9 | did_prof_dump_open = true; 10 | 11 | fd = open("/dev/null", O_WRONLY); 12 | assert_d_ne(fd, -1, "Unexpected open() failure"); 13 | 14 | return fd; 15 | } 16 | 17 | TEST_BEGIN(test_idump) { 18 | bool active; 19 | void *p; 20 | 21 | test_skip_if(!config_prof); 22 | 23 | active = true; 24 | assert_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active, 25 | sizeof(active)), 0, 26 | "Unexpected mallctl failure while activating profiling"); 27 | 28 | prof_dump_open = prof_dump_open_intercept; 29 | 30 | did_prof_dump_open = false; 31 | p = mallocx(1, 0); 32 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); 33 | dallocx(p, 0); 34 | assert_true(did_prof_dump_open, "Expected a profile dump"); 35 | } 36 | TEST_END 37 | 38 | int 39 | main(void) { 40 | return test( 41 | test_idump); 42 | } 43 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/slab.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_arena_slab_regind) { 4 | szind_t binind; 5 | 6 | for (binind = 0; binind < NBINS; binind++) { 7 | size_t regind; 8 | extent_t slab; 9 | const bin_info_t *bin_info = &bin_infos[binind]; 10 | extent_init(&slab, NULL, mallocx(bin_info->slab_size, 11 | MALLOCX_LG_ALIGN(LG_PAGE)), bin_info->slab_size, true, 12 | binind, 0, extent_state_active, false, true, true); 13 | assert_ptr_not_null(extent_addr_get(&slab), 14 | "Unexpected malloc() failure"); 15 | for (regind = 0; regind < bin_info->nregs; regind++) { 16 | void *reg = (void *)((uintptr_t)extent_addr_get(&slab) + 17 | (bin_info->reg_size * regind)); 18 | assert_zu_eq(arena_slab_regind(&slab, binind, reg), 19 | regind, 20 | "Incorrect region index computed for size %zu", 21 | bin_info->reg_size); 22 | } 23 | free(extent_addr_get(&slab)); 24 | } 25 | } 26 | TEST_END 27 | 28 | int 29 | main(void) { 30 | return test( 31 | test_arena_slab_regind); 32 | } 33 | -------------------------------------------------------------------------------- /deps/lua/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (char* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | #ifdef luac_c 23 | /* print one chunk; from print.c */ 24 | LUAI_FUNC void luaU_print (const Proto* f, int full); 25 | #endif 26 | 27 | /* for header of binary files -- this is Lua 5.1 */ 28 | #define LUAC_VERSION 0x51 29 | 30 | /* for header of binary files -- this is the official format */ 31 | #define LUAC_FORMAT 0 32 | 33 | /* size of header of binary files */ 34 | #define LUAC_HEADERSIZE 12 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/base_externs.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BASE_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_BASE_EXTERNS_H 3 | 4 | extern metadata_thp_mode_t opt_metadata_thp; 5 | extern const char *metadata_thp_mode_names[]; 6 | 7 | base_t *b0get(void); 8 | base_t *base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks); 9 | void base_delete(tsdn_t *tsdn, base_t *base); 10 | extent_hooks_t *base_extent_hooks_get(base_t *base); 11 | extent_hooks_t *base_extent_hooks_set(base_t *base, 12 | extent_hooks_t *extent_hooks); 13 | void *base_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment); 14 | extent_t *base_alloc_extent(tsdn_t *tsdn, base_t *base); 15 | void base_stats_get(tsdn_t *tsdn, base_t *base, size_t *allocated, 16 | size_t *resident, size_t *mapped, size_t *n_thp); 17 | void base_prefork(tsdn_t *tsdn, base_t *base); 18 | void base_postfork_parent(tsdn_t *tsdn, base_t *base); 19 | void base_postfork_child(tsdn_t *tsdn, base_t *base); 20 | bool base_boot(tsdn_t *tsdn); 21 | 22 | #endif /* JEMALLOC_INTERNAL_BASE_EXTERNS_H */ 23 | -------------------------------------------------------------------------------- /tests/modules/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # find the OS 3 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') 4 | 5 | # Compile flags for linux / osx 6 | ifeq ($(uname_S),Linux) 7 | SHOBJ_CFLAGS ?= -W -Wall -fno-common -g -ggdb -std=c99 -O2 8 | SHOBJ_LDFLAGS ?= -shared 9 | else 10 | SHOBJ_CFLAGS ?= -W -Wall -dynamic -fno-common -g -ggdb -std=c99 -O2 11 | SHOBJ_LDFLAGS ?= -bundle -undefined dynamic_lookup 12 | endif 13 | 14 | TEST_MODULES = \ 15 | commandfilter.so \ 16 | testrdb.so \ 17 | fork.so \ 18 | infotest.so \ 19 | propagate.so \ 20 | misc.so \ 21 | hooks.so \ 22 | blockonkeys.so \ 23 | scan.so \ 24 | datatype.so \ 25 | auth.so 26 | 27 | .PHONY: all 28 | 29 | all: $(TEST_MODULES) 30 | 31 | 32bit: 32 | $(MAKE) CFLAGS="-m32" LDFLAGS="-melf_i386" 33 | 34 | %.xo: %.c ../../src/redismodule.h 35 | $(CC) -I../../src $(CFLAGS) $(SHOBJ_CFLAGS) -fPIC -c $< -o $@ 36 | 37 | %.so: %.xo 38 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LDFLAGS) $(LIBS) -lc 39 | 40 | .PHONY: clean 41 | 42 | clean: 43 | rm -f $(TEST_MODULES) $(TEST_MODULES:.so=.xo) 44 | -------------------------------------------------------------------------------- /deps/jemalloc/src/extent_mmap.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_EXTENT_MMAP_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | 5 | #include "jemalloc/internal/assert.h" 6 | #include "jemalloc/internal/extent_mmap.h" 7 | 8 | /******************************************************************************/ 9 | /* Data. */ 10 | 11 | bool opt_retain = 12 | #ifdef JEMALLOC_RETAIN 13 | true 14 | #else 15 | false 16 | #endif 17 | ; 18 | 19 | /******************************************************************************/ 20 | 21 | void * 22 | extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero, 23 | bool *commit) { 24 | void *ret = pages_map(new_addr, size, ALIGNMENT_CEILING(alignment, 25 | PAGE), commit); 26 | if (ret == NULL) { 27 | return NULL; 28 | } 29 | assert(ret != NULL); 30 | if (*commit) { 31 | *zero = true; 32 | } 33 | return ret; 34 | } 35 | 36 | bool 37 | extent_dalloc_mmap(void *addr, size_t size) { 38 | if (!opt_retain) { 39 | pages_unmap(addr, size); 40 | } 41 | return opt_retain; 42 | } 43 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/stats.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_STATS_H 2 | #define JEMALLOC_INTERNAL_STATS_H 3 | 4 | /* OPTION(opt, var_name, default, set_value_to) */ 5 | #define STATS_PRINT_OPTIONS \ 6 | OPTION('J', json, false, true) \ 7 | OPTION('g', general, true, false) \ 8 | OPTION('m', merged, config_stats, false) \ 9 | OPTION('d', destroyed, config_stats, false) \ 10 | OPTION('a', unmerged, config_stats, false) \ 11 | OPTION('b', bins, true, false) \ 12 | OPTION('l', large, true, false) \ 13 | OPTION('x', mutex, true, false) 14 | 15 | enum { 16 | #define OPTION(o, v, d, s) stats_print_option_num_##v, 17 | STATS_PRINT_OPTIONS 18 | #undef OPTION 19 | stats_print_tot_num_options 20 | }; 21 | 22 | /* Options for stats_print. */ 23 | extern bool opt_stats_print; 24 | extern char opt_stats_print_opts[stats_print_tot_num_options+1]; 25 | 26 | /* Implements je_malloc_stats_print. */ 27 | void stats_print(void (*write_cb)(void *, const char *), void *cbopaque, 28 | const char *opts); 29 | 30 | #endif /* JEMALLOC_INTERNAL_STATS_H */ 31 | -------------------------------------------------------------------------------- /deps/lua/etc/Makefile: -------------------------------------------------------------------------------- 1 | # makefile for Lua etc 2 | 3 | TOP= .. 4 | LIB= $(TOP)/src 5 | INC= $(TOP)/src 6 | BIN= $(TOP)/src 7 | SRC= $(TOP)/src 8 | TST= $(TOP)/test 9 | 10 | CC= gcc 11 | CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS) 12 | MYCFLAGS= 13 | MYLDFLAGS= -Wl,-E 14 | MYLIBS= -lm 15 | #MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses 16 | RM= rm -f 17 | 18 | default: 19 | @echo 'Please choose a target: min noparser one strict clean' 20 | 21 | min: min.c 22 | $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS) 23 | echo 'print"Hello there!"' | ./a.out 24 | 25 | noparser: noparser.o 26 | $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS) 27 | $(BIN)/luac $(TST)/hello.lua 28 | -./a.out luac.out 29 | -./a.out -e'a=1' 30 | 31 | one: 32 | $(CC) $(CFLAGS) all.c $(MYLIBS) 33 | ./a.out $(TST)/hello.lua 34 | 35 | strict: 36 | -$(BIN)/lua -e 'print(a);b=2' 37 | -$(BIN)/lua -lstrict -e 'print(a)' 38 | -$(BIN)/lua -e 'function f() b=2 end f()' 39 | -$(BIN)/lua -lstrict -e 'function f() b=2 end f()' 40 | 41 | clean: 42 | $(RM) a.out core core.* *.o luac.out 43 | 44 | .PHONY: default min noparser one strict clean 45 | -------------------------------------------------------------------------------- /deps/lua/etc/strict.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- strict.lua 3 | -- checks uses of undeclared global variables 4 | -- All global variables must be 'declared' through a regular assignment 5 | -- (even assigning nil will do) in a main chunk before being used 6 | -- anywhere or assigned to inside a function. 7 | -- 8 | 9 | local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget 10 | 11 | local mt = getmetatable(_G) 12 | if mt == nil then 13 | mt = {} 14 | setmetatable(_G, mt) 15 | end 16 | 17 | mt.__declared = {} 18 | 19 | local function what () 20 | local d = getinfo(3, "S") 21 | return d and d.what or "C" 22 | end 23 | 24 | mt.__newindex = function (t, n, v) 25 | if not mt.__declared[n] then 26 | local w = what() 27 | if w ~= "main" and w ~= "C" then 28 | error("assign to undeclared variable '"..n.."'", 2) 29 | end 30 | mt.__declared[n] = true 31 | end 32 | rawset(t, n, v) 33 | end 34 | 35 | mt.__index = function (t, n) 36 | if not mt.__declared[n] and what() ~= "C" then 37 | error("variable '"..n.."' is not declared", 2) 38 | end 39 | return rawget(t, n) 40 | end 41 | 42 | -------------------------------------------------------------------------------- /deps/jemalloc/README: -------------------------------------------------------------------------------- 1 | jemalloc is a general purpose malloc(3) implementation that emphasizes 2 | fragmentation avoidance and scalable concurrency support. jemalloc first came 3 | into use as the FreeBSD libc allocator in 2005, and since then it has found its 4 | way into numerous applications that rely on its predictable behavior. In 2010 5 | jemalloc development efforts broadened to include developer support features 6 | such as heap profiling and extensive monitoring/tuning hooks. Modern jemalloc 7 | releases continue to be integrated back into FreeBSD, and therefore versatility 8 | remains critical. Ongoing development efforts trend toward making jemalloc 9 | among the best allocators for a broad range of demanding applications, and 10 | eliminating/mitigating weaknesses that have practical repercussions for real 11 | world applications. 12 | 13 | The COPYING file contains copyright and licensing information. 14 | 15 | The INSTALL file contains information on how to configure, build, and install 16 | jemalloc. 17 | 18 | The ChangeLog file contains a brief summary of changes for each release. 19 | 20 | URL: http://jemalloc.net/ 21 | -------------------------------------------------------------------------------- /deps/lua/etc/README: -------------------------------------------------------------------------------- 1 | This directory contains some useful files and code. 2 | Unlike the code in ../src, everything here is in the public domain. 3 | 4 | If any of the makes fail, you're probably not using the same libraries 5 | used to build Lua. Set MYLIBS in Makefile accordingly. 6 | 7 | all.c 8 | Full Lua interpreter in a single file. 9 | Do "make one" for a demo. 10 | 11 | lua.hpp 12 | Lua header files for C++ using 'extern "C"'. 13 | 14 | lua.ico 15 | A Lua icon for Windows (and web sites: save as favicon.ico). 16 | Drawn by hand by Markus Gritsch . 17 | 18 | lua.pc 19 | pkg-config data for Lua 20 | 21 | luavs.bat 22 | Script to build Lua under "Visual Studio .NET Command Prompt". 23 | Run it from the toplevel as etc\luavs.bat. 24 | 25 | min.c 26 | A minimal Lua interpreter. 27 | Good for learning and for starting your own. 28 | Do "make min" for a demo. 29 | 30 | noparser.c 31 | Linking with noparser.o avoids loading the parsing modules in lualib.a. 32 | Do "make noparser" for a demo. 33 | 34 | strict.lua 35 | Traps uses of undeclared global variables. 36 | Do "make strict" for a demo. 37 | 38 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/projects/vc2015/test_threads/test_threads.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /deps/jemalloc/msvc/projects/vc2017/test_threads/test_threads.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | 7 | test-ubuntu-latest: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v1 11 | - name: make 12 | run: make 13 | - name: test 14 | run: | 15 | sudo apt-get install tcl8.5 16 | ./runtest --verbose 17 | - name: module api test 18 | run: ./runtest-moduleapi --verbose 19 | 20 | build-ubuntu-old: 21 | runs-on: ubuntu-16.04 22 | steps: 23 | - uses: actions/checkout@v1 24 | - name: make 25 | run: make 26 | 27 | build-macos-latest: 28 | runs-on: macos-latest 29 | steps: 30 | - uses: actions/checkout@v1 31 | - name: make 32 | run: make 33 | 34 | biuld-32bit: 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v1 38 | - name: make 39 | run: | 40 | sudo apt-get update && sudo apt-get install libc6-dev-i386 41 | make 32bit 42 | 43 | build-libc-malloc: 44 | runs-on: ubuntu-latest 45 | steps: 46 | - uses: actions/checkout@v1 47 | - name: make 48 | run: make MALLOC=libc 49 | 50 | -------------------------------------------------------------------------------- /tests/unit/quit.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"quit"}} { 2 | proc format_command {args} { 3 | set cmd "*[llength $args]\r\n" 4 | foreach a $args { 5 | append cmd "$[string length $a]\r\n$a\r\n" 6 | } 7 | set _ $cmd 8 | } 9 | 10 | test "QUIT returns OK" { 11 | reconnect 12 | assert_equal OK [r quit] 13 | assert_error * {r ping} 14 | } 15 | 16 | test "Pipelined commands after QUIT must not be executed" { 17 | reconnect 18 | r write [format_command quit] 19 | r write [format_command set foo bar] 20 | r flush 21 | assert_equal OK [r read] 22 | assert_error * {r read} 23 | 24 | reconnect 25 | assert_equal {} [r get foo] 26 | } 27 | 28 | test "Pipelined commands after QUIT that exceed read buffer size" { 29 | reconnect 30 | r write [format_command quit] 31 | r write [format_command set foo [string repeat "x" 1024]] 32 | r flush 33 | assert_equal OK [r read] 34 | assert_error * {r read} 35 | 36 | reconnect 37 | assert_equal {} [r get foo] 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /deps/jemalloc/.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | 3 | environment: 4 | matrix: 5 | - MSYSTEM: MINGW64 6 | CPU: x86_64 7 | MSVC: amd64 8 | - MSYSTEM: MINGW32 9 | CPU: i686 10 | MSVC: x86 11 | - MSYSTEM: MINGW64 12 | CPU: x86_64 13 | - MSYSTEM: MINGW32 14 | CPU: i686 15 | - MSYSTEM: MINGW64 16 | CPU: x86_64 17 | MSVC: amd64 18 | CONFIG_FLAGS: --enable-debug 19 | - MSYSTEM: MINGW32 20 | CPU: i686 21 | MSVC: x86 22 | CONFIG_FLAGS: --enable-debug 23 | - MSYSTEM: MINGW64 24 | CPU: x86_64 25 | CONFIG_FLAGS: --enable-debug 26 | - MSYSTEM: MINGW32 27 | CPU: i686 28 | CONFIG_FLAGS: --enable-debug 29 | 30 | install: 31 | - set PATH=c:\msys64\%MSYSTEM%\bin;c:\msys64\usr\bin;%PATH% 32 | - if defined MSVC call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %MSVC% 33 | - if defined MSVC pacman --noconfirm -Rsc mingw-w64-%CPU%-gcc gcc 34 | - pacman --noconfirm -Suy mingw-w64-%CPU%-make 35 | 36 | build_script: 37 | - bash -c "autoconf" 38 | - bash -c "./configure $CONFIG_FLAGS" 39 | - mingw32-make 40 | - file lib/jemalloc.dll 41 | - mingw32-make tests 42 | - mingw32-make -k check 43 | -------------------------------------------------------------------------------- /deps/lua/etc/luavs.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build Lua under "Visual Studio .NET Command Prompt". 2 | @rem Do not run from this directory; run it from the toplevel: etc\luavs.bat . 3 | @rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src. 4 | @rem (contributed by David Manura and Mike Pall) 5 | 6 | @setlocal 7 | @set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE 8 | @set MYLINK=link /nologo 9 | @set MYMT=mt /nologo 10 | 11 | cd src 12 | %MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c 13 | del lua.obj luac.obj 14 | %MYLINK% /DLL /out:lua51.dll l*.obj 15 | if exist lua51.dll.manifest^ 16 | %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 17 | %MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c 18 | %MYLINK% /out:lua.exe lua.obj lua51.lib 19 | if exist lua.exe.manifest^ 20 | %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe 21 | %MYCOMPILE% l*.c print.c 22 | del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^ 23 | loslib.obj ltablib.obj lstrlib.obj loadlib.obj 24 | %MYLINK% /out:luac.exe *.obj 25 | if exist luac.exe.manifest^ 26 | %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe 27 | del *.obj *.manifest 28 | cd .. 29 | -------------------------------------------------------------------------------- /deps/lua/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 25 | const TValue *p2); 26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 29 | LUAI_FUNC void luaG_errormsg (lua_State *L); 30 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 31 | LUAI_FUNC int luaG_checkopenop (Instruction i); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /tests/cluster/tests/09-pubsub.tcl: -------------------------------------------------------------------------------- 1 | # Test PUBLISH propagation across the cluster. 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "Create a 5 nodes cluster" { 6 | create_cluster 5 5 7 | } 8 | 9 | proc test_cluster_publish {instance instances} { 10 | # Subscribe all the instances but the one we use to send. 11 | for {set j 0} {$j < $instances} {incr j} { 12 | if {$j != $instance} { 13 | R $j deferred 1 14 | R $j subscribe testchannel 15 | R $j read; # Read the subscribe reply 16 | } 17 | } 18 | 19 | set data [randomValue] 20 | R $instance PUBLISH testchannel $data 21 | 22 | # Read the message back from all the nodes. 23 | for {set j 0} {$j < $instances} {incr j} { 24 | if {$j != $instance} { 25 | set msg [R $j read] 26 | assert {$data eq [lindex $msg 2]} 27 | R $j unsubscribe testchannel 28 | R $j read; # Read the unsubscribe reply 29 | R $j deferred 0 30 | } 31 | } 32 | } 33 | 34 | test "Test publishing to master" { 35 | test_cluster_publish 0 10 36 | } 37 | 38 | test "Test publishing to slave" { 39 | test_cluster_publish 5 10 40 | } 41 | -------------------------------------------------------------------------------- /tests/unit/pendingquerybuf.tcl: -------------------------------------------------------------------------------- 1 | proc info_memory {r property} { 2 | if {[regexp "\r\n$property:(.*?)\r\n" [{*}$r info memory] _ value]} { 3 | set _ $value 4 | } 5 | } 6 | 7 | proc prepare_value {size} { 8 | set _v "c" 9 | for {set i 1} {$i < $size} {incr i} { 10 | append _v 0 11 | } 12 | return $_v 13 | } 14 | 15 | start_server {tags {"wait"}} { 16 | start_server {} { 17 | set slave [srv 0 client] 18 | set slave_host [srv 0 host] 19 | set slave_port [srv 0 port] 20 | set master [srv -1 client] 21 | set master_host [srv -1 host] 22 | set master_port [srv -1 port] 23 | 24 | test "pending querybuf: check size of pending_querybuf after set a big value" { 25 | $slave slaveof $master_host $master_port 26 | set _v [prepare_value [expr 32*1024*1024]] 27 | $master set key $_v 28 | after 2000 29 | set m_usedmemory [info_memory $master used_memory] 30 | set s_usedmemory [info_memory $slave used_memory] 31 | if { $s_usedmemory > $m_usedmemory + 10*1024*1024 } { 32 | fail "the used_memory of replica is much larger than master. Master:$m_usedmemory Replica:$s_usedmemory" 33 | } 34 | } 35 | }} 36 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/jemalloc_internal_macros.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_MACROS_H 2 | #define JEMALLOC_INTERNAL_MACROS_H 3 | 4 | #ifdef JEMALLOC_DEBUG 5 | # define JEMALLOC_ALWAYS_INLINE static inline 6 | #else 7 | # define JEMALLOC_ALWAYS_INLINE JEMALLOC_ATTR(always_inline) static inline 8 | #endif 9 | #ifdef _MSC_VER 10 | # define inline _inline 11 | #endif 12 | 13 | #define UNUSED JEMALLOC_ATTR(unused) 14 | 15 | #define ZU(z) ((size_t)z) 16 | #define ZD(z) ((ssize_t)z) 17 | #define QU(q) ((uint64_t)q) 18 | #define QD(q) ((int64_t)q) 19 | 20 | #define KZU(z) ZU(z##ULL) 21 | #define KZD(z) ZD(z##LL) 22 | #define KQU(q) QU(q##ULL) 23 | #define KQD(q) QI(q##LL) 24 | 25 | #ifndef __DECONST 26 | # define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var)) 27 | #endif 28 | 29 | #if !defined(JEMALLOC_HAS_RESTRICT) || defined(__cplusplus) 30 | # define restrict 31 | #endif 32 | 33 | /* Various function pointers are statick and immutable except during testing. */ 34 | #ifdef JEMALLOC_JET 35 | # define JET_MUTABLE 36 | #else 37 | # define JET_MUTABLE const 38 | #endif 39 | 40 | #define JEMALLOC_VA_ARGS_HEAD(head, ...) head 41 | #define JEMALLOC_VA_ARGS_TAIL(head, ...) __VA_ARGS__ 42 | 43 | #endif /* JEMALLOC_INTERNAL_MACROS_H */ 44 | -------------------------------------------------------------------------------- /utils/redis_init_script.tpl: -------------------------------------------------------------------------------- 1 | 2 | case "$1" in 3 | start) 4 | if [ -f $PIDFILE ] 5 | then 6 | echo "$PIDFILE exists, process is already running or crashed" 7 | else 8 | echo "Starting Redis server..." 9 | $EXEC $CONF 10 | fi 11 | ;; 12 | stop) 13 | if [ ! -f $PIDFILE ] 14 | then 15 | echo "$PIDFILE does not exist, process is not running" 16 | else 17 | PID=$(cat $PIDFILE) 18 | echo "Stopping ..." 19 | $CLIEXEC -p $REDISPORT shutdown 20 | while [ -x /proc/${PID} ] 21 | do 22 | echo "Waiting for Redis to shutdown ..." 23 | sleep 1 24 | done 25 | echo "Redis stopped" 26 | fi 27 | ;; 28 | status) 29 | PID=$(cat $PIDFILE) 30 | if [ ! -x /proc/${PID} ] 31 | then 32 | echo 'Redis is not running' 33 | else 34 | echo "Redis is running ($PID)" 35 | fi 36 | ;; 37 | restart) 38 | $0 stop 39 | $0 start 40 | ;; 41 | *) 42 | echo "Please use start, stop, restart or status as first argument" 43 | ;; 44 | esac 45 | -------------------------------------------------------------------------------- /deps/lua/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_EQ, /* last tag method with `fast' access */ 24 | TM_ADD, 25 | TM_SUB, 26 | TM_MUL, 27 | TM_DIV, 28 | TM_MOD, 29 | TM_POW, 30 | TM_UNM, 31 | TM_LEN, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | LUAI_DATA const char *const luaT_typenames[]; 47 | 48 | 49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 51 | TMS event); 52 | LUAI_FUNC void luaT_init (lua_State *L); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /deps/lua/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/hiredis/examples/example-qt.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #include 5 | #include 6 | 7 | #include "example-qt.h" 8 | 9 | void getCallback(redisAsyncContext *, void * r, void * privdata) { 10 | 11 | redisReply * reply = static_cast(r); 12 | ExampleQt * ex = static_cast(privdata); 13 | if (reply == nullptr || ex == nullptr) return; 14 | 15 | cout << "key: " << reply->str << endl; 16 | 17 | ex->finish(); 18 | } 19 | 20 | void ExampleQt::run() { 21 | 22 | m_ctx = redisAsyncConnect("localhost", 6379); 23 | 24 | if (m_ctx->err) { 25 | cerr << "Error: " << m_ctx->errstr << endl; 26 | redisAsyncFree(m_ctx); 27 | emit finished(); 28 | } 29 | 30 | m_adapter.setContext(m_ctx); 31 | 32 | redisAsyncCommand(m_ctx, NULL, NULL, "SET key %s", m_value); 33 | redisAsyncCommand(m_ctx, getCallback, this, "GET key"); 34 | } 35 | 36 | int main (int argc, char **argv) { 37 | 38 | QCoreApplication app(argc, argv); 39 | 40 | ExampleQt example(argv[argc-1]); 41 | 42 | QObject::connect(&example, SIGNAL(finished()), &app, SLOT(quit())); 43 | QTimer::singleShot(0, &example, SLOT(run())); 44 | 45 | return app.exec(); 46 | } 47 | -------------------------------------------------------------------------------- /deps/lua/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/sentinel/tests/06-ckquorum.tcl: -------------------------------------------------------------------------------- 1 | # Test for the SENTINEL CKQUORUM command 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | set num_sentinels [llength $::sentinel_instances] 5 | 6 | test "CKQUORUM reports OK and the right amount of Sentinels" { 7 | foreach_sentinel_id id { 8 | assert_match "*OK $num_sentinels usable*" [S $id SENTINEL CKQUORUM mymaster] 9 | } 10 | } 11 | 12 | test "CKQUORUM detects quorum cannot be reached" { 13 | set orig_quorum [expr {$num_sentinels/2+1}] 14 | S 0 SENTINEL SET mymaster quorum [expr {$num_sentinels+1}] 15 | catch {[S 0 SENTINEL CKQUORUM mymaster]} err 16 | assert_match "*NOQUORUM*" $err 17 | S 0 SENTINEL SET mymaster quorum $orig_quorum 18 | } 19 | 20 | test "CKQUORUM detects failover authorization cannot be reached" { 21 | set orig_quorum [expr {$num_sentinels/2+1}] 22 | S 0 SENTINEL SET mymaster quorum 1 23 | kill_instance sentinel 1 24 | kill_instance sentinel 2 25 | kill_instance sentinel 3 26 | after 5000 27 | catch {[S 0 SENTINEL CKQUORUM mymaster]} err 28 | assert_match "*NOQUORUM*" $err 29 | S 0 SENTINEL SET mymaster quorum $orig_quorum 30 | restart_instance sentinel 1 31 | restart_instance sentinel 2 32 | restart_instance sentinel 3 33 | } 34 | 35 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/base_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BASE_TYPES_H 2 | #define JEMALLOC_INTERNAL_BASE_TYPES_H 3 | 4 | typedef struct base_block_s base_block_t; 5 | typedef struct base_s base_t; 6 | 7 | #define METADATA_THP_DEFAULT metadata_thp_disabled 8 | 9 | /* 10 | * In auto mode, arenas switch to huge pages for the base allocator on the 11 | * second base block. a0 switches to thp on the 5th block (after 20 megabytes 12 | * of metadata), since more metadata (e.g. rtree nodes) come from a0's base. 13 | */ 14 | 15 | #define BASE_AUTO_THP_THRESHOLD 2 16 | #define BASE_AUTO_THP_THRESHOLD_A0 5 17 | 18 | typedef enum { 19 | metadata_thp_disabled = 0, 20 | /* 21 | * Lazily enable hugepage for metadata. To avoid high RSS caused by THP 22 | * + low usage arena (i.e. THP becomes a significant percentage), the 23 | * "auto" option only starts using THP after a base allocator used up 24 | * the first THP region. Starting from the second hugepage (in a single 25 | * arena), "auto" behaves the same as "always", i.e. madvise hugepage 26 | * right away. 27 | */ 28 | metadata_thp_auto = 1, 29 | metadata_thp_always = 2, 30 | metadata_thp_mode_limit = 3 31 | } metadata_thp_mode_t; 32 | 33 | #endif /* JEMALLOC_INTERNAL_BASE_TYPES_H */ 34 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/mtx.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define NTHREADS 2 4 | #define NINCRS 2000000 5 | 6 | TEST_BEGIN(test_mtx_basic) { 7 | mtx_t mtx; 8 | 9 | assert_false(mtx_init(&mtx), "Unexpected mtx_init() failure"); 10 | mtx_lock(&mtx); 11 | mtx_unlock(&mtx); 12 | mtx_fini(&mtx); 13 | } 14 | TEST_END 15 | 16 | typedef struct { 17 | mtx_t mtx; 18 | unsigned x; 19 | } thd_start_arg_t; 20 | 21 | static void * 22 | thd_start(void *varg) { 23 | thd_start_arg_t *arg = (thd_start_arg_t *)varg; 24 | unsigned i; 25 | 26 | for (i = 0; i < NINCRS; i++) { 27 | mtx_lock(&arg->mtx); 28 | arg->x++; 29 | mtx_unlock(&arg->mtx); 30 | } 31 | return NULL; 32 | } 33 | 34 | TEST_BEGIN(test_mtx_race) { 35 | thd_start_arg_t arg; 36 | thd_t thds[NTHREADS]; 37 | unsigned i; 38 | 39 | assert_false(mtx_init(&arg.mtx), "Unexpected mtx_init() failure"); 40 | arg.x = 0; 41 | for (i = 0; i < NTHREADS; i++) { 42 | thd_create(&thds[i], thd_start, (void *)&arg); 43 | } 44 | for (i = 0; i < NTHREADS; i++) { 45 | thd_join(thds[i], NULL); 46 | } 47 | assert_u_eq(arg.x, NTHREADS * NINCRS, 48 | "Race-related counter corruption"); 49 | } 50 | TEST_END 51 | 52 | int 53 | main(void) { 54 | return test( 55 | test_mtx_basic, 56 | test_mtx_race); 57 | } 58 | -------------------------------------------------------------------------------- /deps/lua/test/README: -------------------------------------------------------------------------------- 1 | These are simple tests for Lua. Some of them contain useful code. 2 | They are meant to be run to make sure Lua is built correctly and also 3 | to be read, to see how Lua programs look. 4 | 5 | Here is a one-line summary of each program: 6 | 7 | bisect.lua bisection method for solving non-linear equations 8 | cf.lua temperature conversion table (celsius to farenheit) 9 | echo.lua echo command line arguments 10 | env.lua environment variables as automatic global variables 11 | factorial.lua factorial without recursion 12 | fib.lua fibonacci function with cache 13 | fibfor.lua fibonacci numbers with coroutines and generators 14 | globals.lua report global variable usage 15 | hello.lua the first program in every language 16 | life.lua Conway's Game of Life 17 | luac.lua bare-bones luac 18 | printf.lua an implementation of printf 19 | readonly.lua make global variables readonly 20 | sieve.lua the sieve of of Eratosthenes programmed with coroutines 21 | sort.lua two implementations of a sort function 22 | table.lua make table, grouping all data for the same item 23 | trace-calls.lua trace calls 24 | trace-globals.lua trace assigments to global variables 25 | xd.lua hex dump 26 | 27 | -------------------------------------------------------------------------------- /deps/hiredis/win32.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIN32_HELPER_INCLUDE 2 | #define _WIN32_HELPER_INCLUDE 3 | #ifdef _MSC_VER 4 | 5 | #include /* for struct timeval */ 6 | 7 | #ifndef inline 8 | #define inline __inline 9 | #endif 10 | 11 | #ifndef strcasecmp 12 | #define strcasecmp stricmp 13 | #endif 14 | 15 | #ifndef strncasecmp 16 | #define strncasecmp strnicmp 17 | #endif 18 | 19 | #ifndef va_copy 20 | #define va_copy(d,s) ((d) = (s)) 21 | #endif 22 | 23 | #ifndef snprintf 24 | #define snprintf c99_snprintf 25 | 26 | __inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) 27 | { 28 | int count = -1; 29 | 30 | if (size != 0) 31 | count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); 32 | if (count == -1) 33 | count = _vscprintf(format, ap); 34 | 35 | return count; 36 | } 37 | 38 | __inline int c99_snprintf(char* str, size_t size, const char* format, ...) 39 | { 40 | int count; 41 | va_list ap; 42 | 43 | va_start(ap, format); 44 | count = c99_vsnprintf(str, size, format, ap); 45 | va_end(ap); 46 | 47 | return count; 48 | } 49 | #endif 50 | #endif /* _MSC_VER */ 51 | 52 | #ifdef _WIN32 53 | #define strerror_r(errno,buf,len) strerror_s(buf,len,errno) 54 | #endif /* _WIN32 */ 55 | 56 | #endif /* _WIN32_HELPER_INCLUDE */ 57 | -------------------------------------------------------------------------------- /utils/corrupt_rdb.c: -------------------------------------------------------------------------------- 1 | /* Trivia program to corrupt an RDB file in order to check the RDB check 2 | * program behavior and effectiveness. 3 | * 4 | * Copyright (C) 2016 Salvatore Sanfilippo. 5 | * This software is released in the 3-clause BSD license. */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int main(int argc, char **argv) { 15 | struct stat stat; 16 | int fd, cycles; 17 | 18 | if (argc != 3) { 19 | fprintf(stderr,"Usage: \n"); 20 | exit(1); 21 | } 22 | 23 | srand(time(NULL)); 24 | char *filename = argv[1]; 25 | cycles = atoi(argv[2]); 26 | fd = open(filename,O_RDWR); 27 | if (fd == -1) { 28 | perror("open"); 29 | exit(1); 30 | } 31 | fstat(fd,&stat); 32 | 33 | while(cycles--) { 34 | unsigned char buf[32]; 35 | unsigned long offset = rand()%stat.st_size; 36 | int writelen = 1+rand()%31; 37 | int j; 38 | 39 | for (j = 0; j < writelen; j++) buf[j] = (char)rand(); 40 | lseek(fd,offset,SEEK_SET); 41 | printf("Writing %d bytes at offset %lu\n", writelen, offset); 42 | write(fd,buf,writelen); 43 | } 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /src/sha256.h: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Filename: sha256.h 3 | * Author: Brad Conte (brad AT bradconte.com) 4 | * Copyright: 5 | * Disclaimer: This code is presented "as is" without any guarantees. 6 | * Details: Defines the API for the corresponding SHA1 implementation. 7 | *********************************************************************/ 8 | 9 | #ifndef SHA256_H 10 | #define SHA256_H 11 | 12 | /*************************** HEADER FILES ***************************/ 13 | #include 14 | #include 15 | 16 | /****************************** MACROS ******************************/ 17 | #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest 18 | 19 | /**************************** DATA TYPES ****************************/ 20 | typedef uint8_t BYTE; // 8-bit byte 21 | typedef uint32_t WORD; // 32-bit word 22 | 23 | typedef struct { 24 | BYTE data[64]; 25 | WORD datalen; 26 | unsigned long long bitlen; 27 | WORD state[8]; 28 | } SHA256_CTX; 29 | 30 | /*********************** FUNCTION DECLARATIONS **********************/ 31 | void sha256_init(SHA256_CTX *ctx); 32 | void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len); 33 | void sha256_final(SHA256_CTX *ctx, BYTE hash[]); 34 | 35 | #endif // SHA256_H 36 | -------------------------------------------------------------------------------- /deps/lua/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ 19 | (((o) = luaV_tonumber(o,n)) != NULL)) 20 | 21 | #define equalobj(L,o1,o2) \ 22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 23 | 24 | 25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 30 | StkId val); 31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 32 | StkId val); 33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/sdallocx.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define MAXALIGN (((size_t)1) << 22) 4 | #define NITER 3 5 | 6 | TEST_BEGIN(test_basic) { 7 | void *ptr = mallocx(64, 0); 8 | sdallocx(ptr, 64, 0); 9 | } 10 | TEST_END 11 | 12 | TEST_BEGIN(test_alignment_and_size) { 13 | size_t nsz, sz, alignment, total; 14 | unsigned i; 15 | void *ps[NITER]; 16 | 17 | for (i = 0; i < NITER; i++) { 18 | ps[i] = NULL; 19 | } 20 | 21 | for (alignment = 8; 22 | alignment <= MAXALIGN; 23 | alignment <<= 1) { 24 | total = 0; 25 | for (sz = 1; 26 | sz < 3 * alignment && sz < (1U << 31); 27 | sz += (alignment >> (LG_SIZEOF_PTR-1)) - 1) { 28 | for (i = 0; i < NITER; i++) { 29 | nsz = nallocx(sz, MALLOCX_ALIGN(alignment) | 30 | MALLOCX_ZERO); 31 | ps[i] = mallocx(sz, MALLOCX_ALIGN(alignment) | 32 | MALLOCX_ZERO); 33 | total += nsz; 34 | if (total >= (MAXALIGN << 1)) { 35 | break; 36 | } 37 | } 38 | for (i = 0; i < NITER; i++) { 39 | if (ps[i] != NULL) { 40 | sdallocx(ps[i], sz, 41 | MALLOCX_ALIGN(alignment)); 42 | ps[i] = NULL; 43 | } 44 | } 45 | } 46 | } 47 | } 48 | TEST_END 49 | 50 | int 51 | main(void) { 52 | return test_no_reentrancy( 53 | test_basic, 54 | test_alignment_and_size); 55 | } 56 | -------------------------------------------------------------------------------- /deps/jemalloc/include/msvc_compat/strings.h: -------------------------------------------------------------------------------- 1 | #ifndef strings_h 2 | #define strings_h 3 | 4 | /* MSVC doesn't define ffs/ffsl. This dummy strings.h header is provided 5 | * for both */ 6 | #ifdef _MSC_VER 7 | # include 8 | # pragma intrinsic(_BitScanForward) 9 | static __forceinline int ffsl(long x) { 10 | unsigned long i; 11 | 12 | if (_BitScanForward(&i, x)) { 13 | return i + 1; 14 | } 15 | return 0; 16 | } 17 | 18 | static __forceinline int ffs(int x) { 19 | return ffsl(x); 20 | } 21 | 22 | # ifdef _M_X64 23 | # pragma intrinsic(_BitScanForward64) 24 | # endif 25 | 26 | static __forceinline int ffsll(unsigned __int64 x) { 27 | unsigned long i; 28 | #ifdef _M_X64 29 | if (_BitScanForward64(&i, x)) { 30 | return i + 1; 31 | } 32 | return 0; 33 | #else 34 | // Fallback for 32-bit build where 64-bit version not available 35 | // assuming little endian 36 | union { 37 | unsigned __int64 ll; 38 | unsigned long l[2]; 39 | } s; 40 | 41 | s.ll = x; 42 | 43 | if (_BitScanForward(&i, s.l[0])) { 44 | return i + 1; 45 | } else if(_BitScanForward(&i, s.l[1])) { 46 | return i + 33; 47 | } 48 | return 0; 49 | #endif 50 | } 51 | 52 | #else 53 | # define ffsll(x) __builtin_ffsll(x) 54 | # define ffsl(x) __builtin_ffsl(x) 55 | # define ffs(x) __builtin_ffs(x) 56 | #endif 57 | 58 | #endif /* strings_h */ 59 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/timer.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | void 4 | timer_start(timedelta_t *timer) { 5 | nstime_init(&timer->t0, 0); 6 | nstime_update(&timer->t0); 7 | } 8 | 9 | void 10 | timer_stop(timedelta_t *timer) { 11 | nstime_copy(&timer->t1, &timer->t0); 12 | nstime_update(&timer->t1); 13 | } 14 | 15 | uint64_t 16 | timer_usec(const timedelta_t *timer) { 17 | nstime_t delta; 18 | 19 | nstime_copy(&delta, &timer->t1); 20 | nstime_subtract(&delta, &timer->t0); 21 | return nstime_ns(&delta) / 1000; 22 | } 23 | 24 | void 25 | timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen) { 26 | uint64_t t0 = timer_usec(a); 27 | uint64_t t1 = timer_usec(b); 28 | uint64_t mult; 29 | size_t i = 0; 30 | size_t j, n; 31 | 32 | /* Whole. */ 33 | n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1); 34 | i += n; 35 | if (i >= buflen) { 36 | return; 37 | } 38 | mult = 1; 39 | for (j = 0; j < n; j++) { 40 | mult *= 10; 41 | } 42 | 43 | /* Decimal. */ 44 | n = malloc_snprintf(&buf[i], buflen-i, "."); 45 | i += n; 46 | 47 | /* Fraction. */ 48 | while (i < buflen-1) { 49 | uint64_t round = (i+1 == buflen-1 && ((t0 * mult * 10 / t1) % 10 50 | >= 5)) ? 1 : 0; 51 | n = malloc_snprintf(&buf[i], buflen-i, 52 | "%"FMTu64, (t0 * mult / t1) % 10 + round); 53 | i += n; 54 | mult *= 10; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /deps/lua/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.nk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define key2tval(n) (&(n)->i_key.tvk) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); 22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 25 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 28 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 29 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 30 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 31 | LUAI_FUNC int luaH_getn (Table *t); 32 | 33 | 34 | #if defined(LUA_DEBUG) 35 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 36 | LUAI_FUNC int luaH_isdummy (Node *n); 37 | #endif 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /utils/releasetools/changelog.tcl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env tclsh 2 | 3 | if {[llength $::argv] != 2 && [llength $::argv] != 3} { 4 | puts "Usage: $::argv0 \[\]" 5 | exit 1 6 | } 7 | 8 | set branch [lindex $::argv 0] 9 | set ver [lindex $::argv 1] 10 | if {[llength $::argv] == 3} { 11 | set count [lindex ::$argv 2] 12 | } else { 13 | set count 100 14 | } 15 | 16 | set template { 17 | ================================================================================ 18 | Redis %ver% Released %date% 19 | ================================================================================ 20 | 21 | Upgrade urgency : 22 | } 23 | 24 | set template [string trim $template] 25 | append template "\n\n" 26 | set date [clock format [clock seconds]] 27 | set template [string map [list %ver% $ver %date% $date] $template] 28 | 29 | append template [exec git log $branch~$count..$branch "--format=format:%an in commit %h:%n %s" --shortstat] 30 | 31 | #Older, more verbose version. 32 | # 33 | #append template [exec git log $branch~30..$branch "--format=format:+-------------------------------------------------------------------------------%n| %s%n| By %an, %ai%n+--------------------------------------------------------------------------------%nhttps://github.com/antirez/redis/commit/%H%n%n%b" --stat] 34 | 35 | puts $template 36 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/jemalloc_defs.h.in: -------------------------------------------------------------------------------- 1 | /* Defined if __attribute__((...)) syntax is supported. */ 2 | #undef JEMALLOC_HAVE_ATTR 3 | 4 | /* Defined if alloc_size attribute is supported. */ 5 | #undef JEMALLOC_HAVE_ATTR_ALLOC_SIZE 6 | 7 | /* Defined if format(gnu_printf, ...) attribute is supported. */ 8 | #undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF 9 | 10 | /* Defined if format(printf, ...) attribute is supported. */ 11 | #undef JEMALLOC_HAVE_ATTR_FORMAT_PRINTF 12 | 13 | /* 14 | * Define overrides for non-standard allocator-related functions if they are 15 | * present on the system. 16 | */ 17 | #undef JEMALLOC_OVERRIDE_MEMALIGN 18 | #undef JEMALLOC_OVERRIDE_VALLOC 19 | 20 | /* 21 | * At least Linux omits the "const" in: 22 | * 23 | * size_t malloc_usable_size(const void *ptr); 24 | * 25 | * Match the operating system's prototype. 26 | */ 27 | #undef JEMALLOC_USABLE_SIZE_CONST 28 | 29 | /* 30 | * If defined, specify throw() for the public function prototypes when compiling 31 | * with C++. The only justification for this is to match the prototypes that 32 | * glibc defines. 33 | */ 34 | #undef JEMALLOC_USE_CXX_THROW 35 | 36 | #ifdef _MSC_VER 37 | # ifdef _WIN64 38 | # define LG_SIZEOF_PTR_WIN 3 39 | # else 40 | # define LG_SIZEOF_PTR_WIN 2 41 | # endif 42 | #endif 43 | 44 | /* sizeof(void *) == 2^LG_SIZEOF_PTR. */ 45 | #undef LG_SIZEOF_PTR 46 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/div.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_DIV_H 2 | #define JEMALLOC_INTERNAL_DIV_H 3 | 4 | #include "jemalloc/internal/assert.h" 5 | 6 | /* 7 | * This module does the division that computes the index of a region in a slab, 8 | * given its offset relative to the base. 9 | * That is, given a divisor d, an n = i * d (all integers), we'll return i. 10 | * We do some pre-computation to do this more quickly than a CPU division 11 | * instruction. 12 | * We bound n < 2^32, and don't support dividing by one. 13 | */ 14 | 15 | typedef struct div_info_s div_info_t; 16 | struct div_info_s { 17 | uint32_t magic; 18 | #ifdef JEMALLOC_DEBUG 19 | size_t d; 20 | #endif 21 | }; 22 | 23 | void div_init(div_info_t *div_info, size_t divisor); 24 | 25 | static inline size_t 26 | div_compute(div_info_t *div_info, size_t n) { 27 | assert(n <= (uint32_t)-1); 28 | /* 29 | * This generates, e.g. mov; imul; shr on x86-64. On a 32-bit machine, 30 | * the compilers I tried were all smart enough to turn this into the 31 | * appropriate "get the high 32 bits of the result of a multiply" (e.g. 32 | * mul; mov edx eax; on x86, umull on arm, etc.). 33 | */ 34 | size_t i = ((uint64_t)n * (uint64_t)div_info->magic) >> 32; 35 | #ifdef JEMALLOC_DEBUG 36 | assert(i * div_info->d == n); 37 | #endif 38 | return i; 39 | } 40 | 41 | #endif /* JEMALLOC_INTERNAL_DIV_H */ 42 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/large_externs.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_LARGE_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_LARGE_EXTERNS_H 3 | 4 | void *large_malloc(tsdn_t *tsdn, arena_t *arena, size_t usize, bool zero); 5 | void *large_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment, 6 | bool zero); 7 | bool large_ralloc_no_move(tsdn_t *tsdn, extent_t *extent, size_t usize_min, 8 | size_t usize_max, bool zero); 9 | void *large_ralloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent, size_t usize, 10 | size_t alignment, bool zero, tcache_t *tcache); 11 | 12 | typedef void (large_dalloc_junk_t)(void *, size_t); 13 | extern large_dalloc_junk_t *JET_MUTABLE large_dalloc_junk; 14 | 15 | typedef void (large_dalloc_maybe_junk_t)(void *, size_t); 16 | extern large_dalloc_maybe_junk_t *JET_MUTABLE large_dalloc_maybe_junk; 17 | 18 | void large_dalloc_prep_junked_locked(tsdn_t *tsdn, extent_t *extent); 19 | void large_dalloc_finish(tsdn_t *tsdn, extent_t *extent); 20 | void large_dalloc(tsdn_t *tsdn, extent_t *extent); 21 | size_t large_salloc(tsdn_t *tsdn, const extent_t *extent); 22 | prof_tctx_t *large_prof_tctx_get(tsdn_t *tsdn, const extent_t *extent); 23 | void large_prof_tctx_set(tsdn_t *tsdn, extent_t *extent, prof_tctx_t *tctx); 24 | void large_prof_tctx_reset(tsdn_t *tsdn, extent_t *extent); 25 | 26 | #endif /* JEMALLOC_INTERNAL_LARGE_EXTERNS_H */ 27 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/tsd_tls.h: -------------------------------------------------------------------------------- 1 | #ifdef JEMALLOC_INTERNAL_TSD_TLS_H 2 | #error This file should be included only once, by tsd.h. 3 | #endif 4 | #define JEMALLOC_INTERNAL_TSD_TLS_H 5 | 6 | extern __thread tsd_t tsd_tls; 7 | extern pthread_key_t tsd_tsd; 8 | extern bool tsd_booted; 9 | 10 | /* Initialization/cleanup. */ 11 | JEMALLOC_ALWAYS_INLINE bool 12 | tsd_boot0(void) { 13 | if (pthread_key_create(&tsd_tsd, &tsd_cleanup) != 0) { 14 | return true; 15 | } 16 | tsd_booted = true; 17 | return false; 18 | } 19 | 20 | JEMALLOC_ALWAYS_INLINE void 21 | tsd_boot1(void) { 22 | /* Do nothing. */ 23 | } 24 | 25 | JEMALLOC_ALWAYS_INLINE bool 26 | tsd_boot(void) { 27 | return tsd_boot0(); 28 | } 29 | 30 | JEMALLOC_ALWAYS_INLINE bool 31 | tsd_booted_get(void) { 32 | return tsd_booted; 33 | } 34 | 35 | JEMALLOC_ALWAYS_INLINE bool 36 | tsd_get_allocates(void) { 37 | return false; 38 | } 39 | 40 | /* Get/set. */ 41 | JEMALLOC_ALWAYS_INLINE tsd_t * 42 | tsd_get(UNUSED bool init) { 43 | assert(tsd_booted); 44 | return &tsd_tls; 45 | } 46 | 47 | JEMALLOC_ALWAYS_INLINE void 48 | tsd_set(tsd_t *val) { 49 | assert(tsd_booted); 50 | if (likely(&tsd_tls != val)) { 51 | tsd_tls = (*val); 52 | } 53 | if (pthread_setspecific(tsd_tsd, (void *)(&tsd_tls)) != 0) { 54 | malloc_write(": Error setting tsd.\n"); 55 | if (opt_abort) { 56 | abort(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/unit/lazyfree.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"lazyfree"}} { 2 | test "UNLINK can reclaim memory in background" { 3 | set orig_mem [s used_memory] 4 | set args {} 5 | for {set i 0} {$i < 100000} {incr i} { 6 | lappend args $i 7 | } 8 | r sadd myset {*}$args 9 | assert {[r scard myset] == 100000} 10 | set peak_mem [s used_memory] 11 | assert {[r unlink myset] == 1} 12 | assert {$peak_mem > $orig_mem+1000000} 13 | wait_for_condition 50 100 { 14 | [s used_memory] < $peak_mem && 15 | [s used_memory] < $orig_mem*2 16 | } else { 17 | fail "Memory is not reclaimed by UNLINK" 18 | } 19 | } 20 | 21 | test "FLUSHDB ASYNC can reclaim memory in background" { 22 | set orig_mem [s used_memory] 23 | set args {} 24 | for {set i 0} {$i < 100000} {incr i} { 25 | lappend args $i 26 | } 27 | r sadd myset {*}$args 28 | assert {[r scard myset] == 100000} 29 | set peak_mem [s used_memory] 30 | r flushdb async 31 | assert {$peak_mem > $orig_mem+1000000} 32 | wait_for_condition 50 100 { 33 | [s used_memory] < $peak_mem && 34 | [s used_memory] < $orig_mem*2 35 | } else { 36 | fail "Memory is not reclaimed by FLUSHDB ASYNC" 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/private_symbols.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Generate private_symbols[_jet].awk. 4 | # 5 | # Usage: private_symbols.sh * 6 | # 7 | # is typically "" or "_". 8 | 9 | sym_prefix=$1 10 | shift 11 | 12 | cat <' output. 35 | # 36 | # Handle lines like: 37 | # 0000000000000008 D opt_junk 38 | # 0000000000007574 T malloc_initialized 39 | (NF == 3 && $2 ~ /^[ABCDGRSTVW]$/ && !($3 in exported_symbols) && $3 ~ /^[A-Za-z0-9_]+$/) { 40 | print substr($3, 1+length(sym_prefix), length($3)-length(sym_prefix)) 41 | } 42 | 43 | # Process 'dumpbin /SYMBOLS ' output. 44 | # 45 | # Handle lines like: 46 | # 353 00008098 SECT4 notype External | opt_junk 47 | # 3F1 00000000 SECT7 notype () External | malloc_initialized 48 | ($3 ~ /^SECT[0-9]+/ && $(NF-2) == "External" && !($NF in exported_symbols)) { 49 | print $NF 50 | } 51 | EOF 52 | -------------------------------------------------------------------------------- /tests/cluster/tests/15-cluster-slots.tcl: -------------------------------------------------------------------------------- 1 | source "../tests/includes/init-tests.tcl" 2 | 3 | proc cluster_allocate_mixedSlots {n} { 4 | set slot 16383 5 | while {$slot >= 0} { 6 | set node [expr {$slot % $n}] 7 | lappend slots_$node $slot 8 | incr slot -1 9 | } 10 | for {set j 0} {$j < $n} {incr j} { 11 | R $j cluster addslots {*}[set slots_${j}] 12 | } 13 | } 14 | 15 | proc create_cluster_with_mixedSlot {masters slaves} { 16 | cluster_allocate_mixedSlots $masters 17 | if {$slaves} { 18 | cluster_allocate_slaves $masters $slaves 19 | } 20 | assert_cluster_state ok 21 | } 22 | 23 | test "Create a 5 nodes cluster" { 24 | create_cluster_with_mixedSlot 5 15 25 | } 26 | 27 | test "Cluster is up" { 28 | assert_cluster_state ok 29 | } 30 | 31 | test "Cluster is writable" { 32 | cluster_write_test 0 33 | } 34 | 35 | test "Instance #5 is a slave" { 36 | assert {[RI 5 role] eq {slave}} 37 | } 38 | 39 | test "client do not break when cluster slot" { 40 | R 0 config set client-output-buffer-limit "normal 33554432 16777216 60" 41 | if { [catch {R 0 cluster slots}] } { 42 | fail "output overflow when cluster slots" 43 | } 44 | } 45 | 46 | test "client can handle keys with hash tag" { 47 | set cluster [redis_cluster 127.0.0.1:[get_instance_attrib redis 0 port]] 48 | $cluster set foo{tag} bar 49 | $cluster close 50 | } 51 | -------------------------------------------------------------------------------- /utils/redis-copy.rb: -------------------------------------------------------------------------------- 1 | # redis-copy.rb - Copyright (C) 2009-2010 Salvatore Sanfilippo 2 | # BSD license, See the COPYING file for more information. 3 | # 4 | # Copy the whole dataset from one Redis instance to another one 5 | # 6 | # WARNING: this utility is deprecated and serves as a legacy adapter 7 | # for the more-robust redis-copy gem. 8 | 9 | require 'shellwords' 10 | 11 | def redisCopy(opts={}) 12 | src = "#{opts[:srchost]}:#{opts[:srcport]}" 13 | dst = "#{opts[:dsthost]}:#{opts[:dstport]}" 14 | `redis-copy #{src.shellescape} #{dst.shellescape}` 15 | rescue Errno::ENOENT 16 | $stderr.puts 'This utility requires the redis-copy executable', 17 | 'from the redis-copy gem on https://rubygems.org', 18 | 'To install it, run `gem install redis-copy`.' 19 | exit 1 20 | end 21 | 22 | $stderr.puts "This utility is deprecated. Use the redis-copy gem instead." 23 | if ARGV.length != 4 24 | puts "Usage: redis-copy.rb " 25 | exit 1 26 | end 27 | puts "WARNING: it's up to you to FLUSHDB the destination host before to continue, press any key when ready." 28 | STDIN.gets 29 | srchost = ARGV[0] 30 | srcport = ARGV[1] 31 | dsthost = ARGV[2] 32 | dstport = ARGV[3] 33 | puts "Copying #{srchost}:#{srcport} into #{dsthost}:#{dstport}" 34 | redisCopy(:srchost => srchost, :srcport => srcport.to_i, 35 | :dsthost => dsthost, :dstport => dstport.to_i) 36 | -------------------------------------------------------------------------------- /tests/sentinel/tests/01-conf-update.tcl: -------------------------------------------------------------------------------- 1 | # Test Sentinel configuration consistency after partitions heal. 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "We can failover with Sentinel 1 crashed" { 6 | set old_port [RI $master_id tcp_port] 7 | set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 8 | assert {[lindex $addr 1] == $old_port} 9 | 10 | # Crash Sentinel 1 11 | kill_instance sentinel 1 12 | 13 | kill_instance redis $master_id 14 | foreach_sentinel_id id { 15 | if {$id != 1} { 16 | wait_for_condition 1000 50 { 17 | [lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port 18 | } else { 19 | fail "Sentinel $id did not receive failover info" 20 | } 21 | } 22 | } 23 | restart_instance redis $master_id 24 | set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 25 | set master_id [get_instance_id_by_port redis [lindex $addr 1]] 26 | } 27 | 28 | test "After Sentinel 1 is restarted, its config gets updated" { 29 | restart_instance sentinel 1 30 | wait_for_condition 1000 50 { 31 | [lindex [S 1 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port 32 | } else { 33 | fail "Restarted Sentinel did not receive failover info" 34 | } 35 | } 36 | 37 | test "New master [join $addr {:}] role matches" { 38 | assert {[RI $master_id role] eq {master}} 39 | } 40 | -------------------------------------------------------------------------------- /deps/hiredis/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | # Check for GLib 3 | 4 | PKG_CHECK_MODULES(GLIB2 glib-2.0) 5 | if (GLIB2_FOUND) 6 | INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS}) 7 | LINK_DIRECTORIES(${GLIB2_LIBRARY_DIRS}) 8 | ADD_EXECUTABLE(example-glib example-glib.c) 9 | TARGET_LINK_LIBRARIES(example-glib hiredis ${GLIB2_LIBRARIES}) 10 | ENDIF(GLIB2_FOUND) 11 | 12 | FIND_PATH(LIBEV ev.h 13 | HINTS /usr/local /usr/opt/local 14 | ENV LIBEV_INCLUDE_DIR) 15 | 16 | if (LIBEV) 17 | # Just compile and link with libev 18 | ADD_EXECUTABLE(example-libev example-libev.c) 19 | TARGET_LINK_LIBRARIES(example-libev hiredis ev) 20 | ENDIF() 21 | 22 | FIND_PATH(LIBEVENT event.h) 23 | if (LIBEVENT) 24 | ADD_EXECUTABLE(example-libevent example-libevent) 25 | TARGET_LINK_LIBRARIES(example-libevent hiredis event) 26 | ENDIF() 27 | 28 | FIND_PATH(LIBUV uv.h) 29 | IF (LIBUV) 30 | ADD_EXECUTABLE(example-libuv example-libuv.c) 31 | TARGET_LINK_LIBRARIES(example-libuv hiredis uv) 32 | ENDIF() 33 | 34 | IF (APPLE) 35 | FIND_LIBRARY(CF CoreFoundation) 36 | ADD_EXECUTABLE(example-macosx example-macosx.c) 37 | TARGET_LINK_LIBRARIES(example-macosx hiredis ${CF}) 38 | ENDIF() 39 | 40 | IF (ENABLE_SSL) 41 | ADD_EXECUTABLE(example-ssl example-ssl.c) 42 | TARGET_LINK_LIBRARIES(example-ssl hiredis hiredis_ssl) 43 | ENDIF() 44 | 45 | ADD_EXECUTABLE(example example.c) 46 | TARGET_LINK_LIBRARIES(example hiredis) 47 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/tsd_malloc_thread_cleanup.h: -------------------------------------------------------------------------------- 1 | #ifdef JEMALLOC_INTERNAL_TSD_MALLOC_THREAD_CLEANUP_H 2 | #error This file should be included only once, by tsd.h. 3 | #endif 4 | #define JEMALLOC_INTERNAL_TSD_MALLOC_THREAD_CLEANUP_H 5 | 6 | extern __thread tsd_t tsd_tls; 7 | extern __thread bool tsd_initialized; 8 | extern bool tsd_booted; 9 | 10 | /* Initialization/cleanup. */ 11 | JEMALLOC_ALWAYS_INLINE bool 12 | tsd_cleanup_wrapper(void) { 13 | if (tsd_initialized) { 14 | tsd_initialized = false; 15 | tsd_cleanup(&tsd_tls); 16 | } 17 | return tsd_initialized; 18 | } 19 | 20 | JEMALLOC_ALWAYS_INLINE bool 21 | tsd_boot0(void) { 22 | malloc_tsd_cleanup_register(&tsd_cleanup_wrapper); 23 | tsd_booted = true; 24 | return false; 25 | } 26 | 27 | JEMALLOC_ALWAYS_INLINE void 28 | tsd_boot1(void) { 29 | /* Do nothing. */ 30 | } 31 | 32 | JEMALLOC_ALWAYS_INLINE bool 33 | tsd_boot(void) { 34 | return tsd_boot0(); 35 | } 36 | 37 | JEMALLOC_ALWAYS_INLINE bool 38 | tsd_booted_get(void) { 39 | return tsd_booted; 40 | } 41 | 42 | JEMALLOC_ALWAYS_INLINE bool 43 | tsd_get_allocates(void) { 44 | return false; 45 | } 46 | 47 | /* Get/set. */ 48 | JEMALLOC_ALWAYS_INLINE tsd_t * 49 | tsd_get(bool init) { 50 | assert(tsd_booted); 51 | return &tsd_tls; 52 | } 53 | JEMALLOC_ALWAYS_INLINE void 54 | tsd_set(tsd_t *val) { 55 | assert(tsd_booted); 56 | if (likely(&tsd_tls != val)) { 57 | tsd_tls = (*val); 58 | } 59 | tsd_initialized = true; 60 | } 61 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/nstime.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_NSTIME_H 2 | #define JEMALLOC_INTERNAL_NSTIME_H 3 | 4 | /* Maximum supported number of seconds (~584 years). */ 5 | #define NSTIME_SEC_MAX KQU(18446744072) 6 | #define NSTIME_ZERO_INITIALIZER {0} 7 | 8 | typedef struct { 9 | uint64_t ns; 10 | } nstime_t; 11 | 12 | void nstime_init(nstime_t *time, uint64_t ns); 13 | void nstime_init2(nstime_t *time, uint64_t sec, uint64_t nsec); 14 | uint64_t nstime_ns(const nstime_t *time); 15 | uint64_t nstime_sec(const nstime_t *time); 16 | uint64_t nstime_msec(const nstime_t *time); 17 | uint64_t nstime_nsec(const nstime_t *time); 18 | void nstime_copy(nstime_t *time, const nstime_t *source); 19 | int nstime_compare(const nstime_t *a, const nstime_t *b); 20 | void nstime_add(nstime_t *time, const nstime_t *addend); 21 | void nstime_iadd(nstime_t *time, uint64_t addend); 22 | void nstime_subtract(nstime_t *time, const nstime_t *subtrahend); 23 | void nstime_isubtract(nstime_t *time, uint64_t subtrahend); 24 | void nstime_imultiply(nstime_t *time, uint64_t multiplier); 25 | void nstime_idivide(nstime_t *time, uint64_t divisor); 26 | uint64_t nstime_divide(const nstime_t *time, const nstime_t *divisor); 27 | 28 | typedef bool (nstime_monotonic_t)(void); 29 | extern nstime_monotonic_t *JET_MUTABLE nstime_monotonic; 30 | 31 | typedef bool (nstime_update_t)(nstime_t *); 32 | extern nstime_update_t *JET_MUTABLE nstime_update; 33 | 34 | #endif /* JEMALLOC_INTERNAL_NSTIME_H */ 35 | -------------------------------------------------------------------------------- /tests/unit/moduleapi/scan.tcl: -------------------------------------------------------------------------------- 1 | set testmodule [file normalize tests/modules/scan.so] 2 | 3 | start_server {tags {"modules"}} { 4 | r module load $testmodule 5 | 6 | test {Module scan keyspace} { 7 | # the module create a scan command with filtering which also return values 8 | r set x 1 9 | r set y 2 10 | r set z 3 11 | r hset h f v 12 | lsort [r scan.scan_strings] 13 | } {{x 1} {y 2} {z 3}} 14 | 15 | test {Module scan hash ziplist} { 16 | r hmset hh f1 v1 f2 v2 17 | lsort [r scan.scan_key hh] 18 | } {{f1 v1} {f2 v2}} 19 | 20 | test {Module scan hash dict} { 21 | r config set hash-max-ziplist-entries 2 22 | r hmset hh f3 v3 23 | lsort [r scan.scan_key hh] 24 | } {{f1 v1} {f2 v2} {f3 v3}} 25 | 26 | test {Module scan zset ziplist} { 27 | r zadd zz 1 f1 2 f2 28 | lsort [r scan.scan_key zz] 29 | } {{f1 1} {f2 2}} 30 | 31 | test {Module scan zset dict} { 32 | r config set zset-max-ziplist-entries 2 33 | r zadd zz 3 f3 34 | lsort [r scan.scan_key zz] 35 | } {{f1 1} {f2 2} {f3 3}} 36 | 37 | test {Module scan set intset} { 38 | r sadd ss 1 2 39 | lsort [r scan.scan_key ss] 40 | } {{1 {}} {2 {}}} 41 | 42 | test {Module scan set dict} { 43 | r config set set-max-intset-entries 2 44 | r sadd ss 3 45 | lsort [r scan.scan_key ss] 46 | } {{1 {}} {2 {}} {3 {}}} 47 | } 48 | -------------------------------------------------------------------------------- /deps/lua/etc/noparser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The code below can be used to make a Lua core that does not contain the 3 | * parsing modules (lcode, llex, lparser), which represent 35% of the total core. 4 | * You'll only be able to load binary files and strings, precompiled with luac. 5 | * (Of course, you'll have to build luac with the original parsing modules!) 6 | * 7 | * To use this module, simply compile it ("make noparser" does that) and list 8 | * its object file before the Lua libraries. The linker should then not load 9 | * the parsing modules. To try it, do "make luab". 10 | * 11 | * If you also want to avoid the dump module (ldump.o), define NODUMP. 12 | * #define NODUMP 13 | */ 14 | 15 | #define LUA_CORE 16 | 17 | #include "llex.h" 18 | #include "lparser.h" 19 | #include "lzio.h" 20 | 21 | LUAI_FUNC void luaX_init (lua_State *L) { 22 | UNUSED(L); 23 | } 24 | 25 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { 26 | UNUSED(z); 27 | UNUSED(buff); 28 | UNUSED(name); 29 | lua_pushliteral(L,"parser not loaded"); 30 | lua_error(L); 31 | return NULL; 32 | } 33 | 34 | #ifdef NODUMP 35 | #include "lundump.h" 36 | 37 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) { 38 | UNUSED(f); 39 | UNUSED(w); 40 | UNUSED(data); 41 | UNUSED(strip); 42 | #if 1 43 | UNUSED(L); 44 | return 0; 45 | #else 46 | lua_pushliteral(L,"dumper not loaded"); 47 | lua_error(L); 48 | #endif 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /tests/integration/convert-zipmap-hash-on-load.tcl: -------------------------------------------------------------------------------- 1 | # Copy RDB with zipmap encoded hash to server path 2 | set server_path [tmpdir "server.convert-zipmap-hash-on-load"] 3 | 4 | exec cp -f tests/assets/hash-zipmap.rdb $server_path 5 | start_server [list overrides [list "dir" $server_path "dbfilename" "hash-zipmap.rdb"]] { 6 | test "RDB load zipmap hash: converts to ziplist" { 7 | r select 0 8 | 9 | assert_match "*ziplist*" [r debug object hash] 10 | assert_equal 2 [r hlen hash] 11 | assert_match {v1 v2} [r hmget hash f1 f2] 12 | } 13 | } 14 | 15 | exec cp -f tests/assets/hash-zipmap.rdb $server_path 16 | start_server [list overrides [list "dir" $server_path "dbfilename" "hash-zipmap.rdb" "hash-max-ziplist-entries" 1]] { 17 | test "RDB load zipmap hash: converts to hash table when hash-max-ziplist-entries is exceeded" { 18 | r select 0 19 | 20 | assert_match "*hashtable*" [r debug object hash] 21 | assert_equal 2 [r hlen hash] 22 | assert_match {v1 v2} [r hmget hash f1 f2] 23 | } 24 | } 25 | 26 | exec cp -f tests/assets/hash-zipmap.rdb $server_path 27 | start_server [list overrides [list "dir" $server_path "dbfilename" "hash-zipmap.rdb" "hash-max-ziplist-value" 1]] { 28 | test "RDB load zipmap hash: converts to hash table when hash-max-ziplist-value is exceeded" { 29 | r select 0 30 | 31 | assert_match "*hashtable*" [r debug object hash] 32 | assert_equal 2 [r hlen hash] 33 | assert_match {v1 v2} [r hmget hash f1 f2] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/jemalloc_mangle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -eu 2 | 3 | public_symbols_txt=$1 4 | symbol_prefix=$2 5 | 6 | cat < 0} {} 26 | 27 | # Check contents of foo 28 | assert_equal 20000 [$client get foo] 29 | } 30 | 31 | # Restart server to replay AOF 32 | start_server_aof [list dir $server_path] { 33 | set client [redis [srv host] [srv port] 0 $::tls] 34 | assert_equal 20000 [$client get foo] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /utils/systemd-redis_multiple_servers@.service: -------------------------------------------------------------------------------- 1 | # example systemd template service unit file for multiple redis-servers 2 | # 3 | # You can use this file as a blueprint for your actual template service unit 4 | # file, if you intend to run multiple independent redis-server instances in 5 | # parallel using systemd's "template unit files" feature. If you do, you will 6 | # want to choose a better basename for your service unit by renaming this file 7 | # when copying it. 8 | # 9 | # Please take a look at the provided "systemd-redis_server.service" example 10 | # service unit file, too, if you choose to use this approach at managing 11 | # multiple redis-server instances via systemd. 12 | 13 | [Unit] 14 | Description=Redis data structure server - instance %i 15 | Documentation=https://redis.io/documentation 16 | # This template unit assumes your redis-server configuration file(s) 17 | # to live at /etc/redis/redis_server_.conf 18 | AssertPathExists=/etc/redis/redis_server_%i.conf 19 | #Before=your_application.service another_example_application.service 20 | #AssertPathExists=/var/lib/redis 21 | 22 | [Service] 23 | ExecStart=/usr/local/bin/redis-server /etc/redis/redis_server_%i.conf 24 | LimitNOFILE=10032 25 | NoNewPrivileges=yes 26 | #OOMScoreAdjust=-900 27 | #PrivateTmp=yes 28 | Type=notify 29 | TimeoutStartSec=infinity 30 | TimeoutStopSec=infinity 31 | UMask=0077 32 | #User=redis 33 | #Group=redis 34 | #WorkingDirectory=/var/lib/redis 35 | 36 | [Install] 37 | WantedBy=multi-user.target 38 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2015, Salvatore Sanfilippo 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | * Neither the name of Redis nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/prof_tctx.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_prof_realloc) { 4 | tsdn_t *tsdn; 5 | int flags; 6 | void *p, *q; 7 | prof_tctx_t *tctx_p, *tctx_q; 8 | uint64_t curobjs_0, curobjs_1, curobjs_2, curobjs_3; 9 | 10 | test_skip_if(!config_prof); 11 | 12 | tsdn = tsdn_fetch(); 13 | flags = MALLOCX_TCACHE_NONE; 14 | 15 | prof_cnt_all(&curobjs_0, NULL, NULL, NULL); 16 | p = mallocx(1024, flags); 17 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); 18 | tctx_p = prof_tctx_get(tsdn, p, NULL); 19 | assert_ptr_ne(tctx_p, (prof_tctx_t *)(uintptr_t)1U, 20 | "Expected valid tctx"); 21 | prof_cnt_all(&curobjs_1, NULL, NULL, NULL); 22 | assert_u64_eq(curobjs_0 + 1, curobjs_1, 23 | "Allocation should have increased sample size"); 24 | 25 | q = rallocx(p, 2048, flags); 26 | assert_ptr_ne(p, q, "Expected move"); 27 | assert_ptr_not_null(p, "Unexpected rmallocx() failure"); 28 | tctx_q = prof_tctx_get(tsdn, q, NULL); 29 | assert_ptr_ne(tctx_q, (prof_tctx_t *)(uintptr_t)1U, 30 | "Expected valid tctx"); 31 | prof_cnt_all(&curobjs_2, NULL, NULL, NULL); 32 | assert_u64_eq(curobjs_1, curobjs_2, 33 | "Reallocation should not have changed sample size"); 34 | 35 | dallocx(q, flags); 36 | prof_cnt_all(&curobjs_3, NULL, NULL, NULL); 37 | assert_u64_eq(curobjs_0, curobjs_3, 38 | "Sample size should have returned to base level"); 39 | } 40 | TEST_END 41 | 42 | int 43 | main(void) { 44 | return test_no_reentrancy( 45 | test_prof_realloc); 46 | } 47 | -------------------------------------------------------------------------------- /tests/unit/wait.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/cli.tcl 2 | 3 | start_server {tags {"wait"}} { 4 | start_server {} { 5 | set slave [srv 0 client] 6 | set slave_host [srv 0 host] 7 | set slave_port [srv 0 port] 8 | set master [srv -1 client] 9 | set master_host [srv -1 host] 10 | set master_port [srv -1 port] 11 | 12 | test {Setup slave} { 13 | $slave slaveof $master_host $master_port 14 | wait_for_condition 50 100 { 15 | [s 0 master_link_status] eq {up} 16 | } else { 17 | fail "Replication not started." 18 | } 19 | } 20 | 21 | test {WAIT should acknowledge 1 additional copy of the data} { 22 | $master set foo 0 23 | $master incr foo 24 | $master incr foo 25 | $master incr foo 26 | assert {[$master wait 1 5000] == 1} 27 | assert {[$slave get foo] == 3} 28 | } 29 | 30 | test {WAIT should not acknowledge 2 additional copies of the data} { 31 | $master incr foo 32 | assert {[$master wait 2 1000] <= 1} 33 | } 34 | 35 | test {WAIT should not acknowledge 1 additional copy if slave is blocked} { 36 | set cmd [rediscli $slave_port "-h $slave_host debug sleep 5"] 37 | exec {*}$cmd > /dev/null 2> /dev/null & 38 | after 1000 ;# Give redis-cli the time to execute the command. 39 | $master set foo 0 40 | $master incr foo 41 | $master incr foo 42 | $master incr foo 43 | assert {[$master wait 1 3000] == 0} 44 | } 45 | }} 46 | -------------------------------------------------------------------------------- /deps/lua/README: -------------------------------------------------------------------------------- 1 | README for Lua 5.1 2 | 3 | See INSTALL for installation instructions. 4 | See HISTORY for a summary of changes since the last released version. 5 | 6 | * What is Lua? 7 | ------------ 8 | Lua is a powerful, light-weight programming language designed for extending 9 | applications. Lua is also frequently used as a general-purpose, stand-alone 10 | language. Lua is free software. 11 | 12 | For complete information, visit Lua's web site at http://www.lua.org/ . 13 | For an executive summary, see http://www.lua.org/about.html . 14 | 15 | Lua has been used in many different projects around the world. 16 | For a short list, see http://www.lua.org/uses.html . 17 | 18 | * Availability 19 | ------------ 20 | Lua is freely available for both academic and commercial purposes. 21 | See COPYRIGHT and http://www.lua.org/license.html for details. 22 | Lua can be downloaded at http://www.lua.org/download.html . 23 | 24 | * Installation 25 | ------------ 26 | Lua is implemented in pure ANSI C, and compiles unmodified in all known 27 | platforms that have an ANSI C compiler. In most Unix-like platforms, simply 28 | do "make" with a suitable target. See INSTALL for detailed instructions. 29 | 30 | * Origin 31 | ------ 32 | Lua is developed at Lua.org, a laboratory of the Department of Computer 33 | Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro 34 | in Brazil). 35 | For more information about the authors, see http://www.lua.org/authors.html . 36 | 37 | (end of README) 38 | -------------------------------------------------------------------------------- /utils/cluster_fail_time.tcl: -------------------------------------------------------------------------------- 1 | # This simple script is used in order to estimate the average PFAIL->FAIL 2 | # state switch after a failure. 3 | 4 | set ::sleep_time 10 ; # How much to sleep to trigger PFAIL. 5 | set ::fail_port 30016 ; # Node to put in sleep. 6 | set ::other_port 30001 ; # Node to use to monitor the flag switch. 7 | 8 | proc avg vector { 9 | set sum 0.0 10 | foreach x $vector { 11 | set sum [expr {$sum+$x}] 12 | } 13 | expr {$sum/[llength $vector]} 14 | } 15 | 16 | set samples {} 17 | while 1 { 18 | exec redis-cli -p $::fail_port debug sleep $::sleep_time > /dev/null & 19 | 20 | # Wait for fail? to appear. 21 | while 1 { 22 | set output [exec redis-cli -p $::other_port cluster nodes] 23 | if {[string match {*fail\?*} $output]} break 24 | after 100 25 | } 26 | 27 | puts "FAIL?" 28 | set start [clock milliseconds] 29 | 30 | # Wait for fail? to disappear. 31 | while 1 { 32 | set output [exec redis-cli -p $::other_port cluster nodes] 33 | if {![string match {*fail\?*} $output]} break 34 | after 100 35 | } 36 | 37 | puts "FAIL" 38 | set now [clock milliseconds] 39 | set elapsed [expr {$now-$start}] 40 | puts $elapsed 41 | lappend samples $elapsed 42 | 43 | puts "AVG([llength $samples]): [avg $samples]" 44 | 45 | # Wait for the instance to be available again. 46 | exec redis-cli -p $::fail_port ping 47 | 48 | # Wait for the fail flag to be cleared. 49 | after 2000 50 | } 51 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/zero.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | static void 4 | test_zero(size_t sz_min, size_t sz_max) { 5 | uint8_t *s; 6 | size_t sz_prev, sz, i; 7 | #define MAGIC ((uint8_t)0x61) 8 | 9 | sz_prev = 0; 10 | s = (uint8_t *)mallocx(sz_min, 0); 11 | assert_ptr_not_null((void *)s, "Unexpected mallocx() failure"); 12 | 13 | for (sz = sallocx(s, 0); sz <= sz_max; 14 | sz_prev = sz, sz = sallocx(s, 0)) { 15 | if (sz_prev > 0) { 16 | assert_u_eq(s[0], MAGIC, 17 | "Previously allocated byte %zu/%zu is corrupted", 18 | ZU(0), sz_prev); 19 | assert_u_eq(s[sz_prev-1], MAGIC, 20 | "Previously allocated byte %zu/%zu is corrupted", 21 | sz_prev-1, sz_prev); 22 | } 23 | 24 | for (i = sz_prev; i < sz; i++) { 25 | assert_u_eq(s[i], 0x0, 26 | "Newly allocated byte %zu/%zu isn't zero-filled", 27 | i, sz); 28 | s[i] = MAGIC; 29 | } 30 | 31 | if (xallocx(s, sz+1, 0, 0) == sz) { 32 | s = (uint8_t *)rallocx(s, sz+1, 0); 33 | assert_ptr_not_null((void *)s, 34 | "Unexpected rallocx() failure"); 35 | } 36 | } 37 | 38 | dallocx(s, 0); 39 | #undef MAGIC 40 | } 41 | 42 | TEST_BEGIN(test_zero_small) { 43 | test_skip_if(!config_fill); 44 | test_zero(1, SMALL_MAXCLASS-1); 45 | } 46 | TEST_END 47 | 48 | TEST_BEGIN(test_zero_large) { 49 | test_skip_if(!config_fill); 50 | test_zero(SMALL_MAXCLASS+1, (1U << (LG_LARGE_MINCLASS+1))); 51 | } 52 | TEST_END 53 | 54 | int 55 | main(void) { 56 | return test( 57 | test_zero_small, 58 | test_zero_large); 59 | } 60 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/background_thread_externs.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BACKGROUND_THREAD_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_BACKGROUND_THREAD_EXTERNS_H 3 | 4 | extern bool opt_background_thread; 5 | extern size_t opt_max_background_threads; 6 | extern malloc_mutex_t background_thread_lock; 7 | extern atomic_b_t background_thread_enabled_state; 8 | extern size_t n_background_threads; 9 | extern size_t max_background_threads; 10 | extern background_thread_info_t *background_thread_info; 11 | extern bool can_enable_background_thread; 12 | 13 | bool background_thread_create(tsd_t *tsd, unsigned arena_ind); 14 | bool background_threads_enable(tsd_t *tsd); 15 | bool background_threads_disable(tsd_t *tsd); 16 | void background_thread_interval_check(tsdn_t *tsdn, arena_t *arena, 17 | arena_decay_t *decay, size_t npages_new); 18 | void background_thread_prefork0(tsdn_t *tsdn); 19 | void background_thread_prefork1(tsdn_t *tsdn); 20 | void background_thread_postfork_parent(tsdn_t *tsdn); 21 | void background_thread_postfork_child(tsdn_t *tsdn); 22 | bool background_thread_stats_read(tsdn_t *tsdn, 23 | background_thread_stats_t *stats); 24 | void background_thread_ctl_init(tsdn_t *tsdn); 25 | 26 | #ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER 27 | extern int pthread_create_wrapper(pthread_t *__restrict, const pthread_attr_t *, 28 | void *(*)(void *), void *__restrict); 29 | #endif 30 | bool background_thread_boot0(void); 31 | bool background_thread_boot1(tsdn_t *tsdn); 32 | 33 | #endif /* JEMALLOC_INTERNAL_BACKGROUND_THREAD_EXTERNS_H */ 34 | -------------------------------------------------------------------------------- /deps/jemalloc/src/bin.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | #include "jemalloc/internal/jemalloc_internal_includes.h" 3 | 4 | #include "jemalloc/internal/bin.h" 5 | #include "jemalloc/internal/witness.h" 6 | 7 | const bin_info_t bin_infos[NBINS] = { 8 | #define BIN_INFO_bin_yes(reg_size, slab_size, nregs) \ 9 | {reg_size, slab_size, nregs, BITMAP_INFO_INITIALIZER(nregs)}, 10 | #define BIN_INFO_bin_no(reg_size, slab_size, nregs) 11 | #define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, \ 12 | lg_delta_lookup) \ 13 | BIN_INFO_bin_##bin((1U<lock, "bin", WITNESS_RANK_BIN, 25 | malloc_mutex_rank_exclusive)) { 26 | return true; 27 | } 28 | bin->slabcur = NULL; 29 | extent_heap_new(&bin->slabs_nonfull); 30 | extent_list_init(&bin->slabs_full); 31 | if (config_stats) { 32 | memset(&bin->stats, 0, sizeof(bin_stats_t)); 33 | } 34 | return false; 35 | } 36 | 37 | void 38 | bin_prefork(tsdn_t *tsdn, bin_t *bin) { 39 | malloc_mutex_prefork(tsdn, &bin->lock); 40 | } 41 | 42 | void 43 | bin_postfork_parent(tsdn_t *tsdn, bin_t *bin) { 44 | malloc_mutex_postfork_parent(tsdn, &bin->lock); 45 | } 46 | 47 | void 48 | bin_postfork_child(tsdn_t *tsdn, bin_t *bin) { 49 | malloc_mutex_postfork_child(tsdn, &bin->lock); 50 | } 51 | -------------------------------------------------------------------------------- /utils/create-cluster/README: -------------------------------------------------------------------------------- 1 | Create-custer is a small script used to easily start a big number of Redis 2 | instances configured to run in cluster mode. Its main goal is to allow manual 3 | testing in a condition which is not easy to replicate with the Redis cluster 4 | unit tests, for example when a lot of instances are needed in order to trigger 5 | a given bug. 6 | 7 | The tool can also be used just to easily create a number of instances in a 8 | Redis Cluster in order to experiment a bit with the system. 9 | 10 | USAGE 11 | --- 12 | 13 | To create a cluster, follow these steps: 14 | 15 | 1. Edit create-cluster and change the start / end port, depending on the 16 | number of instances you want to create. 17 | 2. Use "./create-cluster start" in order to run the instances. 18 | 3. Use "./create-cluster create" in order to execute redis-cli --cluster create, so that 19 | an actual Redis cluster will be created. (If you're accessing your setup via a local container, ensure that the CLUSTER_HOST value is changed to your local IP) 20 | 4. Now you are ready to play with the cluster. AOF files and logs for each instances are created in the current directory. 21 | 22 | In order to stop a cluster: 23 | 24 | 1. Use "./create-cluster stop" to stop all the instances. After you stopped the instances you can use "./create-cluster start" to restart them if you change your mind. 25 | 2. Use "./create-cluster clean" to remove all the AOF / log files to restart with a clean environment. 26 | 27 | Use the command "./create-cluster help" to get the full list of features. 28 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/bin_stats.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BIN_STATS_H 2 | #define JEMALLOC_INTERNAL_BIN_STATS_H 3 | 4 | #include "jemalloc/internal/mutex_prof.h" 5 | 6 | typedef struct bin_stats_s bin_stats_t; 7 | struct bin_stats_s { 8 | /* 9 | * Total number of allocation/deallocation requests served directly by 10 | * the bin. Note that tcache may allocate an object, then recycle it 11 | * many times, resulting many increments to nrequests, but only one 12 | * each to nmalloc and ndalloc. 13 | */ 14 | uint64_t nmalloc; 15 | uint64_t ndalloc; 16 | 17 | /* 18 | * Number of allocation requests that correspond to the size of this 19 | * bin. This includes requests served by tcache, though tcache only 20 | * periodically merges into this counter. 21 | */ 22 | uint64_t nrequests; 23 | 24 | /* 25 | * Current number of regions of this size class, including regions 26 | * currently cached by tcache. 27 | */ 28 | size_t curregs; 29 | 30 | /* Number of tcache fills from this bin. */ 31 | uint64_t nfills; 32 | 33 | /* Number of tcache flushes to this bin. */ 34 | uint64_t nflushes; 35 | 36 | /* Total number of slabs created for this bin's size class. */ 37 | uint64_t nslabs; 38 | 39 | /* 40 | * Total number of slabs reused by extracting them from the slabs heap 41 | * for this bin's size class. 42 | */ 43 | uint64_t reslabs; 44 | 45 | /* Current number of slabs in this bin. */ 46 | size_t curslabs; 47 | 48 | mutex_prof_data_t mutex_data; 49 | }; 50 | 51 | #endif /* JEMALLOC_INTERNAL_BIN_STATS_H */ 52 | -------------------------------------------------------------------------------- /tests/cluster/tests/11-manual-takeover.tcl: -------------------------------------------------------------------------------- 1 | # Manual takeover test 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "Create a 5 nodes cluster" { 6 | create_cluster 5 5 7 | } 8 | 9 | test "Cluster is up" { 10 | assert_cluster_state ok 11 | } 12 | 13 | test "Cluster is writable" { 14 | cluster_write_test 0 15 | } 16 | 17 | test "Killing majority of master nodes" { 18 | kill_instance redis 0 19 | kill_instance redis 1 20 | kill_instance redis 2 21 | } 22 | 23 | test "Cluster should eventually be down" { 24 | assert_cluster_state fail 25 | } 26 | 27 | test "Use takeover to bring slaves back" { 28 | R 5 cluster failover takeover 29 | R 6 cluster failover takeover 30 | R 7 cluster failover takeover 31 | } 32 | 33 | test "Cluster should eventually be up again" { 34 | assert_cluster_state ok 35 | } 36 | 37 | test "Cluster is writable" { 38 | cluster_write_test 4 39 | } 40 | 41 | test "Instance #5, #6, #7 are now masters" { 42 | assert {[RI 5 role] eq {master}} 43 | assert {[RI 6 role] eq {master}} 44 | assert {[RI 7 role] eq {master}} 45 | } 46 | 47 | test "Restarting the previously killed master nodes" { 48 | restart_instance redis 0 49 | restart_instance redis 1 50 | restart_instance redis 2 51 | } 52 | 53 | test "Instance #0, #1, #2 gets converted into a slaves" { 54 | wait_for_condition 1000 50 { 55 | [RI 0 role] eq {slave} && [RI 1 role] eq {slave} && [RI 2 role] eq {slave} 56 | } else { 57 | fail "Old masters not converted into slaves" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /utils/redis_init_script: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Simple Redis init.d script conceived to work on Linux systems 4 | # as it does use of the /proc filesystem. 5 | 6 | ### BEGIN INIT INFO 7 | # Provides: redis_6379 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Short-Description: Redis data structure server 11 | # Description: Redis data structure server. See https://redis.io 12 | ### END INIT INFO 13 | 14 | REDISPORT=6379 15 | EXEC=/usr/local/bin/redis-server 16 | CLIEXEC=/usr/local/bin/redis-cli 17 | 18 | PIDFILE=/var/run/redis_${REDISPORT}.pid 19 | CONF="/etc/redis/${REDISPORT}.conf" 20 | 21 | case "$1" in 22 | start) 23 | if [ -f $PIDFILE ] 24 | then 25 | echo "$PIDFILE exists, process is already running or crashed" 26 | else 27 | echo "Starting Redis server..." 28 | $EXEC $CONF 29 | fi 30 | ;; 31 | stop) 32 | if [ ! -f $PIDFILE ] 33 | then 34 | echo "$PIDFILE does not exist, process is not running" 35 | else 36 | PID=$(cat $PIDFILE) 37 | echo "Stopping ..." 38 | $CLIEXEC -p $REDISPORT shutdown 39 | while [ -x /proc/${PID} ] 40 | do 41 | echo "Waiting for Redis to shutdown ..." 42 | sleep 1 43 | done 44 | echo "Redis stopped" 45 | fi 46 | ;; 47 | *) 48 | echo "Please use start or stop as first argument" 49 | ;; 50 | esac 51 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/overflow.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_overflow) { 4 | unsigned nlextents; 5 | size_t mib[4]; 6 | size_t sz, miblen, max_size_class; 7 | void *p; 8 | 9 | sz = sizeof(unsigned); 10 | assert_d_eq(mallctl("arenas.nlextents", (void *)&nlextents, &sz, NULL, 11 | 0), 0, "Unexpected mallctl() error"); 12 | 13 | miblen = sizeof(mib) / sizeof(size_t); 14 | assert_d_eq(mallctlnametomib("arenas.lextent.0.size", mib, &miblen), 0, 15 | "Unexpected mallctlnametomib() error"); 16 | mib[2] = nlextents - 1; 17 | 18 | sz = sizeof(size_t); 19 | assert_d_eq(mallctlbymib(mib, miblen, (void *)&max_size_class, &sz, 20 | NULL, 0), 0, "Unexpected mallctlbymib() error"); 21 | 22 | assert_ptr_null(malloc(max_size_class + 1), 23 | "Expected OOM due to over-sized allocation request"); 24 | assert_ptr_null(malloc(SIZE_T_MAX), 25 | "Expected OOM due to over-sized allocation request"); 26 | 27 | assert_ptr_null(calloc(1, max_size_class + 1), 28 | "Expected OOM due to over-sized allocation request"); 29 | assert_ptr_null(calloc(1, SIZE_T_MAX), 30 | "Expected OOM due to over-sized allocation request"); 31 | 32 | p = malloc(1); 33 | assert_ptr_not_null(p, "Unexpected malloc() OOM"); 34 | assert_ptr_null(realloc(p, max_size_class + 1), 35 | "Expected OOM due to over-sized allocation request"); 36 | assert_ptr_null(realloc(p, SIZE_T_MAX), 37 | "Expected OOM due to over-sized allocation request"); 38 | free(p); 39 | } 40 | TEST_END 41 | 42 | int 43 | main(void) { 44 | return test( 45 | test_overflow); 46 | } 47 | -------------------------------------------------------------------------------- /tests/unit/moduleapi/datatype.tcl: -------------------------------------------------------------------------------- 1 | set testmodule [file normalize tests/modules/datatype.so] 2 | 3 | start_server {tags {"modules"}} { 4 | r module load $testmodule 5 | 6 | test {DataType: Test module is sane, GET/SET work.} { 7 | r datatype.set dtkey 100 stringval 8 | assert {[r datatype.get dtkey] eq {100 stringval}} 9 | } 10 | 11 | test {DataType: RM_SaveDataTypeToString(), RM_LoadDataTypeFromString() work} { 12 | r datatype.set dtkey -1111 MyString 13 | set encoded [r datatype.dump dtkey] 14 | 15 | r datatype.restore dtkeycopy $encoded 16 | assert {[r datatype.get dtkeycopy] eq {-1111 MyString}} 17 | } 18 | 19 | test {DataType: Handle truncated RM_LoadDataTypeFromString()} { 20 | r datatype.set dtkey -1111 MyString 21 | set encoded [r datatype.dump dtkey] 22 | set truncated [string range $encoded 0 end-1] 23 | 24 | catch {r datatype.restore dtkeycopy $truncated} e 25 | set e 26 | } {*Invalid*} 27 | 28 | test {DataType: ModuleTypeReplaceValue() happy path works} { 29 | r datatype.set key-a 1 AAA 30 | r datatype.set key-b 2 BBB 31 | 32 | assert {[r datatype.swap key-a key-b] eq {OK}} 33 | assert {[r datatype.get key-a] eq {2 BBB}} 34 | assert {[r datatype.get key-b] eq {1 AAA}} 35 | } 36 | 37 | test {DataType: ModuleTypeReplaceValue() fails on non-module keys} { 38 | r datatype.set key-a 1 AAA 39 | r set key-b RedisString 40 | 41 | catch {r datatype.swap key-a key-b} e 42 | set e 43 | } {*ERR*} 44 | } 45 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/assert.h: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/malloc_io.h" 2 | #include "jemalloc/internal/util.h" 3 | 4 | /* 5 | * Define a custom assert() in order to reduce the chances of deadlock during 6 | * assertion failure. 7 | */ 8 | #ifndef assert 9 | #define assert(e) do { \ 10 | if (unlikely(config_debug && !(e))) { \ 11 | malloc_printf( \ 12 | ": %s:%d: Failed assertion: \"%s\"\n", \ 13 | __FILE__, __LINE__, #e); \ 14 | abort(); \ 15 | } \ 16 | } while (0) 17 | #endif 18 | 19 | #ifndef not_reached 20 | #define not_reached() do { \ 21 | if (config_debug) { \ 22 | malloc_printf( \ 23 | ": %s:%d: Unreachable code reached\n", \ 24 | __FILE__, __LINE__); \ 25 | abort(); \ 26 | } \ 27 | unreachable(); \ 28 | } while (0) 29 | #endif 30 | 31 | #ifndef not_implemented 32 | #define not_implemented() do { \ 33 | if (config_debug) { \ 34 | malloc_printf(": %s:%d: Not implemented\n", \ 35 | __FILE__, __LINE__); \ 36 | abort(); \ 37 | } \ 38 | } while (0) 39 | #endif 40 | 41 | #ifndef assert_not_implemented 42 | #define assert_not_implemented(e) do { \ 43 | if (unlikely(config_debug && !(e))) { \ 44 | not_implemented(); \ 45 | } \ 46 | } while (0) 47 | #endif 48 | 49 | /* Use to assert a particular configuration, e.g., cassert(config_debug). */ 50 | #ifndef cassert 51 | #define cassert(c) do { \ 52 | if (unlikely(!(c))) { \ 53 | not_reached(); \ 54 | } \ 55 | } while (0) 56 | #endif 57 | -------------------------------------------------------------------------------- /tests/sentinel/tests/05-manual.tcl: -------------------------------------------------------------------------------- 1 | # Test manual failover 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "Manual failover works" { 6 | set old_port [RI $master_id tcp_port] 7 | set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 8 | assert {[lindex $addr 1] == $old_port} 9 | catch {S 0 SENTINEL FAILOVER mymaster} reply 10 | assert {$reply eq "OK"} 11 | foreach_sentinel_id id { 12 | wait_for_condition 1000 50 { 13 | [lindex [S $id SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 1] != $old_port 14 | } else { 15 | fail "At least one Sentinel did not receive failover info" 16 | } 17 | } 18 | set addr [S 0 SENTINEL GET-MASTER-ADDR-BY-NAME mymaster] 19 | set master_id [get_instance_id_by_port redis [lindex $addr 1]] 20 | } 21 | 22 | test "New master [join $addr {:}] role matches" { 23 | assert {[RI $master_id role] eq {master}} 24 | } 25 | 26 | test "All the other slaves now point to the new master" { 27 | foreach_redis_id id { 28 | if {$id != $master_id && $id != 0} { 29 | wait_for_condition 1000 50 { 30 | [RI $id master_port] == [lindex $addr 1] 31 | } else { 32 | fail "Redis ID $id not configured to replicate with new master" 33 | } 34 | } 35 | } 36 | } 37 | 38 | test "The old master eventually gets reconfigured as a slave" { 39 | wait_for_condition 1000 50 { 40 | [RI 0 master_port] == [lindex $addr 1] 41 | } else { 42 | fail "Old master not reconfigured as slave of new master" 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /tests/cluster/tests/02-failover.tcl: -------------------------------------------------------------------------------- 1 | # Check the basic monitoring and failover capabilities. 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "Create a 5 nodes cluster" { 6 | create_cluster 5 5 7 | } 8 | 9 | test "Cluster is up" { 10 | assert_cluster_state ok 11 | } 12 | 13 | test "Cluster is writable" { 14 | cluster_write_test 0 15 | } 16 | 17 | test "Instance #5 is a slave" { 18 | assert {[RI 5 role] eq {slave}} 19 | } 20 | 21 | test "Instance #5 synced with the master" { 22 | wait_for_condition 1000 50 { 23 | [RI 5 master_link_status] eq {up} 24 | } else { 25 | fail "Instance #5 master link status is not up" 26 | } 27 | } 28 | 29 | set current_epoch [CI 1 cluster_current_epoch] 30 | 31 | test "Killing one master node" { 32 | kill_instance redis 0 33 | } 34 | 35 | test "Wait for failover" { 36 | wait_for_condition 1000 50 { 37 | [CI 1 cluster_current_epoch] > $current_epoch 38 | } else { 39 | fail "No failover detected" 40 | } 41 | } 42 | 43 | test "Cluster should eventually be up again" { 44 | assert_cluster_state ok 45 | } 46 | 47 | test "Cluster is writable" { 48 | cluster_write_test 1 49 | } 50 | 51 | test "Instance #5 is now a master" { 52 | assert {[RI 5 role] eq {master}} 53 | } 54 | 55 | test "Restarting the previously killed master node" { 56 | restart_instance redis 0 57 | } 58 | 59 | test "Instance #0 gets converted into a slave" { 60 | wait_for_condition 1000 50 { 61 | [RI 0 role] eq {slave} 62 | } else { 63 | fail "Old master was not converted into slave" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tests/cluster/tests/13-no-failover-option.tcl: -------------------------------------------------------------------------------- 1 | # Check that the no-failover option works 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | test "Create a 5 nodes cluster" { 6 | create_cluster 5 5 7 | } 8 | 9 | test "Cluster is up" { 10 | assert_cluster_state ok 11 | } 12 | 13 | test "Cluster is writable" { 14 | cluster_write_test 0 15 | } 16 | 17 | test "Instance #5 is a slave" { 18 | assert {[RI 5 role] eq {slave}} 19 | 20 | # Configure it to never failover the master 21 | R 5 CONFIG SET cluster-slave-no-failover yes 22 | } 23 | 24 | test "Instance #5 synced with the master" { 25 | wait_for_condition 1000 50 { 26 | [RI 5 master_link_status] eq {up} 27 | } else { 28 | fail "Instance #5 master link status is not up" 29 | } 30 | } 31 | 32 | test "The nofailover flag is propagated" { 33 | set slave5_id [dict get [get_myself 5] id] 34 | 35 | foreach_redis_id id { 36 | wait_for_condition 1000 50 { 37 | [has_flag [get_node_by_id $id $slave5_id] nofailover] 38 | } else { 39 | fail "Instance $id can't see the nofailover flag of slave" 40 | } 41 | } 42 | } 43 | 44 | set current_epoch [CI 1 cluster_current_epoch] 45 | 46 | test "Killing one master node" { 47 | kill_instance redis 0 48 | } 49 | 50 | test "Cluster should be still down after some time" { 51 | after 10000 52 | assert_cluster_state fail 53 | } 54 | 55 | test "Instance #5 is still a slave" { 56 | assert {[RI 5 role] eq {slave}} 57 | } 58 | 59 | test "Restarting the previously killed master node" { 60 | restart_instance redis 0 61 | } 62 | -------------------------------------------------------------------------------- /deps/hiredis/examples/example-libev.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void getCallback(redisAsyncContext *c, void *r, void *privdata) { 11 | redisReply *reply = r; 12 | if (reply == NULL) return; 13 | printf("argv[%s]: %s\n", (char*)privdata, reply->str); 14 | 15 | /* Disconnect after receiving the reply to GET */ 16 | redisAsyncDisconnect(c); 17 | } 18 | 19 | void connectCallback(const redisAsyncContext *c, int status) { 20 | if (status != REDIS_OK) { 21 | printf("Error: %s\n", c->errstr); 22 | return; 23 | } 24 | printf("Connected...\n"); 25 | } 26 | 27 | void disconnectCallback(const redisAsyncContext *c, int status) { 28 | if (status != REDIS_OK) { 29 | printf("Error: %s\n", c->errstr); 30 | return; 31 | } 32 | printf("Disconnected...\n"); 33 | } 34 | 35 | int main (int argc, char **argv) { 36 | signal(SIGPIPE, SIG_IGN); 37 | 38 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); 39 | if (c->err) { 40 | /* Let *c leak for now... */ 41 | printf("Error: %s\n", c->errstr); 42 | return 1; 43 | } 44 | 45 | redisLibevAttach(EV_DEFAULT_ c); 46 | redisAsyncSetConnectCallback(c,connectCallback); 47 | redisAsyncSetDisconnectCallback(c,disconnectCallback); 48 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); 49 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key"); 50 | ev_loop(EV_DEFAULT_ 0); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/bit_util.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/bit_util.h" 4 | 5 | #define TEST_POW2_CEIL(t, suf, pri) do { \ 6 | unsigned i, pow2; \ 7 | t x; \ 8 | \ 9 | assert_##suf##_eq(pow2_ceil_##suf(0), 0, "Unexpected result"); \ 10 | \ 11 | for (i = 0; i < sizeof(t) * 8; i++) { \ 12 | assert_##suf##_eq(pow2_ceil_##suf(((t)1) << i), ((t)1) \ 13 | << i, "Unexpected result"); \ 14 | } \ 15 | \ 16 | for (i = 2; i < sizeof(t) * 8; i++) { \ 17 | assert_##suf##_eq(pow2_ceil_##suf((((t)1) << i) - 1), \ 18 | ((t)1) << i, "Unexpected result"); \ 19 | } \ 20 | \ 21 | for (i = 0; i < sizeof(t) * 8 - 1; i++) { \ 22 | assert_##suf##_eq(pow2_ceil_##suf((((t)1) << i) + 1), \ 23 | ((t)1) << (i+1), "Unexpected result"); \ 24 | } \ 25 | \ 26 | for (pow2 = 1; pow2 < 25; pow2++) { \ 27 | for (x = (((t)1) << (pow2-1)) + 1; x <= ((t)1) << pow2; \ 28 | x++) { \ 29 | assert_##suf##_eq(pow2_ceil_##suf(x), \ 30 | ((t)1) << pow2, \ 31 | "Unexpected result, x=%"pri, x); \ 32 | } \ 33 | } \ 34 | } while (0) 35 | 36 | TEST_BEGIN(test_pow2_ceil_u64) { 37 | TEST_POW2_CEIL(uint64_t, u64, FMTu64); 38 | } 39 | TEST_END 40 | 41 | TEST_BEGIN(test_pow2_ceil_u32) { 42 | TEST_POW2_CEIL(uint32_t, u32, FMTu32); 43 | } 44 | TEST_END 45 | 46 | TEST_BEGIN(test_pow2_ceil_zu) { 47 | TEST_POW2_CEIL(size_t, zu, "zu"); 48 | } 49 | TEST_END 50 | 51 | int 52 | main(void) { 53 | return test( 54 | test_pow2_ceil_u64, 55 | test_pow2_ceil_u32, 56 | test_pow2_ceil_zu); 57 | } 58 | -------------------------------------------------------------------------------- /deps/lua/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Lua License 2 | ----------- 3 | 4 | Lua is licensed under the terms of the MIT license reproduced below. 5 | This means that Lua is free software and can be used for both academic 6 | and commercial purposes at absolutely no cost. 7 | 8 | For details and rationale, see http://www.lua.org/license.html . 9 | 10 | =============================================================================== 11 | 12 | Copyright (C) 1994-2012 Lua.org, PUC-Rio. 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | 32 | =============================================================================== 33 | 34 | (end of COPYRIGHT) 35 | -------------------------------------------------------------------------------- /utils/systemd-redis_server.service: -------------------------------------------------------------------------------- 1 | # example systemd service unit file for redis-server 2 | # 3 | # In order to use this as a template for providing a redis service in your 4 | # environment, _at the very least_ make sure to adapt the redis configuration 5 | # file you intend to use as needed (make sure to set "supervised systemd"), and 6 | # to set sane TimeoutStartSec and TimeoutStopSec property values in the unit's 7 | # "[Service]" section to fit your needs. 8 | # 9 | # Some properties, such as User= and Group=, are highly desirable for virtually 10 | # all deployments of redis, but cannot be provided in a manner that fits all 11 | # expectable environments. Some of these properties have been commented out in 12 | # this example service unit file, but you are highly encouraged to set them to 13 | # fit your needs. 14 | # 15 | # Please refer to systemd.unit(5), systemd.service(5), and systemd.exec(5) for 16 | # more information. 17 | 18 | [Unit] 19 | Description=Redis data structure server 20 | Documentation=https://redis.io/documentation 21 | #Before=your_application.service another_example_application.service 22 | #AssertPathExists=/var/lib/redis 23 | 24 | [Service] 25 | ExecStart=/usr/local/bin/redis-server --supervised systemd --daemonize no 26 | ## Alternatively, have redis-server load a configuration file: 27 | #ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf 28 | LimitNOFILE=10032 29 | NoNewPrivileges=yes 30 | #OOMScoreAdjust=-900 31 | #PrivateTmp=yes 32 | Type=notify 33 | TimeoutStartSec=infinity 34 | TimeoutStopSec=infinity 35 | UMask=0077 36 | #User=redis 37 | #Group=redis 38 | #WorkingDirectory=/var/lib/redis 39 | 40 | [Install] 41 | WantedBy=multi-user.target 42 | -------------------------------------------------------------------------------- /deps/lua/doc/lua.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000000 ; 3 | background-color: #FFFFFF ; 4 | font-family: Helvetica, Arial, sans-serif ; 5 | text-align: justify ; 6 | margin-right: 30px ; 7 | margin-left: 30px ; 8 | } 9 | 10 | h1, h2, h3, h4 { 11 | font-family: Verdana, Geneva, sans-serif ; 12 | font-weight: normal ; 13 | font-style: italic ; 14 | } 15 | 16 | h2 { 17 | padding-top: 0.4em ; 18 | padding-bottom: 0.4em ; 19 | padding-left: 30px ; 20 | padding-right: 30px ; 21 | margin-left: -30px ; 22 | background-color: #E0E0FF ; 23 | } 24 | 25 | h3 { 26 | padding-left: 0.5em ; 27 | border-left: solid #E0E0FF 1em ; 28 | } 29 | 30 | table h3 { 31 | padding-left: 0px ; 32 | border-left: none ; 33 | } 34 | 35 | a:link { 36 | color: #000080 ; 37 | background-color: inherit ; 38 | text-decoration: none ; 39 | } 40 | 41 | a:visited { 42 | background-color: inherit ; 43 | text-decoration: none ; 44 | } 45 | 46 | a:link:hover, a:visited:hover { 47 | color: #000080 ; 48 | background-color: #E0E0FF ; 49 | } 50 | 51 | a:link:active, a:visited:active { 52 | color: #FF0000 ; 53 | } 54 | 55 | hr { 56 | border: 0 ; 57 | height: 1px ; 58 | color: #a0a0a0 ; 59 | background-color: #a0a0a0 ; 60 | } 61 | 62 | :target { 63 | background-color: #F8F8F8 ; 64 | padding: 8px ; 65 | border: solid #a0a0a0 2px ; 66 | } 67 | 68 | .footer { 69 | color: gray ; 70 | font-size: small ; 71 | } 72 | 73 | input[type=text] { 74 | border: solid #a0a0a0 2px ; 75 | border-radius: 2em ; 76 | -moz-border-radius: 2em ; 77 | background-image: url('images/search.png') ; 78 | background-repeat: no-repeat; 79 | background-position: 4px center ; 80 | padding-left: 20px ; 81 | height: 2em ; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /deps/hiredis/examples/example-ivykis.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void getCallback(redisAsyncContext *c, void *r, void *privdata) { 11 | redisReply *reply = r; 12 | if (reply == NULL) return; 13 | printf("argv[%s]: %s\n", (char*)privdata, reply->str); 14 | 15 | /* Disconnect after receiving the reply to GET */ 16 | redisAsyncDisconnect(c); 17 | } 18 | 19 | void connectCallback(const redisAsyncContext *c, int status) { 20 | if (status != REDIS_OK) { 21 | printf("Error: %s\n", c->errstr); 22 | return; 23 | } 24 | printf("Connected...\n"); 25 | } 26 | 27 | void disconnectCallback(const redisAsyncContext *c, int status) { 28 | if (status != REDIS_OK) { 29 | printf("Error: %s\n", c->errstr); 30 | return; 31 | } 32 | printf("Disconnected...\n"); 33 | } 34 | 35 | int main (int argc, char **argv) { 36 | signal(SIGPIPE, SIG_IGN); 37 | 38 | iv_init(); 39 | 40 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); 41 | if (c->err) { 42 | /* Let *c leak for now... */ 43 | printf("Error: %s\n", c->errstr); 44 | return 1; 45 | } 46 | 47 | redisIvykisAttach(c); 48 | redisAsyncSetConnectCallback(c,connectCallback); 49 | redisAsyncSetDisconnectCallback(c,disconnectCallback); 50 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); 51 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key"); 52 | 53 | iv_main(); 54 | 55 | iv_deinit(); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /deps/hiredis/examples/example-libuv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void getCallback(redisAsyncContext *c, void *r, void *privdata) { 11 | redisReply *reply = r; 12 | if (reply == NULL) return; 13 | printf("argv[%s]: %s\n", (char*)privdata, reply->str); 14 | 15 | /* Disconnect after receiving the reply to GET */ 16 | redisAsyncDisconnect(c); 17 | } 18 | 19 | void connectCallback(const redisAsyncContext *c, int status) { 20 | if (status != REDIS_OK) { 21 | printf("Error: %s\n", c->errstr); 22 | return; 23 | } 24 | printf("Connected...\n"); 25 | } 26 | 27 | void disconnectCallback(const redisAsyncContext *c, int status) { 28 | if (status != REDIS_OK) { 29 | printf("Error: %s\n", c->errstr); 30 | return; 31 | } 32 | printf("Disconnected...\n"); 33 | } 34 | 35 | int main (int argc, char **argv) { 36 | signal(SIGPIPE, SIG_IGN); 37 | uv_loop_t* loop = uv_default_loop(); 38 | 39 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); 40 | if (c->err) { 41 | /* Let *c leak for now... */ 42 | printf("Error: %s\n", c->errstr); 43 | return 1; 44 | } 45 | 46 | redisLibuvAttach(c,loop); 47 | redisAsyncSetConnectCallback(c,connectCallback); 48 | redisAsyncSetDisconnectCallback(c,disconnectCallback); 49 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); 50 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key"); 51 | uv_run(loop, UV_RUN_DEFAULT); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/arena_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_ARENA_TYPES_H 2 | #define JEMALLOC_INTERNAL_ARENA_TYPES_H 3 | 4 | /* Maximum number of regions in one slab. */ 5 | #define LG_SLAB_MAXREGS (LG_PAGE - LG_TINY_MIN) 6 | #define SLAB_MAXREGS (1U << LG_SLAB_MAXREGS) 7 | 8 | /* Default decay times in milliseconds. */ 9 | #define DIRTY_DECAY_MS_DEFAULT ZD(10 * 1000) 10 | #define MUZZY_DECAY_MS_DEFAULT ZD(10 * 1000) 11 | /* Number of event ticks between time checks. */ 12 | #define DECAY_NTICKS_PER_UPDATE 1000 13 | 14 | typedef struct arena_slab_data_s arena_slab_data_t; 15 | typedef struct arena_decay_s arena_decay_t; 16 | typedef struct arena_s arena_t; 17 | typedef struct arena_tdata_s arena_tdata_t; 18 | typedef struct alloc_ctx_s alloc_ctx_t; 19 | 20 | typedef enum { 21 | percpu_arena_mode_names_base = 0, /* Used for options processing. */ 22 | 23 | /* 24 | * *_uninit are used only during bootstrapping, and must correspond 25 | * to initialized variant plus percpu_arena_mode_enabled_base. 26 | */ 27 | percpu_arena_uninit = 0, 28 | per_phycpu_arena_uninit = 1, 29 | 30 | /* All non-disabled modes must come after percpu_arena_disabled. */ 31 | percpu_arena_disabled = 2, 32 | 33 | percpu_arena_mode_names_limit = 3, /* Used for options processing. */ 34 | percpu_arena_mode_enabled_base = 3, 35 | 36 | percpu_arena = 3, 37 | per_phycpu_arena = 4 /* Hyper threads share arena. */ 38 | } percpu_arena_mode_t; 39 | 40 | #define PERCPU_ARENA_ENABLED(m) ((m) >= percpu_arena_mode_enabled_base) 41 | #define PERCPU_ARENA_DEFAULT percpu_arena_disabled 42 | 43 | #endif /* JEMALLOC_INTERNAL_ARENA_TYPES_H */ 44 | -------------------------------------------------------------------------------- /deps/jemalloc/test/src/mtx.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifndef _CRT_SPINCOUNT 4 | #define _CRT_SPINCOUNT 4000 5 | #endif 6 | 7 | bool 8 | mtx_init(mtx_t *mtx) { 9 | #ifdef _WIN32 10 | if (!InitializeCriticalSectionAndSpinCount(&mtx->lock, 11 | _CRT_SPINCOUNT)) { 12 | return true; 13 | } 14 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 15 | mtx->lock = OS_UNFAIR_LOCK_INIT; 16 | #elif (defined(JEMALLOC_OSSPIN)) 17 | mtx->lock = 0; 18 | #else 19 | pthread_mutexattr_t attr; 20 | 21 | if (pthread_mutexattr_init(&attr) != 0) { 22 | return true; 23 | } 24 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT); 25 | if (pthread_mutex_init(&mtx->lock, &attr) != 0) { 26 | pthread_mutexattr_destroy(&attr); 27 | return true; 28 | } 29 | pthread_mutexattr_destroy(&attr); 30 | #endif 31 | return false; 32 | } 33 | 34 | void 35 | mtx_fini(mtx_t *mtx) { 36 | #ifdef _WIN32 37 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 38 | #elif (defined(JEMALLOC_OSSPIN)) 39 | #else 40 | pthread_mutex_destroy(&mtx->lock); 41 | #endif 42 | } 43 | 44 | void 45 | mtx_lock(mtx_t *mtx) { 46 | #ifdef _WIN32 47 | EnterCriticalSection(&mtx->lock); 48 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 49 | os_unfair_lock_lock(&mtx->lock); 50 | #elif (defined(JEMALLOC_OSSPIN)) 51 | OSSpinLockLock(&mtx->lock); 52 | #else 53 | pthread_mutex_lock(&mtx->lock); 54 | #endif 55 | } 56 | 57 | void 58 | mtx_unlock(mtx_t *mtx) { 59 | #ifdef _WIN32 60 | LeaveCriticalSection(&mtx->lock); 61 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 62 | os_unfair_lock_unlock(&mtx->lock); 63 | #elif (defined(JEMALLOC_OSSPIN)) 64 | OSSpinLockUnlock(&mtx->lock); 65 | #else 66 | pthread_mutex_unlock(&mtx->lock); 67 | #endif 68 | } 69 | -------------------------------------------------------------------------------- /src/modules/gendoc.rb: -------------------------------------------------------------------------------- 1 | # gendoc.rb -- Converts the top-comments inside module.c to modules API 2 | # reference documentation in markdown format. 3 | 4 | # Convert the C comment to markdown 5 | def markdown(s) 6 | s = s.gsub(/\*\/$/,"") 7 | s = s.gsub(/^ \* {0,1}/,"") 8 | s = s.gsub(/^\/\* /,"") 9 | s.chop! while s[-1] == "\n" || s[-1] == " " 10 | lines = s.split("\n") 11 | newlines = [] 12 | lines.each{|l| 13 | if l[0] != ' ' 14 | l = l.gsub(/RM_[A-z()]+/){|x| "`#{x}`"} 15 | l = l.gsub(/RedisModule_[A-z()]+/){|x| "`#{x}`"} 16 | l = l.gsub(/REDISMODULE_[A-z]+/){|x| "`#{x}`"} 17 | end 18 | newlines << l 19 | } 20 | return newlines.join("\n") 21 | end 22 | 23 | # Given the source code array and the index at which an exported symbol was 24 | # detected, extracts and outputs the documentation. 25 | def docufy(src,i) 26 | m = /RM_[A-z0-9]+/.match(src[i]) 27 | name = m[0] 28 | name = name.sub("RM_","RedisModule_") 29 | proto = src[i].sub("{","").strip+";\n" 30 | proto = proto.sub("RM_","RedisModule_") 31 | puts "## `#{name}`\n\n" 32 | puts " #{proto}\n" 33 | comment = "" 34 | while true 35 | i = i-1 36 | comment = src[i]+comment 37 | break if src[i] =~ /\/\*/ 38 | end 39 | comment = markdown(comment) 40 | puts comment+"\n\n" 41 | end 42 | 43 | puts "# Modules API reference\n\n" 44 | src = File.open("../module.c").to_a 45 | src.each_with_index{|line,i| 46 | if line =~ /RM_/ && line[0] != ' ' && line[0] != '#' && line[0] != '/' 47 | if src[i-1] =~ /\*\// 48 | docufy(src,i) 49 | end 50 | end 51 | } 52 | -------------------------------------------------------------------------------- /deps/hiredis/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2011, Salvatore Sanfilippo 2 | Copyright (c) 2010-2011, Pieter Noordhuis 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of Redis nor the names of its contributors may be used 17 | to endorse or promote products derived from this software without specific 18 | prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 24 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /deps/lua/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | #define MEMERRMSG "not enough memory" 17 | 18 | 19 | #define luaM_reallocv(L,b,on,n,e) \ 20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 22 | luaM_toobig(L)) 23 | 24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 27 | 28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 30 | #define luaM_newvector(L,n,t) \ 31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 32 | 33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 34 | if ((nelems)+1 > (size)) \ 35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 36 | 37 | #define luaM_reallocvector(L, v,oldn,n,t) \ 38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 39 | 40 | 41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 42 | size_t size); 43 | LUAI_FUNC void *luaM_toobig (lua_State *L); 44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 45 | size_t size_elem, int limit, 46 | const char *errormsg); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /tests/helpers/bg_block_op.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | source tests/support/util.tcl 3 | 4 | set ::tlsdir "tests/tls" 5 | 6 | # This function sometimes writes sometimes blocking-reads from lists/sorted 7 | # sets. There are multiple processes like this executing at the same time 8 | # so that we have some chance to trap some corner condition if there is 9 | # a regression. For this to happen it is important that we narrow the key 10 | # space to just a few elements, and balance the operations so that it is 11 | # unlikely that lists and zsets just get more data without ever causing 12 | # blocking. 13 | proc bg_block_op {host port db ops tls} { 14 | set r [redis $host $port 0 $tls] 15 | $r select $db 16 | 17 | for {set j 0} {$j < $ops} {incr j} { 18 | 19 | # List side 20 | set k list_[randomInt 10] 21 | set k2 list_[randomInt 10] 22 | set v [randomValue] 23 | 24 | randpath { 25 | randpath { 26 | $r rpush $k $v 27 | } { 28 | $r lpush $k $v 29 | } 30 | } { 31 | $r blpop $k 2 32 | } { 33 | $r blpop $k $k2 2 34 | } 35 | 36 | # Zset side 37 | set k zset_[randomInt 10] 38 | set k2 zset_[randomInt 10] 39 | set v1 [randomValue] 40 | set v2 [randomValue] 41 | 42 | randpath { 43 | $r zadd $k [randomInt 10000] $v 44 | } { 45 | $r zadd $k [randomInt 10000] $v [randomInt 10000] $v2 46 | } { 47 | $r bzpopmin $k 2 48 | } { 49 | $r bzpopmax $k 2 50 | } 51 | } 52 | } 53 | 54 | bg_block_op [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] 55 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/arena_inlines_a.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_ARENA_INLINES_A_H 2 | #define JEMALLOC_INTERNAL_ARENA_INLINES_A_H 3 | 4 | static inline unsigned 5 | arena_ind_get(const arena_t *arena) { 6 | return base_ind_get(arena->base); 7 | } 8 | 9 | static inline void 10 | arena_internal_add(arena_t *arena, size_t size) { 11 | atomic_fetch_add_zu(&arena->stats.internal, size, ATOMIC_RELAXED); 12 | } 13 | 14 | static inline void 15 | arena_internal_sub(arena_t *arena, size_t size) { 16 | atomic_fetch_sub_zu(&arena->stats.internal, size, ATOMIC_RELAXED); 17 | } 18 | 19 | static inline size_t 20 | arena_internal_get(arena_t *arena) { 21 | return atomic_load_zu(&arena->stats.internal, ATOMIC_RELAXED); 22 | } 23 | 24 | static inline bool 25 | arena_prof_accum(tsdn_t *tsdn, arena_t *arena, uint64_t accumbytes) { 26 | cassert(config_prof); 27 | 28 | if (likely(prof_interval == 0 || !prof_active_get_unlocked())) { 29 | return false; 30 | } 31 | 32 | return prof_accum_add(tsdn, &arena->prof_accum, accumbytes); 33 | } 34 | 35 | static inline void 36 | percpu_arena_update(tsd_t *tsd, unsigned cpu) { 37 | assert(have_percpu_arena); 38 | arena_t *oldarena = tsd_arena_get(tsd); 39 | assert(oldarena != NULL); 40 | unsigned oldind = arena_ind_get(oldarena); 41 | 42 | if (oldind != cpu) { 43 | unsigned newind = cpu; 44 | arena_t *newarena = arena_get(tsd_tsdn(tsd), newind, true); 45 | assert(newarena != NULL); 46 | 47 | /* Set new arena/tcache associations. */ 48 | arena_migrate(tsd, oldind, newind); 49 | tcache_t *tcache = tcache_get(tsd); 50 | if (tcache != NULL) { 51 | tcache_arena_reassociate(tsd_tsdn(tsd), tcache, 52 | newarena); 53 | } 54 | } 55 | } 56 | 57 | #endif /* JEMALLOC_INTERNAL_ARENA_INLINES_A_H */ 58 | -------------------------------------------------------------------------------- /deps/jemalloc/test/integration/MALLOCX_ARENA.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #define NTHREADS 10 4 | 5 | static bool have_dss = 6 | #ifdef JEMALLOC_DSS 7 | true 8 | #else 9 | false 10 | #endif 11 | ; 12 | 13 | void * 14 | thd_start(void *arg) { 15 | unsigned thread_ind = (unsigned)(uintptr_t)arg; 16 | unsigned arena_ind; 17 | void *p; 18 | size_t sz; 19 | 20 | sz = sizeof(arena_ind); 21 | assert_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0), 22 | 0, "Error in arenas.create"); 23 | 24 | if (thread_ind % 4 != 3) { 25 | size_t mib[3]; 26 | size_t miblen = sizeof(mib) / sizeof(size_t); 27 | const char *dss_precs[] = {"disabled", "primary", "secondary"}; 28 | unsigned prec_ind = thread_ind % 29 | (sizeof(dss_precs)/sizeof(char*)); 30 | const char *dss = dss_precs[prec_ind]; 31 | int expected_err = (have_dss || prec_ind == 0) ? 0 : EFAULT; 32 | assert_d_eq(mallctlnametomib("arena.0.dss", mib, &miblen), 0, 33 | "Error in mallctlnametomib()"); 34 | mib[1] = arena_ind; 35 | assert_d_eq(mallctlbymib(mib, miblen, NULL, NULL, (void *)&dss, 36 | sizeof(const char *)), expected_err, 37 | "Error in mallctlbymib()"); 38 | } 39 | 40 | p = mallocx(1, MALLOCX_ARENA(arena_ind)); 41 | assert_ptr_not_null(p, "Unexpected mallocx() error"); 42 | dallocx(p, 0); 43 | 44 | return NULL; 45 | } 46 | 47 | TEST_BEGIN(test_MALLOCX_ARENA) { 48 | thd_t thds[NTHREADS]; 49 | unsigned i; 50 | 51 | for (i = 0; i < NTHREADS; i++) { 52 | thd_create(&thds[i], thd_start, 53 | (void *)(uintptr_t)i); 54 | } 55 | 56 | for (i = 0; i < NTHREADS; i++) { 57 | thd_join(thds[i], NULL); 58 | } 59 | } 60 | TEST_END 61 | 62 | int 63 | main(void) { 64 | return test( 65 | test_MALLOCX_ARENA); 66 | } 67 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/util.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_UTIL_H 2 | #define JEMALLOC_INTERNAL_UTIL_H 3 | 4 | #define UTIL_INLINE static inline 5 | 6 | /* Junk fill patterns. */ 7 | #ifndef JEMALLOC_ALLOC_JUNK 8 | # define JEMALLOC_ALLOC_JUNK ((uint8_t)0xa5) 9 | #endif 10 | #ifndef JEMALLOC_FREE_JUNK 11 | # define JEMALLOC_FREE_JUNK ((uint8_t)0x5a) 12 | #endif 13 | 14 | /* 15 | * Wrap a cpp argument that contains commas such that it isn't broken up into 16 | * multiple arguments. 17 | */ 18 | #define JEMALLOC_ARG_CONCAT(...) __VA_ARGS__ 19 | 20 | /* cpp macro definition stringification. */ 21 | #define STRINGIFY_HELPER(x) #x 22 | #define STRINGIFY(x) STRINGIFY_HELPER(x) 23 | 24 | /* 25 | * Silence compiler warnings due to uninitialized values. This is used 26 | * wherever the compiler fails to recognize that the variable is never used 27 | * uninitialized. 28 | */ 29 | #define JEMALLOC_CC_SILENCE_INIT(v) = v 30 | 31 | #ifdef __GNUC__ 32 | # define likely(x) __builtin_expect(!!(x), 1) 33 | # define unlikely(x) __builtin_expect(!!(x), 0) 34 | #else 35 | # define likely(x) !!(x) 36 | # define unlikely(x) !!(x) 37 | #endif 38 | 39 | #if !defined(JEMALLOC_INTERNAL_UNREACHABLE) 40 | # error JEMALLOC_INTERNAL_UNREACHABLE should have been defined by configure 41 | #endif 42 | 43 | #define unreachable() JEMALLOC_INTERNAL_UNREACHABLE() 44 | 45 | /* Set error code. */ 46 | UTIL_INLINE void 47 | set_errno(int errnum) { 48 | #ifdef _WIN32 49 | SetLastError(errnum); 50 | #else 51 | errno = errnum; 52 | #endif 53 | } 54 | 55 | /* Get last error code. */ 56 | UTIL_INLINE int 57 | get_errno(void) { 58 | #ifdef _WIN32 59 | return GetLastError(); 60 | #else 61 | return errno; 62 | #endif 63 | } 64 | 65 | #undef UTIL_INLINE 66 | 67 | #endif /* JEMALLOC_INTERNAL_UTIL_H */ 68 | --------------------------------------------------------------------------------