├── INSTALL ├── tests ├── tmp │ └── .gitignore ├── cluster │ ├── tmp │ │ └── .gitignore │ ├── tests │ │ ├── helpers │ │ │ └── onlydots.tcl │ │ ├── 01-faildet.tcl │ │ ├── 09-pubsub.tcl │ │ ├── 11-manual-takeover.tcl │ │ ├── 02-failover.tcl │ │ ├── 13-no-failover-option.tcl │ │ └── 00-base.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 │ │ └── list-2.tcl │ ├── limits.tcl │ ├── introspection-2.tcl │ ├── auth.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 └── integration │ ├── logging.tcl │ ├── aof-race.tcl │ └── convert-zipmap-hash-on-load.tcl ├── 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 │ │ └── div.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 │ │ │ │ └── base_structs.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 │ └── COPYING ├── linenoise │ ├── .gitignore │ └── Makefile ├── lua │ ├── etc │ │ ├── lua.ico │ │ ├── lua.hpp │ │ ├── lua.pc │ │ ├── all.c │ │ ├── min.c │ │ ├── Makefile │ │ ├── strict.lua │ │ ├── README │ │ ├── luavs.bat │ │ └── noparser.c │ ├── doc │ │ ├── cover.png │ │ ├── logo.gif │ │ ├── manual.css │ │ ├── readme.html │ │ └── lua.css │ ├── 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 │ │ └── sort.lua │ ├── 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 │ │ └── lzio.h │ ├── README │ └── COPYRIGHT ├── hiredis │ ├── .gitignore │ ├── fmacros.h │ ├── examples │ │ ├── example-qt.h │ │ ├── example-qt.cpp │ │ ├── example-libev.c │ │ ├── example-ivykis.c │ │ ├── example-libuv.c │ │ ├── example-libevent.c │ │ └── example-ae.c │ ├── win32.h │ ├── .travis.yml │ ├── appveyor.yml │ └── 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 ├── build-static-symbols.tcl ├── graphs │ └── commits-over-time │ │ └── README.md ├── whatisdoing.sh ├── lru │ └── README ├── redis_init_script.tpl ├── corrupt_rdb.c ├── redis-copy.rb ├── cluster_fail_time.tcl └── redis_init_script ├── src ├── modules │ ├── .gitignore │ ├── Makefile │ └── gendoc.rb ├── version.h ├── .gitignore ├── crc64.h ├── valgrind.sup ├── geo.h ├── sha1.h └── mkreleasehdr.sh ├── BUGS ├── Makefile ├── runtest ├── runtest-cluster ├── runtest-sentinel ├── .gitignore ├── 00-RELEASENOTES └── 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 | -------------------------------------------------------------------------------- /deps/jemalloc/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | #define REDIS_VERSION "999.999.999" 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 | -------------------------------------------------------------------------------- /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/etc/lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asg017/redis/unstable/deps/lua/etc/lua.ico -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /deps/lua/doc/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asg017/redis/unstable/deps/lua/doc/cover.png -------------------------------------------------------------------------------- /deps/lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asg017/redis/unstable/deps/lua/doc/logo.gif -------------------------------------------------------------------------------- /deps/lua/test/life.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asg017/redis/unstable/deps/lua/test/life.lua -------------------------------------------------------------------------------- /tests/sentinel/tests/03-runtime-reconf.tcl: -------------------------------------------------------------------------------- 1 | # Test runtime reconfiguration command SENTINEL SET. 2 | -------------------------------------------------------------------------------- /tests/assets/encodings.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asg017/redis/unstable/tests/assets/encodings.rdb -------------------------------------------------------------------------------- /tests/assets/hash-zipmap.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asg017/redis/unstable/tests/assets/hash-zipmap.rdb -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/arena_reset_prof.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 4 | -------------------------------------------------------------------------------- /deps/hiredis/.gitignore: -------------------------------------------------------------------------------- 1 | /hiredis-test 2 | /examples/hiredis-example* 3 | /*.o 4 | /*.so 5 | /*.dylib 6 | /*.a 7 | /*.pc 8 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /src/crc64.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC64_H 2 | #define CRC64_H 3 | 4 | #include 5 | 6 | uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); 7 | 8 | #ifdef REDIS_TEST 9 | int crc64Test(int argc, char *argv[]); 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /tests/helpers/bg_complex_data.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | source tests/support/util.tcl 3 | 4 | proc bg_complex_data {host port db ops} { 5 | set r [redis $host $port] 6 | $r select $db 7 | createComplexDataset $r $ops 8 | } 9 | 10 | bg_complex_data [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] 11 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/helpers/gen_write_load.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | 3 | proc gen_write_load {host port seconds} { 4 | set start_time [clock seconds] 5 | set r [redis $host $port 1] 6 | $r select 9 7 | while 1 { 8 | $r set [expr rand()] [expr rand()] 9 | if {[clock seconds]-$start_time > $seconds} { 10 | exit 0 11 | } 12 | } 13 | } 14 | 15 | gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.o 3 | *.log 4 | dump.rdb 5 | redis-benchmark 6 | redis-check-aof 7 | redis-check-rdb 8 | redis-check-dump 9 | redis-cli 10 | redis-sentinel 11 | redis-server 12 | doc-tools 13 | release 14 | misc/* 15 | src/release.h 16 | appendonly.aof 17 | SHORT_TERM_TODO 18 | release.h 19 | src/transfer.sh 20 | src/configs 21 | redis.ds 22 | src/redis.conf 23 | src/nodes.conf 24 | deps/lua/src/lua 25 | deps/lua/src/luac 26 | deps/lua/src/liblua.a 27 | .make-* 28 | .prerequisites 29 | *.dSYM 30 | Makefile.dep 31 | -------------------------------------------------------------------------------- /tests/unit/limits.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"limits"} overrides {maxclients 10}} { 2 | test {Check if maxclients works refusing connections} { 3 | set c 0 4 | catch { 5 | while {$c < 50} { 6 | incr c 7 | set rd [redis_deferring_client] 8 | $rd ping 9 | $rd read 10 | after 100 11 | } 12 | } e 13 | assert {$c > 8 && $c <= 10} 14 | set e 15 | } {*ERR max*reached*} 16 | } 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /deps/hiredis/fmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_FMACRO_H 2 | #define __HIREDIS_FMACRO_H 3 | 4 | #if defined(__linux__) 5 | #define _BSD_SOURCE 6 | #define _DEFAULT_SOURCE 7 | #endif 8 | 9 | #if defined(__CYGWIN__) 10 | #include 11 | #endif 12 | 13 | #if defined(__sun__) 14 | #define _POSIX_C_SOURCE 200112L 15 | #else 16 | #if !(defined(__APPLE__) && defined(__MACH__)) && !(defined(__FreeBSD__)) 17 | #define _XOPEN_SOURCE 600 18 | #endif 19 | #endif 20 | 21 | #if defined(__APPLE__) && defined(__MACH__) 22 | #define _OSX 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/jemalloc_rename.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | public_symbols_txt=$1 4 | 5 | cat < 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 | -------------------------------------------------------------------------------- /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 | 10 | proc main {} { 11 | parse_options 12 | spawn_instance sentinel $::sentinel_base_port $::instances_count 13 | spawn_instance redis $::redis_base_port $::instances_count 14 | run_tests 15 | cleanup 16 | end_tests 17 | } 18 | 19 | if {[catch main e]} { 20 | puts $::errorInfo 21 | cleanup 22 | exit 1 23 | } 24 | -------------------------------------------------------------------------------- /tests/unit/introspection-2.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"introspection"}} { 2 | test {TTL and TYPYE do not alter the last access time of a key} { 3 | r set foo bar 4 | after 3000 5 | r ttl foo 6 | r type foo 7 | assert {[r object idletime foo] >= 2} 8 | } 9 | 10 | test {TOUCH alters the last access time of a key} { 11 | r set foo bar 12 | after 3000 13 | r touch foo 14 | assert {[r object idletime foo] < 2} 15 | } 16 | 17 | test {TOUCH returns the number of existing keys specified} { 18 | r flushdb 19 | r set key1 1 20 | r set key2 2 21 | r touch key0 key1 key2 key3 22 | } 2 23 | } 24 | -------------------------------------------------------------------------------- /00-RELEASENOTES: -------------------------------------------------------------------------------- 1 | Hello! This file is just a placeholder, since this is the "unstable" branch 2 | of Redis, the place where all the development happens. 3 | 4 | There is no release notes for this branch, it gets forked into another branch 5 | every time there is a partial feature freeze in order to eventually create 6 | a new stable release. 7 | 8 | Usually "unstable" is stable enough for you to use it in development environments 9 | however you should never use it in production environments. It is possible 10 | to download the latest stable release here: 11 | 12 | http://download.redis.io/releases/redis-stable.tar.gz 13 | 14 | More information is available at http://redis.io 15 | 16 | Happy hacking! 17 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | 12 | proc main {} { 13 | parse_options 14 | spawn_instance redis $::redis_base_port $::instances_count { 15 | "cluster-enabled yes" 16 | "appendonly yes" 17 | } 18 | run_tests 19 | cleanup 20 | end_tests 21 | } 22 | 23 | if {[catch main e]} { 24 | puts $::errorInfo 25 | if {$::pause_on_error} pause_on_error 26 | cleanup 27 | exit 1 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 | -------------------------------------------------------------------------------- /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/lua/test/factorial.lua: -------------------------------------------------------------------------------- 1 | -- function closures are powerful 2 | 3 | -- traditional fixed-point operator from functional programming 4 | Y = function (g) 5 | local a = function (f) return f(f) end 6 | return a(function (f) 7 | return g(function (x) 8 | local c=f(f) 9 | return c(x) 10 | end) 11 | end) 12 | end 13 | 14 | 15 | -- factorial without recursion 16 | F = function (f) 17 | return function (n) 18 | if n == 0 then return 1 19 | else return n*f(n-1) end 20 | end 21 | end 22 | 23 | factorial = Y(F) -- factorial is the fixed point of F 24 | 25 | -- now test it 26 | function test(x) 27 | io.write(x,"! = ",factorial(x),"\n") 28 | end 29 | 30 | for n=0,16 do 31 | test(n) 32 | end 33 | -------------------------------------------------------------------------------- /deps/jemalloc/test/unit/pages.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_pages_huge) { 4 | size_t alloc_size; 5 | bool commit; 6 | void *pages, *hugepage; 7 | 8 | alloc_size = HUGEPAGE * 2 - PAGE; 9 | commit = true; 10 | pages = pages_map(NULL, alloc_size, PAGE, &commit); 11 | assert_ptr_not_null(pages, "Unexpected pages_map() error"); 12 | 13 | if (init_system_thp_mode == thp_mode_default) { 14 | hugepage = (void *)(ALIGNMENT_CEILING((uintptr_t)pages, HUGEPAGE)); 15 | assert_b_ne(pages_huge(hugepage, HUGEPAGE), have_madvise_huge, 16 | "Unexpected pages_huge() result"); 17 | assert_false(pages_nohuge(hugepage, HUGEPAGE), 18 | "Unexpected pages_nohuge() result"); 19 | } 20 | 21 | pages_unmap(pages, alloc_size); 22 | } 23 | TEST_END 24 | 25 | int 26 | main(void) { 27 | return test( 28 | test_pages_huge); 29 | } 30 | -------------------------------------------------------------------------------- /tests/unit/auth.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"auth"}} { 2 | test {AUTH fails if there is no password configured server side} { 3 | catch {r auth foo} err 4 | set _ $err 5 | } {ERR*no password*} 6 | } 7 | 8 | start_server {tags {"auth"} overrides {requirepass foobar}} { 9 | test {AUTH fails when a wrong password is given} { 10 | catch {r auth wrong!} err 11 | set _ $err 12 | } {ERR*invalid password} 13 | 14 | test {Arbitrary command gives an error when AUTH is required} { 15 | catch {r set foo bar} err 16 | set _ $err 17 | } {NOAUTH*} 18 | 19 | test {AUTH succeeds when the right password is given} { 20 | r auth foobar 21 | } {OK} 22 | 23 | test {Once AUTH succeeded we can actually send commands to the server} { 24 | r set foo 100 25 | r incr foo 26 | } {101} 27 | } 28 | -------------------------------------------------------------------------------- /utils/releasetools/03_test_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ $# != "1" ] 3 | then 4 | echo "Usage: ${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/hiredis/win32.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIN32_HELPER_INCLUDE 2 | #define _WIN32_HELPER_INCLUDE 3 | #ifdef _MSC_VER 4 | 5 | #ifndef inline 6 | #define inline __inline 7 | #endif 8 | 9 | #ifndef va_copy 10 | #define va_copy(d,s) ((d) = (s)) 11 | #endif 12 | 13 | #ifndef snprintf 14 | #define snprintf c99_snprintf 15 | 16 | __inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) 17 | { 18 | int count = -1; 19 | 20 | if (size != 0) 21 | count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); 22 | if (count == -1) 23 | count = _vscprintf(format, ap); 24 | 25 | return count; 26 | } 27 | 28 | __inline int c99_snprintf(char* str, size_t size, const char* format, ...) 29 | { 30 | int count; 31 | va_list ap; 32 | 33 | va_start(ap, format); 34 | count = c99_vsnprintf(str, size, format, ap); 35 | va_end(ap); 36 | 37 | return count; 38 | } 39 | #endif 40 | 41 | #endif 42 | #endif -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /deps/hiredis/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | compiler: 4 | - gcc 5 | - clang 6 | 7 | os: 8 | - linux 9 | - osx 10 | 11 | before_script: 12 | - if [ "$TRAVIS_OS_NAME" == "osx" ] ; then brew update; brew install redis; fi 13 | 14 | addons: 15 | apt: 16 | packages: 17 | - libc6-dbg 18 | - libc6-dev 19 | - libc6:i386 20 | - libc6-dev-i386 21 | - libc6-dbg:i386 22 | - gcc-multilib 23 | - valgrind 24 | 25 | env: 26 | - CFLAGS="-Werror" 27 | - PRE="valgrind --track-origins=yes --leak-check=full" 28 | - TARGET="32bit" TARGET_VARS="32bit-vars" CFLAGS="-Werror" 29 | - TARGET="32bit" TARGET_VARS="32bit-vars" PRE="valgrind --track-origins=yes --leak-check=full" 30 | 31 | matrix: 32 | exclude: 33 | - os: osx 34 | env: PRE="valgrind --track-origins=yes --leak-check=full" 35 | 36 | - os: osx 37 | env: TARGET="32bit" TARGET_VARS="32bit-vars" PRE="valgrind --track-origins=yes --leak-check=full" 38 | 39 | script: make $TARGET CFLAGS="$CFLAGS" && make check PRE="$PRE" && make $TARGET_VARS hiredis-example 40 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /utils/releasetools/changelog.tcl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env tclsh 2 | 3 | if {[llength $::argv] != 2} { 4 | puts "Usage: $::argv0 " 5 | exit 1 6 | } 7 | 8 | set branch [lindex $::argv 0] 9 | set ver [lindex $::argv 1] 10 | 11 | set template { 12 | ================================================================================ 13 | Redis %ver% Released %date% 14 | ================================================================================ 15 | 16 | Upgrade urgency : 17 | } 18 | 19 | set template [string trim $template] 20 | append template "\n\n" 21 | set date [clock format [clock seconds]] 22 | set template [string map [list %ver% $ver %date% $date] $template] 23 | 24 | append template [exec git log $branch~100..$branch "--format=format:%an in commit %h:%n %s" --shortstat] 25 | 26 | #Older, more verbose version. 27 | # 28 | #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] 29 | 30 | puts $template 31 | -------------------------------------------------------------------------------- /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 slave is too larger than master.Master:$m_usedmemory Slave:$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 | -------------------------------------------------------------------------------- /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 | cycles = atoi(argv[2]); 25 | fd = open("dump.rdb",O_RDWR); 26 | if (fd == -1) { 27 | perror("open"); 28 | exit(1); 29 | } 30 | fstat(fd,&stat); 31 | 32 | while(cycles--) { 33 | unsigned char buf[32]; 34 | unsigned long offset = rand()%stat.st_size; 35 | int writelen = 1+rand()%31; 36 | int j; 37 | 38 | for (j = 0; j < writelen; j++) buf[j] = (char)rand(); 39 | lseek(fd,offset,SEEK_SET); 40 | printf("Writing %d bytes at offset %lu\n", writelen, offset); 41 | write(fd,buf,writelen); 42 | } 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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. 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/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 | .SUFFIXES: .c .so .xo .o 15 | 16 | all: helloworld.so hellotype.so helloblock.so testmodule.so hellocluster.so hellotimer.so 17 | 18 | .c.xo: 19 | $(CC) -I. $(CFLAGS) $(SHOBJ_CFLAGS) -fPIC -c $< -o $@ 20 | 21 | helloworld.xo: ../redismodule.h 22 | 23 | helloworld.so: helloworld.xo 24 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lc 25 | 26 | hellotype.xo: ../redismodule.h 27 | 28 | hellotype.so: hellotype.xo 29 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lc 30 | 31 | helloblock.xo: ../redismodule.h 32 | 33 | helloblock.so: helloblock.xo 34 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lpthread -lc 35 | 36 | hellocluster.xo: ../redismodule.h 37 | 38 | hellocluster.so: hellocluster.xo 39 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lc 40 | 41 | hellotimer.xo: ../redismodule.h 42 | 43 | hellotimer.so: hellotimer.xo 44 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lc 45 | 46 | testmodule.xo: ../redismodule.h 47 | 48 | testmodule.so: testmodule.xo 49 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lc 50 | 51 | clean: 52 | rm -rf *.xo *.so 53 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/integration/aof-race.tcl: -------------------------------------------------------------------------------- 1 | set defaults { appendonly {yes} appendfilename {appendonly.aof} aof-use-rdb-preamble {no} } 2 | set server_path [tmpdir server.aof] 3 | set aof_path "$server_path/appendonly.aof" 4 | 5 | proc start_server_aof {overrides code} { 6 | upvar defaults defaults srv srv server_path server_path 7 | set config [concat $defaults $overrides] 8 | start_server [list overrides $config] $code 9 | } 10 | 11 | tags {"aof"} { 12 | # Specific test for a regression where internal buffers were not properly 13 | # cleaned after a child responsible for an AOF rewrite exited. This buffer 14 | # was subsequently appended to the new AOF, resulting in duplicate commands. 15 | start_server_aof [list dir $server_path] { 16 | set client [redis [srv host] [srv port]] 17 | set bench [open "|src/redis-benchmark -q -p [srv port] -c 20 -n 20000 incr foo" "r+"] 18 | after 100 19 | 20 | # Benchmark should be running by now: start background rewrite 21 | $client bgrewriteaof 22 | 23 | # Read until benchmark pipe reaches EOF 24 | while {[string length [read $bench]] > 0} {} 25 | 26 | # Check contents of foo 27 | assert_equal 20000 [$client get foo] 28 | } 29 | 30 | # Restart server to replay AOF 31 | start_server_aof [list dir $server_path] { 32 | set client [redis [srv host] [srv port]] 33 | assert_equal 20000 [$client get foo] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/unit/wait.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"wait"}} { 2 | start_server {} { 3 | set slave [srv 0 client] 4 | set slave_host [srv 0 host] 5 | set slave_port [srv 0 port] 6 | set master [srv -1 client] 7 | set master_host [srv -1 host] 8 | set master_port [srv -1 port] 9 | 10 | test {Setup slave} { 11 | $slave slaveof $master_host $master_port 12 | wait_for_condition 50 100 { 13 | [s 0 master_link_status] eq {up} 14 | } else { 15 | fail "Replication not started." 16 | } 17 | } 18 | 19 | test {WAIT should acknowledge 1 additional copy of the data} { 20 | $master set foo 0 21 | $master incr foo 22 | $master incr foo 23 | $master incr foo 24 | assert {[$master wait 1 5000] == 1} 25 | assert {[$slave get foo] == 3} 26 | } 27 | 28 | test {WAIT should not acknowledge 2 additional copies of the data} { 29 | $master incr foo 30 | assert {[$master wait 2 1000] <= 1} 31 | } 32 | 33 | test {WAIT should not acknowledge 1 additional copy if slave is blocked} { 34 | exec src/redis-cli -h $slave_host -p $slave_port debug sleep 5 > /dev/null 2> /dev/null & 35 | after 1000 ;# Give redis-cli the time to execute the command. 36 | $master set foo 0 37 | $master incr foo 38 | $master incr foo 39 | $master incr foo 40 | assert {[$master wait 1 3000] == 0} 41 | } 42 | }} 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 <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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /deps/hiredis/appveyor.yml: -------------------------------------------------------------------------------- 1 | # Appveyor configuration file for CI build of hiredis on Windows (under Cygwin) 2 | environment: 3 | matrix: 4 | - CYG_ROOT: C:\cygwin64 5 | CYG_SETUP: setup-x86_64.exe 6 | CYG_MIRROR: http://cygwin.mirror.constant.com 7 | CYG_CACHE: C:\cygwin64\var\cache\setup 8 | CYG_BASH: C:\cygwin64\bin\bash 9 | CC: gcc 10 | - CYG_ROOT: C:\cygwin 11 | CYG_SETUP: setup-x86.exe 12 | CYG_MIRROR: http://cygwin.mirror.constant.com 13 | CYG_CACHE: C:\cygwin\var\cache\setup 14 | CYG_BASH: C:\cygwin\bin\bash 15 | CC: gcc 16 | TARGET: 32bit 17 | TARGET_VARS: 32bit-vars 18 | 19 | # Cache Cygwin files to speed up build 20 | cache: 21 | - '%CYG_CACHE%' 22 | clone_depth: 1 23 | 24 | # Attempt to ensure we don't try to convert line endings to Win32 CRLF as this will cause build to fail 25 | init: 26 | - git config --global core.autocrlf input 27 | 28 | # Install needed build dependencies 29 | install: 30 | - ps: 'Start-FileDownload "http://cygwin.com/$env:CYG_SETUP" -FileName "$env:CYG_SETUP"' 31 | - '%CYG_SETUP% --quiet-mode --no-shortcuts --only-site --root "%CYG_ROOT%" --site "%CYG_MIRROR%" --local-package-dir "%CYG_CACHE%" --packages automake,bison,gcc-core,libtool,make,gettext-devel,gettext,intltool,pkg-config,clang,llvm > NUL 2>&1' 32 | - '%CYG_BASH% -lc "cygcheck -dc cygwin"' 33 | 34 | build_script: 35 | - 'echo building...' 36 | - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0 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 | -------------------------------------------------------------------------------- /tests/helpers/bg_block_op.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | source tests/support/util.tcl 3 | 4 | # This function sometimes writes sometimes blocking-reads from lists/sorted 5 | # sets. There are multiple processes like this executing at the same time 6 | # so that we have some chance to trap some corner condition if there is 7 | # a regression. For this to happen it is important that we narrow the key 8 | # space to just a few elements, and balance the operations so that it is 9 | # unlikely that lists and zsets just get more data without ever causing 10 | # blocking. 11 | proc bg_block_op {host port db ops} { 12 | set r [redis $host $port] 13 | $r select $db 14 | 15 | for {set j 0} {$j < $ops} {incr j} { 16 | 17 | # List side 18 | set k list_[randomInt 10] 19 | set k2 list_[randomInt 10] 20 | set v [randomValue] 21 | 22 | randpath { 23 | randpath { 24 | $r rpush $k $v 25 | } { 26 | $r lpush $k $v 27 | } 28 | } { 29 | $r blpop $k 2 30 | } { 31 | $r blpop $k $k2 2 32 | } 33 | 34 | # Zset side 35 | set k zset_[randomInt 10] 36 | set k2 zset_[randomInt 10] 37 | set v1 [randomValue] 38 | set v2 [randomValue] 39 | 40 | randpath { 41 | $r zadd $k [randomInt 10000] $v 42 | } { 43 | $r zadd $k [randomInt 10000] $v [randomInt 10000] $v2 44 | } { 45 | $r bzpopmin $k 2 46 | } { 47 | $r bzpopmax $k 2 48 | } 49 | } 50 | } 51 | 52 | bg_block_op [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] 53 | -------------------------------------------------------------------------------- /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/hiredis/examples/example-libevent.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 | struct event_base *base = event_base_new(); 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 | redisLibeventAttach(c,base); 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 | event_base_dispatch(base); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /deps/lua/test/sort.lua: -------------------------------------------------------------------------------- 1 | -- two implementations of a sort function 2 | -- this is an example only. Lua has now a built-in function "sort" 3 | 4 | -- extracted from Programming Pearls, page 110 5 | function qsort(x,l,u,f) 6 | if ly end) 58 | show("after reverse selection sort",x) 59 | qsort(x,1,n,function (x,y) return x. 5 | All rights reserved. 6 | Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved. 7 | Copyright (C) 2009-2018 Facebook, Inc. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 1. Redistributions of source code must retain the above copyright notice(s), 12 | this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice(s), 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS 18 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- 28 | -------------------------------------------------------------------------------- /deps/jemalloc/src/div.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | 3 | #include "jemalloc/internal/div.h" 4 | 5 | #include "jemalloc/internal/assert.h" 6 | 7 | /* 8 | * Suppose we have n = q * d, all integers. We know n and d, and want q = n / d. 9 | * 10 | * For any k, we have (here, all division is exact; not C-style rounding): 11 | * floor(ceil(2^k / d) * n / 2^k) = floor((2^k + r) / d * n / 2^k), where 12 | * r = (-2^k) mod d. 13 | * 14 | * Expanding this out: 15 | * ... = floor(2^k / d * n / 2^k + r / d * n / 2^k) 16 | * = floor(n / d + (r / d) * (n / 2^k)). 17 | * 18 | * The fractional part of n / d is 0 (because of the assumption that d divides n 19 | * exactly), so we have: 20 | * ... = n / d + floor((r / d) * (n / 2^k)) 21 | * 22 | * So that our initial expression is equal to the quantity we seek, so long as 23 | * (r / d) * (n / 2^k) < 1. 24 | * 25 | * r is a remainder mod d, so r < d and r / d < 1 always. We can make 26 | * n / 2 ^ k < 1 by setting k = 32. This gets us a value of magic that works. 27 | */ 28 | 29 | void 30 | div_init(div_info_t *div_info, size_t d) { 31 | /* Nonsensical. */ 32 | assert(d != 0); 33 | /* 34 | * This would make the value of magic too high to fit into a uint32_t 35 | * (we would want magic = 2^32 exactly). This would mess with code gen 36 | * on 32-bit machines. 37 | */ 38 | assert(d != 1); 39 | 40 | uint64_t two_to_k = ((uint64_t)1 << 32); 41 | uint32_t magic = (uint32_t)(two_to_k / d); 42 | 43 | /* 44 | * We want magic = ceil(2^k / d), but C gives us floor. We have to 45 | * increment it unless the result was exact (i.e. unless d is a power of 46 | * two). 47 | */ 48 | if (two_to_k % d != 0) { 49 | magic++; 50 | } 51 | div_info->magic = magic; 52 | #ifdef JEMALLOC_DEBUG 53 | div_info->d = d; 54 | #endif 55 | } 56 | -------------------------------------------------------------------------------- /deps/jemalloc/include/jemalloc/internal/base_structs.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BASE_STRUCTS_H 2 | #define JEMALLOC_INTERNAL_BASE_STRUCTS_H 3 | 4 | #include "jemalloc/internal/jemalloc_internal_types.h" 5 | #include "jemalloc/internal/mutex.h" 6 | #include "jemalloc/internal/size_classes.h" 7 | 8 | /* Embedded at the beginning of every block of base-managed virtual memory. */ 9 | struct base_block_s { 10 | /* Total size of block's virtual memory mapping. */ 11 | size_t size; 12 | 13 | /* Next block in list of base's blocks. */ 14 | base_block_t *next; 15 | 16 | /* Tracks unused trailing space. */ 17 | extent_t extent; 18 | }; 19 | 20 | struct base_s { 21 | /* Associated arena's index within the arenas array. */ 22 | unsigned ind; 23 | 24 | /* 25 | * User-configurable extent hook functions. Points to an 26 | * extent_hooks_t. 27 | */ 28 | atomic_p_t extent_hooks; 29 | 30 | /* Protects base_alloc() and base_stats_get() operations. */ 31 | malloc_mutex_t mtx; 32 | 33 | /* Using THP when true (metadata_thp auto mode). */ 34 | bool auto_thp_switched; 35 | /* 36 | * Most recent size class in the series of increasingly large base 37 | * extents. Logarithmic spacing between subsequent allocations ensures 38 | * that the total number of distinct mappings remains small. 39 | */ 40 | pszind_t pind_last; 41 | 42 | /* Serial number generation state. */ 43 | size_t extent_sn_next; 44 | 45 | /* Chain of all blocks associated with base. */ 46 | base_block_t *blocks; 47 | 48 | /* Heap of extents that track unused trailing space within blocks. */ 49 | extent_heap_t avail[NSIZES]; 50 | 51 | /* Stats, only maintained if config_stats. */ 52 | size_t allocated; 53 | size_t resident; 54 | size_t mapped; 55 | /* Number of THP regions touched. */ 56 | size_t n_thp; 57 | }; 58 | 59 | #endif /* JEMALLOC_INTERNAL_BASE_STRUCTS_H */ 60 | -------------------------------------------------------------------------------- /deps/lua/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define char2int(c) cast(int, cast(unsigned char, (c))) 21 | 22 | #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) 23 | 24 | typedef struct Mbuffer { 25 | char *buffer; 26 | size_t n; 27 | size_t buffsize; 28 | } Mbuffer; 29 | 30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 31 | 32 | #define luaZ_buffer(buff) ((buff)->buffer) 33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 34 | #define luaZ_bufflen(buff) ((buff)->n) 35 | 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 41 | (buff)->buffsize = size) 42 | 43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 44 | 45 | 46 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 50 | LUAI_FUNC int luaZ_lookahead (ZIO *z); 51 | 52 | 53 | 54 | /* --------- Private Part ------------------ */ 55 | 56 | struct Zio { 57 | size_t n; /* bytes still unread */ 58 | const char *p; /* current position in buffer */ 59 | lua_Reader reader; 60 | void* data; /* additional data */ 61 | lua_State *L; /* Lua state (for reader) */ 62 | }; 63 | 64 | 65 | LUAI_FUNC int luaZ_fill (ZIO *z); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /tests/cluster/tests/00-base.tcl: -------------------------------------------------------------------------------- 1 | # Check the basic monitoring and failover capabilities. 2 | 3 | source "../tests/includes/init-tests.tcl" 4 | 5 | if {$::simulate_error} { 6 | test "This test will fail" { 7 | fail "Simulated error" 8 | } 9 | } 10 | 11 | test "Different nodes have different IDs" { 12 | set ids {} 13 | set numnodes 0 14 | foreach_redis_id id { 15 | incr numnodes 16 | # Every node should just know itself. 17 | set nodeid [dict get [get_myself $id] id] 18 | assert {$nodeid ne {}} 19 | lappend ids $nodeid 20 | } 21 | set numids [llength [lsort -unique $ids]] 22 | assert {$numids == $numnodes} 23 | } 24 | 25 | test "It is possible to perform slot allocation" { 26 | cluster_allocate_slots 5 27 | } 28 | 29 | test "After the join, every node gets a different config epoch" { 30 | set trynum 60 31 | while {[incr trynum -1] != 0} { 32 | # We check that this condition is true for *all* the nodes. 33 | set ok 1 ; # Will be set to 0 every time a node is not ok. 34 | foreach_redis_id id { 35 | set epochs {} 36 | foreach n [get_cluster_nodes $id] { 37 | lappend epochs [dict get $n config_epoch] 38 | } 39 | if {[lsort $epochs] != [lsort -unique $epochs]} { 40 | set ok 0 ; # At least one collision! 41 | } 42 | } 43 | if {$ok} break 44 | after 1000 45 | puts -nonewline . 46 | flush stdout 47 | } 48 | if {$trynum == 0} { 49 | fail "Config epoch conflict resolution is not working." 50 | } 51 | } 52 | 53 | test "Nodes should report cluster_state is ok now" { 54 | assert_cluster_state ok 55 | } 56 | 57 | test "It is possible to write and read from the cluster" { 58 | cluster_write_test 0 59 | } 60 | -------------------------------------------------------------------------------- /tests/unit/type/list-2.tcl: -------------------------------------------------------------------------------- 1 | start_server { 2 | tags {"list"} 3 | overrides { 4 | "list-max-ziplist-size" 4 5 | } 6 | } { 7 | source "tests/unit/type/list-common.tcl" 8 | 9 | foreach {type large} [array get largevalue] { 10 | tags {"slow"} { 11 | test "LTRIM stress testing - $type" { 12 | set mylist {} 13 | set startlen 32 14 | r del mylist 15 | 16 | # Start with the large value to ensure the 17 | # right encoding is used. 18 | r rpush mylist $large 19 | lappend mylist $large 20 | 21 | for {set i 0} {$i < $startlen} {incr i} { 22 | set str [randomInt 9223372036854775807] 23 | r rpush mylist $str 24 | lappend mylist $str 25 | } 26 | 27 | for {set i 0} {$i < 1000} {incr i} { 28 | set min [expr {int(rand()*$startlen)}] 29 | set max [expr {$min+int(rand()*$startlen)}] 30 | set before_len [llength $mylist] 31 | set before_len_r [r llen mylist] 32 | set mylist [lrange $mylist $min $max] 33 | r ltrim mylist $min $max 34 | assert_equal $mylist [r lrange mylist 0 -1] "failed trim" 35 | 36 | set starting [r llen mylist] 37 | for {set j [r llen mylist]} {$j < $startlen} {incr j} { 38 | set str [randomInt 9223372036854775807] 39 | r rpush mylist $str 40 | lappend mylist $str 41 | assert_equal $mylist [r lrange mylist 0 -1] "failed append match" 42 | } 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /deps/hiredis/examples/example-ae.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /* Put event loop in the global scope, so it can be explicitly stopped */ 11 | static aeEventLoop *loop; 12 | 13 | void getCallback(redisAsyncContext *c, void *r, void *privdata) { 14 | redisReply *reply = r; 15 | if (reply == NULL) return; 16 | printf("argv[%s]: %s\n", (char*)privdata, reply->str); 17 | 18 | /* Disconnect after receiving the reply to GET */ 19 | redisAsyncDisconnect(c); 20 | } 21 | 22 | void connectCallback(const redisAsyncContext *c, int status) { 23 | if (status != REDIS_OK) { 24 | printf("Error: %s\n", c->errstr); 25 | aeStop(loop); 26 | return; 27 | } 28 | 29 | printf("Connected...\n"); 30 | } 31 | 32 | void disconnectCallback(const redisAsyncContext *c, int status) { 33 | if (status != REDIS_OK) { 34 | printf("Error: %s\n", c->errstr); 35 | aeStop(loop); 36 | return; 37 | } 38 | 39 | printf("Disconnected...\n"); 40 | aeStop(loop); 41 | } 42 | 43 | int main (int argc, char **argv) { 44 | signal(SIGPIPE, SIG_IGN); 45 | 46 | redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); 47 | if (c->err) { 48 | /* Let *c leak for now... */ 49 | printf("Error: %s\n", c->errstr); 50 | return 1; 51 | } 52 | 53 | loop = aeCreateEventLoop(64); 54 | redisAeAttach(loop, c); 55 | redisAsyncSetConnectCallback(c,connectCallback); 56 | redisAsyncSetDisconnectCallback(c,disconnectCallback); 57 | redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); 58 | redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key"); 59 | aeMain(loop); 60 | return 0; 61 | } 62 | 63 | --------------------------------------------------------------------------------