├── INSTALL
├── tests
├── tmp
│ └── .gitignore
├── cluster
│ ├── tmp
│ │ └── .gitignore
│ ├── tests
│ │ ├── helpers
│ │ │ └── onlydots.tcl
│ │ ├── 01-faildet.tcl
│ │ ├── 09-pubsub.tcl
│ │ ├── 11-manual-takeover.tcl
│ │ ├── 02-failover.tcl
│ │ ├── 00-base.tcl
│ │ └── 12-replica-migration-2.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
│ ├── memefficiency.tcl
│ ├── lazyfree.tcl
│ └── latency-monitor.tcl
├── helpers
│ ├── bg_complex_data.tcl
│ └── gen_write_load.tcl
├── support
│ └── tmpfile.tcl
└── integration
│ ├── logging.tcl
│ ├── aof-race.tcl
│ └── convert-zipmap-hash-on-load.tcl
├── deps
├── jemalloc
│ ├── config.stamp.in
│ ├── .gitattributes
│ ├── VERSION
│ ├── test
│ │ ├── src
│ │ │ ├── math.c
│ │ │ ├── btalloc_0.c
│ │ │ ├── btalloc_1.c
│ │ │ ├── btalloc.c
│ │ │ ├── mq.c
│ │ │ ├── thd.c
│ │ │ ├── mtx.c
│ │ │ └── timer.c
│ │ ├── unit
│ │ │ ├── junk_free.c
│ │ │ ├── junk_alloc.c
│ │ │ ├── lg_chunk.c
│ │ │ ├── prof_idump.c
│ │ │ ├── mtx.c
│ │ │ ├── zero.c
│ │ │ └── mq.c
│ │ ├── include
│ │ │ └── test
│ │ │ │ ├── thd.h
│ │ │ │ ├── jemalloc_test_defs.h.in
│ │ │ │ ├── mtx.h
│ │ │ │ ├── timer.h
│ │ │ │ └── btalloc.h
│ │ ├── test.sh.in
│ │ └── integration
│ │ │ ├── sdallocx.c
│ │ │ ├── overflow.c
│ │ │ ├── MALLOCX_ARENA.c
│ │ │ └── thread_arena.c
│ ├── src
│ │ ├── mb.c
│ │ ├── hash.c
│ │ ├── atomic.c
│ │ ├── valgrind.c
│ │ └── extent.c
│ ├── doc
│ │ ├── jemalloc.html
│ │ ├── html.xsl.in
│ │ ├── manpages.xsl.in
│ │ └── stylesheet.xsl
│ ├── .autom4te.cfg
│ ├── include
│ │ ├── jemalloc
│ │ │ ├── internal
│ │ │ │ ├── private_unnamespace.sh
│ │ │ │ ├── private_namespace.sh
│ │ │ │ ├── public_unnamespace.sh
│ │ │ │ ├── public_namespace.sh
│ │ │ │ ├── chunk_mmap.h
│ │ │ │ ├── base.h
│ │ │ │ ├── pages.h
│ │ │ │ ├── chunk_dss.h
│ │ │ │ ├── huge.h
│ │ │ │ ├── jemalloc_internal_decls.h
│ │ │ │ ├── quarantine.h
│ │ │ │ └── jemalloc_internal_macros.h
│ │ │ ├── jemalloc_rename.sh
│ │ │ ├── jemalloc.sh
│ │ │ ├── jemalloc_defs.h.in
│ │ │ ├── jemalloc_mangle.sh
│ │ │ └── jemalloc_typedefs.h.in
│ │ └── msvc_compat
│ │ │ ├── C99
│ │ │ └── stdbool.h
│ │ │ ├── strings.h
│ │ │ └── windows_extra.h
│ ├── bin
│ │ ├── jemalloc.sh.in
│ │ └── jemalloc-config.in
│ ├── autogen.sh
│ ├── coverage.sh
│ ├── jemalloc.pc.in
│ ├── README
│ ├── COPYING
│ └── .gitignore
├── 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
│ │ ├── ltm.c
│ │ ├── lzio.c
│ │ └── ldo.h
│ ├── README
│ └── COPYRIGHT
├── hiredis
│ ├── .gitignore
│ ├── .travis.yml
│ ├── zmalloc.h
│ ├── fmacros.h
│ ├── CHANGELOG.md
│ ├── examples
│ │ ├── example-libev.c
│ │ ├── example-libuv.c
│ │ ├── example-libevent.c
│ │ └── example-ae.c
│ └── 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_init_script
├── redis-copy.rb
├── cluster_fail_time.tcl
└── redis-sha1.rb
├── src
├── modules
│ ├── .gitignore
│ ├── Makefile
│ └── gendoc.rb
├── version.h
├── simple.txt
├── .gitignore
├── test1.txt
├── crc64.h
├── valgrind.sup
├── geo.h
├── mkreleasehdr.sh
├── sha1.h
├── rand.h
├── graph.h
├── pqsort.h
└── sdsalloc.h
├── BUGS
├── graph_tests
├── rename.sh
├── removing_edges_2_spec.rb
├── minimum_spanning_tree_spec.rb
├── page_rank_spec.rb
├── graph_vertices_spec.rb
├── shortest_distance_spec.rb
├── common_neighbours_spec.rb
├── max_neighbour_spec.rb
├── minimum_spanning_tree_2_spec.rb
├── directed_graph_spec.rb
├── shortest_distance_2_spec.rb
├── errors_spec.rb
├── edge_incr_by_spec.rb
├── removing_edges_spec.rb
└── removing_nodes_spec.rb
├── deploy.sh
├── Makefile
├── runtest
├── runtest-cluster
├── runtest-sentinel
├── .gitignore
├── Dockerfile
├── 00-RELEASENOTES
├── COPYING
└── CONTRIBUTING
/INSTALL:
--------------------------------------------------------------------------------
1 | See README
2 |
--------------------------------------------------------------------------------
/tests/tmp/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
--------------------------------------------------------------------------------
/deps/jemalloc/config.stamp.in:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/simple.txt:
--------------------------------------------------------------------------------
1 | gvertex graph1 a b c
2 | gedge graph1 c b 1
3 |
--------------------------------------------------------------------------------
/deps/jemalloc/VERSION:
--------------------------------------------------------------------------------
1 | 4.0.3-0-ge9192eacf8935e29fc62fddc2701f7942b1cc02c
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/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/etc/lua.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmarQunsul/graph-redis/HEAD/deps/lua/etc/lua.ico
--------------------------------------------------------------------------------
/deps/jemalloc/src/mb.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_MB_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
--------------------------------------------------------------------------------
/deps/lua/doc/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmarQunsul/graph-redis/HEAD/deps/lua/doc/cover.png
--------------------------------------------------------------------------------
/deps/lua/doc/logo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmarQunsul/graph-redis/HEAD/deps/lua/doc/logo.gif
--------------------------------------------------------------------------------
/deps/lua/test/life.lua:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmarQunsul/graph-redis/HEAD/deps/lua/test/life.lua
--------------------------------------------------------------------------------
/tests/sentinel/tests/03-runtime-reconf.tcl:
--------------------------------------------------------------------------------
1 | # Test runtime reconfiguration command SENTINEL SET.
2 |
--------------------------------------------------------------------------------
/deps/jemalloc/src/hash.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_HASH_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
--------------------------------------------------------------------------------
/deps/hiredis/.gitignore:
--------------------------------------------------------------------------------
1 | /hiredis-test
2 | /examples/hiredis-example*
3 | /*.o
4 | /*.so
5 | /*.dylib
6 | /*.a
7 |
--------------------------------------------------------------------------------
/deps/jemalloc/src/atomic.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_ATOMIC_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
--------------------------------------------------------------------------------
/tests/assets/encodings.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmarQunsul/graph-redis/HEAD/tests/assets/encodings.rdb
--------------------------------------------------------------------------------
/deps/hiredis/.travis.yml:
--------------------------------------------------------------------------------
1 | language: c
2 | compiler:
3 | - gcc
4 | - clang
5 |
6 | script: make && make check
7 |
--------------------------------------------------------------------------------
/tests/assets/hash-zipmap.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmarQunsul/graph-redis/HEAD/tests/assets/hash-zipmap.rdb
--------------------------------------------------------------------------------
/deps/jemalloc/doc/jemalloc.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OmarQunsul/graph-redis/HEAD/deps/jemalloc/doc/jemalloc.html
--------------------------------------------------------------------------------
/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/junk_free.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_TEST_JUNK_OPT "junk:free"
2 | #include "junk.c"
3 | #undef JEMALLOC_TEST_JUNK_OPT
4 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/unit/junk_alloc.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_TEST_JUNK_OPT "junk:alloc"
2 | #include "junk.c"
3 | #undef JEMALLOC_TEST_JUNK_OPT
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/include/jemalloc/internal/private_unnamespace.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | for symbol in `cat $1` ; do
4 | echo "#undef ${symbol}"
5 | done
6 |
--------------------------------------------------------------------------------
/graph_tests/rename.sh:
--------------------------------------------------------------------------------
1 |
2 | for f in $(ls *.rb)
3 | do
4 | IFS='.' read -r -a array <<< "$f"
5 | echo $array
6 | mv $f "${array}_spec.rb"
7 | done
8 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/private_namespace.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | for symbol in `cat $1` ; do
4 | echo "#define ${symbol} JEMALLOC_N(${symbol})"
5 | done
6 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/src/btalloc.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | void *
4 | btalloc(size_t size, unsigned bits)
5 | {
6 |
7 | return (btalloc_0(size, bits));
8 | }
9 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/deploy.sh:
--------------------------------------------------------------------------------
1 | make
2 | sudo make install
3 | sudo /etc/init.d/redis_6379 stop
4 | sudo killall redis-server
5 | sudo rm /var/run/redis_6379.pid
6 | #sudo /etc/init.d/redis_6379 start
7 | gdb -ex run redis-server
8 |
--------------------------------------------------------------------------------
/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/html.xsl.in:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/test1.txt:
--------------------------------------------------------------------------------
1 | gvertices graph1
2 | gvertex graph1 a
3 | gvertex graph1 b
4 | gvertex graph1 c
5 | gvertices graph1
6 | gedges graph1
7 | gedge graph1 a b 5
8 | gedge graph1 b c 5
9 | gedges graph1
10 | gedgerem graph1 b c
11 | save
12 |
--------------------------------------------------------------------------------
/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/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/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 |
--------------------------------------------------------------------------------
/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/lua/test/fibfor.lua:
--------------------------------------------------------------------------------
1 | -- example of for with generator functions
2 |
3 | function generatefib (n)
4 | return coroutine.wrap(function ()
5 | local a,b = 1, 1
6 | while a <= n do
7 | coroutine.yield(a)
8 | a, b = b, a+b
9 | end
10 | end)
11 | end
12 |
13 | for i in generatefib(1000) do print(i) end
14 |
--------------------------------------------------------------------------------
/deps/lua/test/readonly.lua:
--------------------------------------------------------------------------------
1 | -- make global variables readonly
2 |
3 | local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end
4 | local g={}
5 | local G=getfenv()
6 | setmetatable(g,{__index=G,__newindex=f})
7 | setfenv(1,g)
8 |
9 | -- an example
10 | rawset(g,"x",3)
11 | x=2
12 | y=1 -- cannot redefine `y'
13 |
--------------------------------------------------------------------------------
/deps/update-jemalloc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | VER=$1
3 | URL="http://www.canonware.com/download/jemalloc/jemalloc-${VER}.tar.bz2"
4 | echo "Downloading $URL"
5 | curl $URL > /tmp/jemalloc.tar.bz2
6 | tar xvjf /tmp/jemalloc.tar.bz2
7 | rm -rf jemalloc
8 | mv jemalloc-${VER} jemalloc
9 | echo "Use git status, add all files and commit changes."
10 |
--------------------------------------------------------------------------------
/runtest:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | TCL_VERSIONS="8.5 8.6"
3 | TCLSH=""
4 |
5 | for VERSION in $TCL_VERSIONS; do
6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL
7 | done
8 |
9 | if [ -z $TCLSH ]
10 | then
11 | echo "You need tcl 8.5 or newer in order to run the Redis test"
12 | exit 1
13 | fi
14 | $TCLSH tests/test_helper.tcl $*
15 |
--------------------------------------------------------------------------------
/deps/hiredis/zmalloc.h:
--------------------------------------------------------------------------------
1 | /* Drop in replacement for zmalloc.h in order to just use libc malloc without
2 | * any wrappering. */
3 |
4 | #ifndef ZMALLOC_H
5 | #define ZMALLOC_H
6 |
7 | #define zmalloc malloc
8 | #define zrealloc realloc
9 | #define zcalloc(x) calloc(x,1)
10 | #define zfree free
11 | #define zstrdup strdup
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/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/doc/stylesheet.xsl:
--------------------------------------------------------------------------------
1 |
2 | ansi
3 |
4 |
5 | ""
6 |
7 |
8 |
--------------------------------------------------------------------------------
/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/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/coverage.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | objdir=$1
6 | suffix=$2
7 | shift 2
8 | objs=$@
9 |
10 | gcov -b -p -f -o "${objdir}" ${objs}
11 |
12 | # Move gcov outputs so that subsequent gcov invocations won't clobber results
13 | # for the same sources with different compilation flags.
14 | for f in `find . -maxdepth 1 -type f -name '*.gcov'` ; do
15 | mv "${f}" "${f}.${suffix}"
16 | done
17 |
--------------------------------------------------------------------------------
/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 | cut -f 1 -d' ')
3 | ENTRY="hash redis-${1}.tar.gz sha1 $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 |
--------------------------------------------------------------------------------
/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/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://www.canonware.com/jemalloc
10 | Version: @jemalloc_version@
11 | Cflags: -I${includedir}
12 | Libs: -L${libdir} -ljemalloc${install_suffix}
13 |
--------------------------------------------------------------------------------
/deps/lua/doc/manual.css:
--------------------------------------------------------------------------------
1 | h3 code {
2 | font-family: inherit ;
3 | font-size: inherit ;
4 | }
5 |
6 | pre, code {
7 | font-size: 12pt ;
8 | }
9 |
10 | span.apii {
11 | float: right ;
12 | font-family: inherit ;
13 | font-style: normal ;
14 | font-size: small ;
15 | color: gray ;
16 | }
17 |
18 | p+h1, ul+h1 {
19 | padding-top: 0.4em ;
20 | padding-bottom: 0.4em ;
21 | padding-left: 30px ;
22 | margin-left: -30px ;
23 | background-color: #E0E0FF ;
24 | }
25 |
--------------------------------------------------------------------------------
/utils/hashtable/README:
--------------------------------------------------------------------------------
1 | Hash table implementation related utilities.
2 |
3 | rehashing.c
4 | ---
5 |
6 | Visually show buckets in the two hash tables between rehashings. Also stress
7 | test getRandomKeys() implementation, that may actually disappear from
8 | Redis soon, however visualizaiton 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 |
--------------------------------------------------------------------------------
/tests/support/tmpfile.tcl:
--------------------------------------------------------------------------------
1 | set ::tmpcounter 0
2 | set ::tmproot "./tests/tmp"
3 | file mkdir $::tmproot
4 |
5 | # returns a dirname unique to this process to write to
6 | proc tmpdir {basename} {
7 | set dir [file join $::tmproot $basename.[pid].[incr ::tmpcounter]]
8 | file mkdir $dir
9 | set _ $dir
10 | }
11 |
12 | # return a filename unique to this process to write to
13 | proc tmpfile {basename} {
14 | file join $::tmproot $basename.[pid].[incr ::tmpcounter]
15 | }
16 |
--------------------------------------------------------------------------------
/deps/lua/test/globals.lua:
--------------------------------------------------------------------------------
1 | -- reads luac listings and reports global variable usage
2 | -- lines where a global is written to are marked with "*"
3 | -- typical usage: luac -p -l file.lua | lua globals.lua | sort | lua table.lua
4 |
5 | while 1 do
6 | local s=io.read()
7 | if s==nil then break end
8 | local ok,_,l,op,g=string.find(s,"%[%-?(%d*)%]%s*([GS])ETGLOBAL.-;%s+(.*)$")
9 | if ok then
10 | if op=="S" then op="*" else op="" end
11 | io.write(g,"\t",l,op,"\n")
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/src/geo.h:
--------------------------------------------------------------------------------
1 | #ifndef __GEO_H__
2 | #define __GEO_H__
3 |
4 | #include "server.h"
5 |
6 | /* Structures used inside geo.c in order to represent points and array of
7 | * points on the earth. */
8 | typedef struct geoPoint {
9 | double longitude;
10 | double latitude;
11 | double dist;
12 | double score;
13 | char *member;
14 | } geoPoint;
15 |
16 | typedef struct geoArray {
17 | struct geoPoint *array;
18 | size_t buckets;
19 | size_t used;
20 | } geoArray;
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/tests/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/hiredis/fmacros.h:
--------------------------------------------------------------------------------
1 | #ifndef __HIREDIS_FMACRO_H
2 | #define __HIREDIS_FMACRO_H
3 |
4 | #if !defined(_BSD_SOURCE)
5 | #define _BSD_SOURCE
6 | #endif
7 |
8 | #if defined(_AIX)
9 | #define _ALL_SOURCE
10 | #endif
11 |
12 | #if defined(__sun__)
13 | #define _POSIX_C_SOURCE 200112L
14 | #elif defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__)
15 | #define _XOPEN_SOURCE 600
16 | #else
17 | #define _XOPEN_SOURCE
18 | #endif
19 |
20 | #if __APPLE__ && __MACH__
21 | #define _OSX
22 | #endif
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .*.swp
2 | *.o
3 | *.log
4 | dump.rdb
5 | *.rdb
6 | redis-benchmark
7 | redis-check-aof
8 | redis-check-rdb
9 | redis-check-dump
10 | redis-cli
11 | redis-sentinel
12 | redis-server
13 | doc-tools
14 | release
15 | misc/*
16 | src/release.h
17 | appendonly.aof
18 | SHORT_TERM_TODO
19 | release.h
20 | src/transfer.sh
21 | src/configs
22 | redis.ds
23 | src/redis.conf
24 | src/nodes.conf
25 | deps/lua/src/lua
26 | deps/lua/src/luac
27 | deps/lua/src/liblua.a
28 | .make-*
29 | .prerequisites
30 | *.dSYM
31 | Makefile.dep
32 |
--------------------------------------------------------------------------------
/tests/assets/default.conf:
--------------------------------------------------------------------------------
1 | # Redis configuration for testing.
2 |
3 | notify-keyspace-events KEA
4 | daemonize no
5 | pidfile /var/run/redis.pid
6 | port 6379
7 | timeout 0
8 | bind 127.0.0.1
9 | loglevel verbose
10 | logfile ''
11 | databases 16
12 | latency-monitor-threshold 1
13 |
14 | save 900 1
15 | save 300 10
16 | save 60 10000
17 |
18 | rdbcompression yes
19 | dbfilename dump.rdb
20 | dir ./
21 |
22 | slave-serve-stale-data yes
23 | appendonly no
24 | appendfsync everysec
25 | no-appendfsync-on-rewrite no
26 | activerehashing yes
27 |
--------------------------------------------------------------------------------
/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/include/jemalloc/jemalloc_rename.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | public_symbols_txt=$1
4 |
5 | cat < /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 | test -f release.h || touch release.h
6 | (cat release.h | grep SHA1 | grep $GIT_SHA1) && \
7 | (cat release.h | grep DIRTY | grep $GIT_DIRTY) && exit 0 # Already up-to-date
8 | echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h
9 | echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h
10 | echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h
11 | touch release.c # Force recompile of release.c
12 |
--------------------------------------------------------------------------------
/deps/lua/src/fpconv.h:
--------------------------------------------------------------------------------
1 | /* Lua CJSON floating point conversion routines */
2 |
3 | /* Buffer required to store the largest string representation of a double.
4 | *
5 | * Longest double printed with %.14g is 21 characters long:
6 | * -1.7976931348623e+308 */
7 | # define FPCONV_G_FMT_BUFSIZE 32
8 |
9 | #ifdef USE_INTERNAL_FPCONV
10 | static inline void fpconv_init()
11 | {
12 | /* Do nothing - not required */
13 | }
14 | #else
15 | extern void fpconv_init();
16 | #endif
17 |
18 | extern int fpconv_g_fmt(char*, double, int);
19 | extern double fpconv_strtod(const char*, char**);
20 |
21 | /* vi:ai et sw=4 ts=4:
22 | */
23 |
--------------------------------------------------------------------------------
/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_OSSPIN))
12 | OSSpinLock lock;
13 | #else
14 | pthread_mutex_t lock;
15 | #endif
16 | } mtx_t;
17 |
18 | bool mtx_init(mtx_t *mtx);
19 | void mtx_fini(mtx_t *mtx);
20 | void mtx_lock(mtx_t *mtx);
21 | void mtx_unlock(mtx_t *mtx);
22 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/unit/lg_chunk.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | /*
4 | * Make sure that opt.lg_chunk clamping is sufficient. In practice, this test
5 | * program will fail a debug assertion during initialization and abort (rather
6 | * than the test soft-failing) if clamping is insufficient.
7 | */
8 | const char *malloc_conf = "lg_chunk:0";
9 |
10 | TEST_BEGIN(test_lg_chunk_clamp)
11 | {
12 | void *p;
13 |
14 | p = mallocx(1, 0);
15 | assert_ptr_not_null(p, "Unexpected mallocx() failure");
16 | dallocx(p, 0);
17 | }
18 | TEST_END
19 |
20 | int
21 | main(void)
22 | {
23 |
24 | return (test(
25 | test_lg_chunk_clamp));
26 | }
27 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/jemalloc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | objroot=$1
4 |
5 | cat <
8 | # pragma intrinsic(_BitScanForward)
9 | static __forceinline int ffsl(long x)
10 | {
11 | unsigned long i;
12 |
13 | if (_BitScanForward(&i, x))
14 | return (i + 1);
15 | return (0);
16 | }
17 |
18 | static __forceinline int ffs(int x)
19 | {
20 |
21 | return (ffsl(x));
22 | }
23 |
24 | #else
25 | # define ffsl(x) __builtin_ffsl(x)
26 | # define ffs(x) __builtin_ffs(x)
27 | #endif
28 |
29 | #endif /* strings_h */
30 |
--------------------------------------------------------------------------------
/src/sha1.h:
--------------------------------------------------------------------------------
1 | #ifndef SHA1_H
2 | #define SHA1_H
3 | /* ================ sha1.h ================ */
4 | /*
5 | SHA-1 in C
6 | By Steve Reid
7 | 100% Public Domain
8 | */
9 |
10 | typedef struct {
11 | uint32_t state[5];
12 | uint32_t count[2];
13 | unsigned char buffer[64];
14 | } SHA1_CTX;
15 |
16 | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
17 | void SHA1Init(SHA1_CTX* context);
18 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
19 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
20 |
21 | #ifdef REDIS_TEST
22 | int sha1Test(int argc, char **argv);
23 | #endif
24 | #endif
25 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:stable-slim
2 |
3 | RUN groupadd -r redis && useradd -r -g redis redis
4 |
5 | RUN apt-get update && apt-get install -y --no-install-recommends \
6 | gcc make libc6-dev \
7 | && rm -rf /var/lib/apt/lists/*
8 |
9 | COPY src/ /usr/src/redis/src/
10 | COPY deps/ /usr/src/redis/deps/
11 | COPY Makefile /usr/src/redis/
12 | COPY *.conf /usr/src/redis/
13 | WORKDIR /usr/src/redis
14 |
15 | RUN make && make install && make clean
16 |
17 | RUN mkdir /data && chown redis:redis /data
18 | VOLUME /data
19 | WORKDIR /data
20 |
21 | RUN mkdir -p /etc/redis
22 | ADD *.conf /etc/redis/
23 |
24 | EXPOSE 6379
25 | CMD [ "redis-server", "/etc/redis/redis.conf" ]
26 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/msvc_compat/windows_extra.h:
--------------------------------------------------------------------------------
1 | #ifndef MSVC_COMPAT_WINDOWS_EXTRA_H
2 | #define MSVC_COMPAT_WINDOWS_EXTRA_H
3 |
4 | #ifndef ENOENT
5 | # define ENOENT ERROR_PATH_NOT_FOUND
6 | #endif
7 | #ifndef EINVAL
8 | # define EINVAL ERROR_BAD_ARGUMENTS
9 | #endif
10 | #ifndef EAGAIN
11 | # define EAGAIN ERROR_OUTOFMEMORY
12 | #endif
13 | #ifndef EPERM
14 | # define EPERM ERROR_WRITE_FAULT
15 | #endif
16 | #ifndef EFAULT
17 | # define EFAULT ERROR_INVALID_ADDRESS
18 | #endif
19 | #ifndef ENOMEM
20 | # define ENOMEM ERROR_NOT_ENOUGH_MEMORY
21 | #endif
22 | #ifndef ERANGE
23 | # define ERANGE ERROR_INVALID_DATA
24 | #endif
25 |
26 | #endif /* MSVC_COMPAT_WINDOWS_EXTRA_H */
27 |
--------------------------------------------------------------------------------
/graph_tests/removing_edges_2_spec.rb:
--------------------------------------------------------------------------------
1 | # edges exists
2 |
3 | require 'redis'
4 |
5 | redis = Redis.new
6 |
7 | describe 'Removing edges' do
8 |
9 | it 'should correctly remove edges from undirected graphs' do
10 | redis.flushdb
11 | redis.gnode 'graph1', 'a', 'b', 'c', 'd'
12 | redis.gedge 'graph1', 'a', 'b', 1
13 | redis.gedge 'graph1', 'b', 'c', 1
14 | redis.gedgeexists('graph1', 'a', 'b').should eq 1
15 | redis.gedgeexists('graph1', 'b', 'a').should eq 1
16 | redis.gedgerem('graph1', 'b', 'a').should eq 1
17 | redis.gedgeexists('graph1', 'a', 'b').should eq 0
18 | redis.gedgeexists('graph1', 'b', 'a').should eq 0
19 | end
20 |
21 | end
22 |
23 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/graph_tests/minimum_spanning_tree_spec.rb:
--------------------------------------------------------------------------------
1 | # Minimum spanning tree
2 |
3 | require 'redis'
4 |
5 | redis = Redis.new
6 |
7 | describe 'Minimum spanning tree' do
8 |
9 | it 'should calculate the correct minimum spanning tree' do
10 | redis.flushdb
11 | redis.gnode 'graph1', 'a', 'b', 'c', 'd', 'e'
12 | redis.gedge 'graph1', 'a', 'b', 1
13 | redis.gedge 'graph1', 'c', 'b', 1
14 | redis.gedge 'graph1', 'a', 'd', 100
15 | redis.gedge 'graph1', 'd', 'e', 1
16 | redis.gedge 'graph1', 'a', 'e', 3
17 | redis.gedge 'graph1', 'd', 'c', 1
18 |
19 | redis.gmintree('graph1', 'graph2')
20 | min_tree = redis.gedges('graph2')
21 |
22 | min_tree.length.should eq 4 * 3
23 | end
24 |
25 | end
26 |
27 |
--------------------------------------------------------------------------------
/deps/jemalloc/src/valgrind.c:
--------------------------------------------------------------------------------
1 | #include "jemalloc/internal/jemalloc_internal.h"
2 | #ifndef JEMALLOC_VALGRIND
3 | # error "This source file is for Valgrind integration."
4 | #endif
5 |
6 | #include
7 |
8 | void
9 | valgrind_make_mem_noaccess(void *ptr, size_t usize)
10 | {
11 |
12 | VALGRIND_MAKE_MEM_NOACCESS(ptr, usize);
13 | }
14 |
15 | void
16 | valgrind_make_mem_undefined(void *ptr, size_t usize)
17 | {
18 |
19 | VALGRIND_MAKE_MEM_UNDEFINED(ptr, usize);
20 | }
21 |
22 | void
23 | valgrind_make_mem_defined(void *ptr, size_t usize)
24 | {
25 |
26 | VALGRIND_MAKE_MEM_DEFINED(ptr, usize);
27 | }
28 |
29 | void
30 | valgrind_freelike_block(void *ptr, size_t usize)
31 | {
32 |
33 | VALGRIND_FREELIKE_BLOCK(ptr, usize);
34 | }
35 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/include/test/timer.h:
--------------------------------------------------------------------------------
1 | /* Simple timer, for use in benchmark reporting. */
2 |
3 | #include
4 | #include
5 |
6 | #define JEMALLOC_CLOCK_GETTIME defined(_POSIX_MONOTONIC_CLOCK) \
7 | && _POSIX_MONOTONIC_CLOCK >= 0
8 |
9 | typedef struct {
10 | #ifdef _WIN32
11 | FILETIME ft0;
12 | FILETIME ft1;
13 | #elif JEMALLOC_CLOCK_GETTIME
14 | struct timespec ts0;
15 | struct timespec ts1;
16 | int clock_id;
17 | #else
18 | struct timeval tv0;
19 | struct timeval tv1;
20 | #endif
21 | } timedelta_t;
22 |
23 | void timer_start(timedelta_t *timer);
24 | void timer_stop(timedelta_t *timer);
25 | uint64_t timer_usec(const timedelta_t *timer);
26 | void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen);
27 |
--------------------------------------------------------------------------------
/graph_tests/page_rank_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'basic commands' do
6 | before do
7 | redis.flushdb
8 | redis.gnode 'graph1', 'a', 'b', 'c', 'd', 'e', 'f', 'g'
9 | redis.gsetdirected 'graph1'
10 | redis.gedge 'graph1', 'a', 'c', 1
11 | redis.gedge 'graph1', 'b', 'c', 1
12 | redis.gedge 'graph1', 'c', 'd', 1
13 | redis.gedge 'graph1', 'd', 'b', 1
14 | redis.gedge 'graph1', 'e', 'c', 1
15 | redis.gedge 'graph1', 'a', 'e', 1
16 | redis.gedge 'graph1', 'c', 'g', 1
17 | redis.gedge 'graph1', 'c', 'b', 1
18 | redis.gedge 'graph1', 'b', 'g', 1
19 | end
20 |
21 | it "should calculate the correct page rank values" do
22 | ret = redis.granks 'graph1'
23 | # TODO
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/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) 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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/graph_tests/graph_vertices_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'basic commands' do
6 | before do
7 | redis.flushdb
8 | end
9 |
10 | it "should list the graph nodes correctly" do
11 | redis.gnode 'graph1', 'a'
12 | nodes = redis.gnodes 'graph1', '*'
13 | nodes.should eq ['a']
14 | nodes = redis.gnodes 'graph1', '*'
15 | nodes.should eq ['a']
16 | end
17 |
18 | it "should be able to filter graph nodes" do
19 | redis.gnode 'graph1', 'country:jordan', 'country:germany', 'user:omar', 'user:john'
20 | countries = redis.gnodes 'graph1', 'country:*'
21 | expect(countries).to eq(%w(country:jordan country:germany))
22 | countries = redis.gnodes 'graph1', 'user:*'
23 | expect(countries).to eq(%w(user:omar user:john))
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/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/hiredis/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ### 0.11.0
2 |
3 | * Increase the maximum multi-bulk reply depth to 7.
4 |
5 | * Increase the read buffer size from 2k to 16k.
6 |
7 | * Use poll(2) instead of select(2) to support large fds (>= 1024).
8 |
9 | ### 0.10.1
10 |
11 | * Makefile overhaul. Important to check out if you override one or more
12 | variables using environment variables or via arguments to the "make" tool.
13 |
14 | * Issue #45: Fix potential memory leak for a multi bulk reply with 0 elements
15 | being created by the default reply object functions.
16 |
17 | * Issue #43: Don't crash in an asynchronous context when Redis returns an error
18 | reply after the connection has been made (this happens when the maximum
19 | number of connections is reached).
20 |
21 | ### 0.10.0
22 |
23 | * See commit log.
24 |
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/graph_tests/shortest_distance_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'shortest path' do
6 | before do
7 | redis.flushdb
8 | redis.gnode 'graph1', 'a', 'b', 'c'
9 | redis.gedge 'graph1', 'a', 'b', 1
10 | redis.gedge 'graph1', 'a', 'b', 3
11 | redis.gedge 'graph1', 'b', 'c', 2
12 |
13 | @result = redis.gshortestpath('graph1', 'a', 'c')
14 | @result2 = redis.gshortestpath('graph1', 'a', 'c')
15 | end
16 |
17 | it 'should make the path from a to c = 5' do
18 | @result.last.should eq "5"
19 | end
20 |
21 | it 'should have the right order of the path' do
22 | @result[0].should eq 'a'
23 | @result[1].should eq 'b'
24 | @result[2].should eq 'c'
25 | end
26 |
27 | it 'should print the correct nodes' do
28 | nodes = redis.gnodes('graph1', '*')
29 | nodes.should eq ['a', 'b', 'c']
30 | end
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/chunk_mmap.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
3 |
4 | #endif /* JEMALLOC_H_TYPES */
5 | /******************************************************************************/
6 | #ifdef JEMALLOC_H_STRUCTS
7 |
8 | #endif /* JEMALLOC_H_STRUCTS */
9 | /******************************************************************************/
10 | #ifdef JEMALLOC_H_EXTERNS
11 |
12 | void *chunk_alloc_mmap(size_t size, size_t alignment, bool *zero,
13 | bool *commit);
14 | bool chunk_dalloc_mmap(void *chunk, size_t size);
15 |
16 | #endif /* JEMALLOC_H_EXTERNS */
17 | /******************************************************************************/
18 | #ifdef JEMALLOC_H_INLINES
19 |
20 | #endif /* JEMALLOC_H_INLINES */
21 | /******************************************************************************/
22 |
--------------------------------------------------------------------------------
/graph_tests/common_neighbours_spec.rb:
--------------------------------------------------------------------------------
1 | # edges exists
2 |
3 | require 'redis'
4 |
5 | redis = Redis.new
6 |
7 | describe 'Common neighbours' do
8 |
9 | it 'should correctly find the common neighbours between two nodes' do
10 | redis.flushdb
11 | redis.gnode 'graph1', 'a', 'b', 'c', 'd', 'e', 'f'
12 | redis.gedge 'graph1', 'a', 'c', 1
13 | redis.gedge 'graph1', 'b', 'c', 1
14 | redis.gedge 'graph1', 'a', 'd', 1
15 | redis.gedge 'graph1', 'b', 'd', 1
16 | redis.gedge 'graph1', 'b', 'e', 1
17 |
18 | common_nodes = redis.gcommon('graph1', 'a', 'b')
19 | common_nodes.length.should eq 2
20 | common_nodes.include?('c').should eq true
21 | common_nodes.include?('d').should eq true
22 | common_nodes.include?('e').should eq false
23 |
24 | common_nodes = redis.gcommon('graph1', 'a', 'f')
25 | common_nodes.empty?.should eq true
26 | end
27 |
28 | end
29 |
30 |
--------------------------------------------------------------------------------
/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/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 | {
7 | LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
8 | *thd = CreateThread(NULL, 0, routine, arg, 0, NULL);
9 | if (*thd == NULL)
10 | test_fail("Error in CreateThread()\n");
11 | }
12 |
13 | void
14 | thd_join(thd_t thd, void **ret)
15 | {
16 |
17 | if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) {
18 | DWORD exit_code;
19 | GetExitCodeThread(thd, (LPDWORD) &exit_code);
20 | *ret = (void *)(uintptr_t)exit_code;
21 | }
22 | }
23 |
24 | #else
25 | void
26 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
27 | {
28 |
29 | if (pthread_create(thd, NULL, proc, arg) != 0)
30 | test_fail("Error in pthread_create()\n");
31 | }
32 |
33 | void
34 | thd_join(thd_t thd, void **ret)
35 | {
36 |
37 | pthread_join(thd, ret);
38 | }
39 | #endif
40 |
--------------------------------------------------------------------------------
/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/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/jemalloc/include/jemalloc/internal/base.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
3 |
4 | #endif /* JEMALLOC_H_TYPES */
5 | /******************************************************************************/
6 | #ifdef JEMALLOC_H_STRUCTS
7 |
8 | #endif /* JEMALLOC_H_STRUCTS */
9 | /******************************************************************************/
10 | #ifdef JEMALLOC_H_EXTERNS
11 |
12 | void *base_alloc(size_t size);
13 | void base_stats_get(size_t *allocated, size_t *resident, size_t *mapped);
14 | bool base_boot(void);
15 | void base_prefork(void);
16 | void base_postfork_parent(void);
17 | void base_postfork_child(void);
18 |
19 | #endif /* JEMALLOC_H_EXTERNS */
20 | /******************************************************************************/
21 | #ifdef JEMALLOC_H_INLINES
22 |
23 | #endif /* JEMALLOC_H_INLINES */
24 | /******************************************************************************/
25 |
--------------------------------------------------------------------------------
/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 | { \
13 | void *p; \
14 | \
15 | if (bits == 0) \
16 | p = mallocx(size, 0); \
17 | else { \
18 | switch (bits & 0x1U) { \
19 | case 0: \
20 | p = (btalloc_0(size, bits >> 1)); \
21 | break; \
22 | case 1: \
23 | p = (btalloc_1(size, bits >> 1)); \
24 | break; \
25 | default: not_reached(); \
26 | } \
27 | } \
28 | /* Intentionally sabotage tail call optimization. */ \
29 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); \
30 | return (p); \
31 | }
32 |
--------------------------------------------------------------------------------
/graph_tests/max_neighbour_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'max_neighbour' do
6 | before do
7 | redis.flushdb
8 | redis.gnode 'graph1', 'a', 'b', 'c', 'd', 'e'
9 | redis.gedge 'graph1', 'a', 'b', 2
10 | redis.gedge 'graph1', 'a', 'c', 1
11 | redis.gedge 'graph1', 'a', 'd', 3
12 |
13 | redis.gedge 'graph1', 'd', 'c', 1
14 | end
15 |
16 | it "should return 0 for isolated node" do
17 | value = redis.gmaxneighbour('graph1', 'e')
18 | expect(value).to eq(0)
19 | end
20 |
21 | it "should return the correct value for multi neighbour" do
22 | arr = redis.gmaxneighbour('graph1', 'a')
23 | expect(arr).to eq(['d', 3])
24 | redis.gedge 'graph1', 'a', 'c', 20
25 | arr = redis.gmaxneighbour('graph1', 'a')
26 | expect(arr).to eq(['c', 20])
27 | end
28 |
29 | it "should return the correct value for single neighbour" do
30 | arr = redis.gmaxneighbour('graph1', 'b')
31 | expect(arr).to eq(['a', 2])
32 | end
33 | end
34 |
--------------------------------------------------------------------------------
/graph_tests/minimum_spanning_tree_2_spec.rb:
--------------------------------------------------------------------------------
1 | # Directed Graphs
2 |
3 | require 'redis'
4 |
5 | redis = Redis.new
6 |
7 | describe 'Minimum spanning tree' do
8 | it 'should calculate the correct minimum spanning tree' do
9 | redis.flushdb
10 | redis.gnode 'graph1', 'a', 'b', 'c', 'd'
11 | redis.gsetdirected 'graph1'
12 | redis.gedge 'graph1', 'a', 'b', 1
13 | redis.gedge 'graph1', 'b', 'a', 4
14 | redis.gedge 'graph1', 'b', 'c', 2
15 | redis.gedge 'graph1', 'c', 'b', 3
16 | redis.gedge 'graph1', 'c', 'd', 3
17 |
18 | path1 = redis.gshortestpath 'graph1', 'a', 'c'
19 | path2 = redis.gshortestpath 'graph1', 'c', 'a'
20 | path3 = redis.gshortestpath 'graph1', 'a', 'd'
21 | path1.last.should eq '3'
22 | path2.last.should eq '7'
23 | path3.last.should eq '6'
24 |
25 | redis.gneighbours('graph1', 'c').should eq ['b', 'd']
26 | redis.gneighbours('graph1', 'd').should eq []
27 | redis.gincoming('graph1', 'd').should eq ['c']
28 | end
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/deps/lua/doc/readme.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Lua documentation
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
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/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/pages.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
3 |
4 | #endif /* JEMALLOC_H_TYPES */
5 | /******************************************************************************/
6 | #ifdef JEMALLOC_H_STRUCTS
7 |
8 | #endif /* JEMALLOC_H_STRUCTS */
9 | /******************************************************************************/
10 | #ifdef JEMALLOC_H_EXTERNS
11 |
12 | void *pages_map(void *addr, size_t size);
13 | void pages_unmap(void *addr, size_t size);
14 | void *pages_trim(void *addr, size_t alloc_size, size_t leadsize,
15 | size_t size);
16 | bool pages_commit(void *addr, size_t size);
17 | bool pages_decommit(void *addr, size_t size);
18 | bool pages_purge(void *addr, size_t size);
19 |
20 | #endif /* JEMALLOC_H_EXTERNS */
21 | /******************************************************************************/
22 | #ifdef JEMALLOC_H_INLINES
23 |
24 | #endif /* JEMALLOC_H_INLINES */
25 | /******************************************************************************/
26 |
27 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/graph_tests/directed_graph_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'basic commands' do
6 | before do
7 | redis.flushdb
8 | redis.gnode 'graph1', 'a', 'b', 'c', 'd'
9 | redis.gsetdirected 'graph1'
10 | redis.gedge 'graph1', 'a', 'b', 2
11 | redis.gedge 'graph1', 'a', 'c', 1
12 | redis.gedge 'graph1', 'd', 'b', 1
13 | end
14 |
15 | it "should calculate the outdegree correctly" do
16 | a = redis.gnodeoutdegree 'graph1', 'a'
17 | expect(a).to eq(2)
18 | b = redis.gnodeoutdegree 'graph1', 'b'
19 | expect(b).to eq(0)
20 | d = redis.gnodeoutdegree 'graph1', 'd'
21 | expect(d).to eq(1)
22 | e = redis.gnodeoutdegree 'graph1', 'e'
23 | expect(e).to eq(nil)
24 | end
25 |
26 | it "should calculate the indegree correctly" do
27 | a = redis.gnodeindegree 'graph1', 'a'
28 | expect(a).to eq(0)
29 | b = redis.gnodeindegree 'graph1', 'b'
30 | expect(b).to eq(2)
31 | d = redis.gnodeindegree 'graph1', 'd'
32 | expect(d).to eq(0)
33 | e = redis.gnodeindegree 'graph1', 'e'
34 | expect(e).to eq(nil)
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/graph_tests/shortest_distance_2_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'shortest path' do
6 | before do
7 | redis.flushdb
8 | redis.gnode 'graph1', *(%w(a b c d e f g))
9 | redis.gedge 'graph1', 'a', 'c', 1
10 | redis.gedge 'graph1', 'a', 'b', 2
11 | redis.gedge 'graph1', 'b', 'c', 3
12 | redis.gedge 'graph1', 'e', 'c', 5
13 | redis.gedge 'graph1', 'd', 'c', 3
14 | redis.gedge 'graph1', 'd', 'f', 1
15 | redis.gedge 'graph1', 'e', 'f', 4
16 | redis.gedge 'graph1', 'g', 'f', 9
17 | redis.gedge 'graph1', 'a', 'g', 15
18 |
19 | @result = redis.gshortestpath('graph1', 'a', 'g')
20 | end
21 |
22 | it 'should make the path from a to g = 14' do
23 | @result.last.should eq "14"
24 | end
25 |
26 | it 'should have the right order of the path' do
27 | @result[0].should eq 'a'
28 | @result[1].should eq 'c'
29 | @result[2].should eq 'd'
30 | @result[3].should eq 'f'
31 | @result[4].should eq 'g'
32 | end
33 |
34 | it 'should print the correct nodes' do
35 | nodes = redis.gnodes('graph1', '*')
36 | nodes.should eq %w(a b c d e f g)
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/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
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 | testmodule.xo: ../redismodule.h
37 |
38 | testmodule.so: testmodule.xo
39 | $(LD) -o $@ $< $(SHOBJ_LDFLAGS) $(LIBS) -lc
40 |
41 | clean:
42 | rm -rf *.xo *.so
43 |
--------------------------------------------------------------------------------
/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, Valgrind integration, and extensive monitoring/tuning
7 | hooks. Modern jemalloc releases continue to be integrated back into FreeBSD,
8 | and therefore versatility remains critical. Ongoing development efforts trend
9 | toward making jemalloc among the best allocators for a broad range of demanding
10 | applications, and eliminating/mitigating weaknesses that have practical
11 | repercussions for real 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://www.canonware.com/jemalloc/
21 |
--------------------------------------------------------------------------------
/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/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~30..$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 |
--------------------------------------------------------------------------------
/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 | /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
37 | #undef LG_SIZEOF_PTR
38 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/unit/prof_idump.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | #ifdef JEMALLOC_PROF
4 | const char *malloc_conf =
5 | "prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,"
6 | "lg_prof_interval:0";
7 | #endif
8 |
9 | static bool did_prof_dump_open;
10 |
11 | static int
12 | prof_dump_open_intercept(bool propagate_err, const char *filename)
13 | {
14 | int fd;
15 |
16 | did_prof_dump_open = true;
17 |
18 | fd = open("/dev/null", O_WRONLY);
19 | assert_d_ne(fd, -1, "Unexpected open() failure");
20 |
21 | return (fd);
22 | }
23 |
24 | TEST_BEGIN(test_idump)
25 | {
26 | bool active;
27 | void *p;
28 |
29 | test_skip_if(!config_prof);
30 |
31 | active = true;
32 | assert_d_eq(mallctl("prof.active", NULL, NULL, &active, sizeof(active)),
33 | 0, "Unexpected mallctl failure while activating profiling");
34 |
35 | prof_dump_open = prof_dump_open_intercept;
36 |
37 | did_prof_dump_open = false;
38 | p = mallocx(1, 0);
39 | assert_ptr_not_null(p, "Unexpected mallocx() failure");
40 | dallocx(p, 0);
41 | assert_true(did_prof_dump_open, "Expected a profile dump");
42 | }
43 | TEST_END
44 |
45 | int
46 | main(void)
47 | {
48 |
49 | return (test(
50 | test_idump));
51 | }
52 |
--------------------------------------------------------------------------------
/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/jemalloc/test/test.sh.in:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | case @abi@ in
4 | macho)
5 | export DYLD_FALLBACK_LIBRARY_PATH="@objroot@lib"
6 | ;;
7 | pecoff)
8 | export PATH="${PATH}:@objroot@lib"
9 | ;;
10 | *)
11 | ;;
12 | esac
13 |
14 | # Corresponds to test_status_t.
15 | pass_code=0
16 | skip_code=1
17 | fail_code=2
18 |
19 | pass_count=0
20 | skip_count=0
21 | fail_count=0
22 | for t in $@; do
23 | if [ $pass_count -ne 0 -o $skip_count -ne 0 -o $fail_count != 0 ] ; then
24 | echo
25 | fi
26 | echo "=== ${t} ==="
27 | ${t}@exe@ @abs_srcroot@ @abs_objroot@
28 | result_code=$?
29 | case ${result_code} in
30 | ${pass_code})
31 | pass_count=$((pass_count+1))
32 | ;;
33 | ${skip_code})
34 | skip_count=$((skip_count+1))
35 | ;;
36 | ${fail_code})
37 | fail_count=$((fail_count+1))
38 | ;;
39 | *)
40 | echo "Test harness error" 1>&2
41 | exit 1
42 | esac
43 | done
44 |
45 | total_count=`expr ${pass_count} + ${skip_count} + ${fail_count}`
46 | echo
47 | echo "Test suite summary: pass: ${pass_count}/${total_count}, skip: ${skip_count}/${total_count}, fail: ${fail_count}/${total_count}"
48 |
49 | if [ ${fail_count} -eq 0 ] ; then
50 | exit 0
51 | else
52 | exit 1
53 | fi
54 |
--------------------------------------------------------------------------------
/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/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/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 |
--------------------------------------------------------------------------------
/tests/unit/memefficiency.tcl:
--------------------------------------------------------------------------------
1 | proc test_memory_efficiency {range} {
2 | r flushall
3 | set rd [redis_deferring_client]
4 | set base_mem [s used_memory]
5 | set written 0
6 | for {set j 0} {$j < 10000} {incr j} {
7 | set key key:$j
8 | set val [string repeat A [expr {int(rand()*$range)}]]
9 | $rd set $key $val
10 | incr written [string length $key]
11 | incr written [string length $val]
12 | incr written 2 ;# A separator is the minimum to store key-value data.
13 | }
14 | for {set j 0} {$j < 10000} {incr j} {
15 | $rd read ; # Discard replies
16 | }
17 |
18 | set current_mem [s used_memory]
19 | set used [expr {$current_mem-$base_mem}]
20 | set efficiency [expr {double($written)/$used}]
21 | return $efficiency
22 | }
23 |
24 | start_server {tags {"memefficiency"}} {
25 | foreach {size_range expected_min_efficiency} {
26 | 32 0.15
27 | 64 0.25
28 | 128 0.35
29 | 1024 0.75
30 | 16384 0.82
31 | } {
32 | test "Memory efficiency with values in range $size_range" {
33 | set efficiency [test_memory_efficiency $size_range]
34 | assert {$efficiency >= $expected_min_efficiency}
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/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 | {
8 | mtx_t mtx;
9 |
10 | assert_false(mtx_init(&mtx), "Unexpected mtx_init() failure");
11 | mtx_lock(&mtx);
12 | mtx_unlock(&mtx);
13 | mtx_fini(&mtx);
14 | }
15 | TEST_END
16 |
17 | typedef struct {
18 | mtx_t mtx;
19 | unsigned x;
20 | } thd_start_arg_t;
21 |
22 | static void *
23 | thd_start(void *varg)
24 | {
25 | thd_start_arg_t *arg = (thd_start_arg_t *)varg;
26 | unsigned i;
27 |
28 | for (i = 0; i < NINCRS; i++) {
29 | mtx_lock(&arg->mtx);
30 | arg->x++;
31 | mtx_unlock(&arg->mtx);
32 | }
33 | return (NULL);
34 | }
35 |
36 | TEST_BEGIN(test_mtx_race)
37 | {
38 | thd_start_arg_t arg;
39 | thd_t thds[NTHREADS];
40 | unsigned i;
41 |
42 | assert_false(mtx_init(&arg.mtx), "Unexpected mtx_init() failure");
43 | arg.x = 0;
44 | for (i = 0; i < NTHREADS; i++)
45 | thd_create(&thds[i], thd_start, (void *)&arg);
46 | for (i = 0; i < NTHREADS; i++)
47 | thd_join(thds[i], NULL);
48 | assert_u_eq(arg.x, NTHREADS * NINCRS,
49 | "Race-related counter corruption");
50 | }
51 | TEST_END
52 |
53 | int
54 | main(void)
55 | {
56 |
57 | return (test(
58 | test_mtx_basic,
59 | test_mtx_race));
60 | }
61 |
--------------------------------------------------------------------------------
/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 | REDISPORT=6379
7 | EXEC=/usr/local/bin/redis-server
8 | CLIEXEC=/usr/local/bin/redis-cli
9 |
10 | PIDFILE=/var/run/redis_${REDISPORT}.pid
11 | CONF="/etc/redis/${REDISPORT}.conf"
12 |
13 | case "$1" in
14 | start)
15 | if [ -f $PIDFILE ]
16 | then
17 | echo "$PIDFILE exists, process is already running or crashed"
18 | else
19 | echo "Starting Redis server..."
20 | $EXEC $CONF
21 | fi
22 | ;;
23 | stop)
24 | if [ ! -f $PIDFILE ]
25 | then
26 | echo "$PIDFILE does not exist, process is not running"
27 | else
28 | PID=$(cat $PIDFILE)
29 | echo "Stopping ..."
30 | $CLIEXEC -p $REDISPORT shutdown
31 | while [ -x /proc/${PID} ]
32 | do
33 | echo "Waiting for Redis to shutdown ..."
34 | sleep 1
35 | done
36 | echo "Redis stopped"
37 | fi
38 | ;;
39 | *)
40 | echo "Please use start or stop as first argument"
41 | ;;
42 | esac
43 |
--------------------------------------------------------------------------------
/graph_tests/errors_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'wrong type' do
6 | before do
7 | redis.flushdb
8 | end
9 |
10 | it "should return error while adding node to non-graph key" do
11 | redis.set("graph1", "value1")
12 | ret = redis.type('graph1')
13 | expect(ret).to eq('string')
14 | expect do
15 | redis.gnode("graph1", "v1")
16 | end.to raise_exception(Redis::CommandError, /WRONGTYPE/)
17 | end
18 |
19 | it "should return error while adding an edge to null key" do
20 | expect do
21 | redis.gedge("graph1", "v1", "v2", 10)
22 | end.to raise_exception(Redis::CommandError, /WRONGTYPE/)
23 | end
24 |
25 | it "should return error while adding an edge to non-graph key" do
26 | redis.set("graph1", "value1")
27 | ret = redis.type('graph1')
28 | expect(ret).to eq('string')
29 | expect do
30 | redis.gedge("graph1", "v1", "v2", 10)
31 | end.to raise_exception(Redis::CommandError, /WRONGTYPE/)
32 | end
33 |
34 | it "should return of graph shortest distance asks for nodes that don't exist" do
35 | redis.gnode "graph1", "a"
36 | expect do
37 | path = redis.gshortestpath "graph1", "a", "b"
38 | end.to raise_exception(Redis::CommandError, /Node not found/)
39 | end
40 | end
41 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/integration/sdallocx.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | #define MAXALIGN (((size_t)1) << 25)
4 | #define NITER 4
5 |
6 | TEST_BEGIN(test_basic)
7 | {
8 | void *ptr = mallocx(64, 0);
9 | sdallocx(ptr, 64, 0);
10 | }
11 | TEST_END
12 |
13 | TEST_BEGIN(test_alignment_and_size)
14 | {
15 | size_t nsz, sz, alignment, total;
16 | unsigned i;
17 | void *ps[NITER];
18 |
19 | for (i = 0; i < NITER; i++)
20 | ps[i] = NULL;
21 |
22 | for (alignment = 8;
23 | alignment <= MAXALIGN;
24 | alignment <<= 1) {
25 | total = 0;
26 | for (sz = 1;
27 | sz < 3 * alignment && sz < (1U << 31);
28 | sz += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
29 | for (i = 0; i < NITER; i++) {
30 | nsz = nallocx(sz, MALLOCX_ALIGN(alignment) |
31 | MALLOCX_ZERO);
32 | ps[i] = mallocx(sz, MALLOCX_ALIGN(alignment) |
33 | MALLOCX_ZERO);
34 | total += nsz;
35 | if (total >= (MAXALIGN << 1))
36 | break;
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 | {
53 |
54 | return (test(
55 | test_basic,
56 | test_alignment_and_size));
57 | }
58 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/graph_tests/edge_incr_by_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'edge increment by' do
6 | before do
7 | redis.flushdb
8 | end
9 |
10 | it "should by able to increment an existing edge" do
11 | ret = redis.gnode 'graph', 'a', 'b', 'c'
12 | ret = redis.gedge 'graph', 'a', 'b', 0
13 | expect(ret).to eq("0")
14 | ret = redis.gedgeexists 'graph', 'a', 'b'
15 | expect(ret).to eq(1)
16 | ret = redis.gedge 'graph', 'a', 'b', 0
17 | expect(ret).to eq("0")
18 | ret = redis.gedgeincrby 'graph', 'a', 'b', 2
19 | expect(ret).to eq("2")
20 | ret = redis.gedgeincrby 'graph', 'a', 'b', 3.1
21 | expect(ret).to eq("5.0999999999999996")
22 | ret = redis.gedgevalue 'graph', 'a', 'b'
23 | expect(ret).to eq("5.0999999999999996")
24 | end
25 |
26 | it "should create the edge with that value if it doesnt exist" do
27 | ret = redis.gnode 'graph', 'a', 'b', 'c'
28 | ret = redis.gedgeexists 'graph', 'a', 'b'
29 | expect(ret).to eq(0)
30 | ret = redis.gedgeincrby 'graph', 'a', 'b', 3
31 | expect(ret).to eq("3")
32 | ret = redis.gedgevalue 'graph', 'a', 'b'
33 | expect(ret).to eq("3")
34 | end
35 |
36 | it "should return the new edge value as float when created" do
37 | redis.gnode 'graph', 'a', 'b', 'c'
38 | ret = redis.gedge 'graph', 'a', 'b', 1.2
39 | expect(ret).to eq("1.2")
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/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/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 | {
10 |
11 | #ifdef _WIN32
12 | if (!InitializeCriticalSectionAndSpinCount(&mtx->lock, _CRT_SPINCOUNT))
13 | return (true);
14 | #elif (defined(JEMALLOC_OSSPIN))
15 | mtx->lock = 0;
16 | #else
17 | pthread_mutexattr_t attr;
18 |
19 | if (pthread_mutexattr_init(&attr) != 0)
20 | return (true);
21 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
22 | if (pthread_mutex_init(&mtx->lock, &attr) != 0) {
23 | pthread_mutexattr_destroy(&attr);
24 | return (true);
25 | }
26 | pthread_mutexattr_destroy(&attr);
27 | #endif
28 | return (false);
29 | }
30 |
31 | void
32 | mtx_fini(mtx_t *mtx)
33 | {
34 |
35 | #ifdef _WIN32
36 | #elif (defined(JEMALLOC_OSSPIN))
37 | #else
38 | pthread_mutex_destroy(&mtx->lock);
39 | #endif
40 | }
41 |
42 | void
43 | mtx_lock(mtx_t *mtx)
44 | {
45 |
46 | #ifdef _WIN32
47 | EnterCriticalSection(&mtx->lock);
48 | #elif (defined(JEMALLOC_OSSPIN))
49 | OSSpinLockLock(&mtx->lock);
50 | #else
51 | pthread_mutex_lock(&mtx->lock);
52 | #endif
53 | }
54 |
55 | void
56 | mtx_unlock(mtx_t *mtx)
57 | {
58 |
59 | #ifdef _WIN32
60 | LeaveCriticalSection(&mtx->lock);
61 | #elif (defined(JEMALLOC_OSSPIN))
62 | OSSpinLockUnlock(&mtx->lock);
63 | #else
64 | pthread_mutex_unlock(&mtx->lock);
65 | #endif
66 | }
67 |
--------------------------------------------------------------------------------
/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 give 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 this 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-trib 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 "./craete-cluster stop" to stop all the instances. After you stopped the instances you can use "./create-cluster start" to restart them if you change ideas.
25 | 2. Use "./create-cluster clean" to remove all the AOF / log files to restat with a clean environment.
26 |
27 | Use the command "./create-cluster help" to get the full list of features.
28 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/modules/gendoc.rb:
--------------------------------------------------------------------------------
1 | # gendoc.rb -- Converts the top-comments inside module.c to modules API
2 | # reference documentaiton 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 | if s[0] != ' '
10 | s = s.gsub(/RM_[A-z()]+/){|x| "`#{x}`"}
11 | s = s.gsub(/RedisModule_[A-z()]+/){|x| "`#{x}`"}
12 | s = s.gsub(/REDISMODULE_[A-z]+/){|x| "`#{x}`"}
13 | end
14 | s.chop! while s[-1] == "\n" || s[-1] == " "
15 | return s
16 | end
17 |
18 | # Given the source code array and the index at which an exported symbol was
19 | # detected, extracts and outputs the documentation.
20 | def docufy(src,i)
21 | m = /RM_[A-z0-9]+/.match(src[i])
22 | proto = src[i].sub("{","").strip+";\n"
23 | puts "## `#{m[0]}`\n\n"
24 | puts " #{proto}\n"
25 | comment = ""
26 | while true
27 | i = i-1
28 | comment = src[i]+comment
29 | break if src[i] =~ /\/\*/
30 | end
31 | comment = markdown(comment)
32 | puts comment+"\n\n"
33 | end
34 |
35 | puts "# Modules API reference\n\n"
36 | src = File.open("../module.c").to_a
37 | src.each_with_index{|line,i|
38 | if line =~ /RM_/ && line[0] != ' ' && line[0] != '#' && line[0] != '/'
39 | if src[i-1] =~ /\*\//
40 | docufy(src,i)
41 | end
42 | end
43 | }
44 |
--------------------------------------------------------------------------------
/tests/integration/aof-race.tcl:
--------------------------------------------------------------------------------
1 | set defaults { appendonly {yes} appendfilename {appendonly.aof} }
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 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/chunk_dss.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
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 | #endif /* JEMALLOC_H_TYPES */
15 | /******************************************************************************/
16 | #ifdef JEMALLOC_H_STRUCTS
17 |
18 | extern const char *dss_prec_names[];
19 |
20 | #endif /* JEMALLOC_H_STRUCTS */
21 | /******************************************************************************/
22 | #ifdef JEMALLOC_H_EXTERNS
23 |
24 | dss_prec_t chunk_dss_prec_get(void);
25 | bool chunk_dss_prec_set(dss_prec_t dss_prec);
26 | void *chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size,
27 | size_t alignment, bool *zero, bool *commit);
28 | bool chunk_in_dss(void *chunk);
29 | bool chunk_dss_boot(void);
30 | void chunk_dss_prefork(void);
31 | void chunk_dss_postfork_parent(void);
32 | void chunk_dss_postfork_child(void);
33 |
34 | #endif /* JEMALLOC_H_EXTERNS */
35 | /******************************************************************************/
36 | #ifdef JEMALLOC_H_INLINES
37 |
38 | #endif /* JEMALLOC_H_INLINES */
39 | /******************************************************************************/
40 |
--------------------------------------------------------------------------------
/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 received 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 received failover info"
34 | }
35 | }
36 |
37 | test "New master [join $addr {:}] role matches" {
38 | assert {[RI $master_id role] eq {master}}
39 | }
40 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/jemalloc_mangle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
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 |
--------------------------------------------------------------------------------
/graph_tests/removing_edges_spec.rb:
--------------------------------------------------------------------------------
1 | # Deleting edges
2 |
3 | require 'redis'
4 |
5 | redis = Redis.new
6 |
7 | describe 'Removing edges' do
8 |
9 | it 'should correctly remove edges from undirected graphs' do
10 | redis.flushdb
11 | redis.gnode 'graph1', 'a', 'b', 'c', 'd'
12 | redis.gedge 'graph1', 'a', 'b', 1
13 | redis.gedge 'graph1', 'b', 'c', 1
14 | redis.gedge 'graph1', 'c', 'd', 1
15 | redis.gedge 'graph1', 'a', 'd', 2
16 | redis.gedgerem 'graph1', 'a', 'd'
17 | path = redis.gshortestpath 'graph1', 'a', 'd'
18 | path.last.should eq '3'
19 | path = redis.gshortestpath 'graph1', 'd', 'a'
20 | path.last.should eq '3'
21 | edges = redis.gedges 'graph1'
22 | edges.length.should eq (3 * 3)
23 | end
24 |
25 | it 'should correctly remove edges from directed graphs' do
26 | redis.flushdb
27 | redis.gnode 'graph1', 'a', 'b', 'c', 'd'
28 | redis.gsetdirected 'graph1'
29 | redis.gedge 'graph1', 'a', 'b', 1
30 | redis.gedge 'graph1', 'c', 'b', 1
31 | redis.gedge 'graph1', 'c', 'd', 1
32 | redis.gedge 'graph1', 'd', 'b', 1
33 | redis.gedge 'graph1', 'b', 'c', 1
34 | incoming = redis.gincoming 'graph1', 'b'
35 | incoming.length.should eq 3
36 | redis.gedgerem('graph1', 'a', 'c').should eq 0
37 | redis.gedgerem('graph1', 'c', 'b').should eq 1
38 | incoming = redis.gincoming 'graph1', 'b'
39 | incoming.length.should eq 2
40 |
41 | path = redis.gshortestpath 'graph1', 'c', 'b'
42 | path.last.should eq '2'
43 | end
44 |
45 | end
46 |
47 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/integration/overflow.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | TEST_BEGIN(test_overflow)
4 | {
5 | unsigned nhchunks;
6 | size_t mib[4];
7 | size_t sz, miblen, max_size_class;
8 | void *p;
9 |
10 | sz = sizeof(unsigned);
11 | assert_d_eq(mallctl("arenas.nhchunks", &nhchunks, &sz, NULL, 0), 0,
12 | "Unexpected mallctl() error");
13 |
14 | miblen = sizeof(mib) / sizeof(size_t);
15 | assert_d_eq(mallctlnametomib("arenas.hchunk.0.size", mib, &miblen), 0,
16 | "Unexpected mallctlnametomib() error");
17 | mib[2] = nhchunks - 1;
18 |
19 | sz = sizeof(size_t);
20 | assert_d_eq(mallctlbymib(mib, miblen, &max_size_class, &sz, NULL, 0), 0,
21 | "Unexpected mallctlbymib() error");
22 |
23 | assert_ptr_null(malloc(max_size_class + 1),
24 | "Expected OOM due to over-sized allocation request");
25 | assert_ptr_null(malloc(SIZE_T_MAX),
26 | "Expected OOM due to over-sized allocation request");
27 |
28 | assert_ptr_null(calloc(1, max_size_class + 1),
29 | "Expected OOM due to over-sized allocation request");
30 | assert_ptr_null(calloc(1, SIZE_T_MAX),
31 | "Expected OOM due to over-sized allocation request");
32 |
33 | p = malloc(1);
34 | assert_ptr_not_null(p, "Unexpected malloc() OOM");
35 | assert_ptr_null(realloc(p, max_size_class + 1),
36 | "Expected OOM due to over-sized allocation request");
37 | assert_ptr_null(realloc(p, SIZE_T_MAX),
38 | "Expected OOM due to over-sized allocation request");
39 | free(p);
40 | }
41 | TEST_END
42 |
43 | int
44 | main(void)
45 | {
46 |
47 | return (test(
48 | test_overflow));
49 | }
50 |
--------------------------------------------------------------------------------
/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 received 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 |
--------------------------------------------------------------------------------
/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/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/jemalloc/include/jemalloc/internal/huge.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
3 |
4 | #endif /* JEMALLOC_H_TYPES */
5 | /******************************************************************************/
6 | #ifdef JEMALLOC_H_STRUCTS
7 |
8 | #endif /* JEMALLOC_H_STRUCTS */
9 | /******************************************************************************/
10 | #ifdef JEMALLOC_H_EXTERNS
11 |
12 | void *huge_malloc(tsd_t *tsd, arena_t *arena, size_t size, bool zero,
13 | tcache_t *tcache);
14 | void *huge_palloc(tsd_t *tsd, arena_t *arena, size_t size, size_t alignment,
15 | bool zero, tcache_t *tcache);
16 | bool huge_ralloc_no_move(void *ptr, size_t oldsize, size_t usize_min,
17 | size_t usize_max, bool zero);
18 | void *huge_ralloc(tsd_t *tsd, arena_t *arena, void *ptr, size_t oldsize,
19 | size_t usize, size_t alignment, bool zero, tcache_t *tcache);
20 | #ifdef JEMALLOC_JET
21 | typedef void (huge_dalloc_junk_t)(void *, size_t);
22 | extern huge_dalloc_junk_t *huge_dalloc_junk;
23 | #endif
24 | void huge_dalloc(tsd_t *tsd, void *ptr, tcache_t *tcache);
25 | arena_t *huge_aalloc(const void *ptr);
26 | size_t huge_salloc(const void *ptr);
27 | prof_tctx_t *huge_prof_tctx_get(const void *ptr);
28 | void huge_prof_tctx_set(const void *ptr, prof_tctx_t *tctx);
29 | void huge_prof_tctx_reset(const void *ptr);
30 |
31 | #endif /* JEMALLOC_H_EXTERNS */
32 | /******************************************************************************/
33 | #ifdef JEMALLOC_H_INLINES
34 |
35 | #endif /* JEMALLOC_H_INLINES */
36 | /******************************************************************************/
37 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/jemalloc_internal_decls.h:
--------------------------------------------------------------------------------
1 | #ifndef JEMALLOC_INTERNAL_DECLS_H
2 | #define JEMALLOC_INTERNAL_DECLS_H
3 |
4 | #include
5 | #ifdef _WIN32
6 | # include
7 | # include "msvc_compat/windows_extra.h"
8 |
9 | #else
10 | # include
11 | # include
12 | # if !defined(__pnacl__) && !defined(__native_client__)
13 | # include
14 | # if !defined(SYS_write) && defined(__NR_write)
15 | # define SYS_write __NR_write
16 | # endif
17 | # include
18 | # endif
19 | # include
20 | # include
21 | #endif
22 | #include
23 |
24 | #include
25 | #ifndef SIZE_T_MAX
26 | # define SIZE_T_MAX SIZE_MAX
27 | #endif
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #ifndef offsetof
35 | # define offsetof(type, member) ((size_t)&(((type *)NULL)->member))
36 | #endif
37 | #include
38 | #include
39 | #include
40 | #ifdef _MSC_VER
41 | # include
42 | typedef intptr_t ssize_t;
43 | # define PATH_MAX 1024
44 | # define STDERR_FILENO 2
45 | # define __func__ __FUNCTION__
46 | # ifdef JEMALLOC_HAS_RESTRICT
47 | # define restrict __restrict
48 | # endif
49 | /* Disable warnings about deprecated system functions. */
50 | # pragma warning(disable: 4996)
51 | #if _MSC_VER < 1800
52 | static int
53 | isblank(int c)
54 | {
55 |
56 | return (c == '\t' || c == ' ');
57 | }
58 | #endif
59 | #else
60 | # include
61 | #endif
62 | #include
63 |
64 | #endif /* JEMALLOC_INTERNAL_H */
65 |
--------------------------------------------------------------------------------
/deps/lua/doc/lua.css:
--------------------------------------------------------------------------------
1 | body {
2 | color: #000000 ;
3 | background-color: #FFFFFF ;
4 | font-family: Helvetica, Arial, sans-serif ;
5 | text-align: justify ;
6 | margin-right: 30px ;
7 | margin-left: 30px ;
8 | }
9 |
10 | h1, h2, h3, h4 {
11 | font-family: Verdana, Geneva, sans-serif ;
12 | font-weight: normal ;
13 | font-style: italic ;
14 | }
15 |
16 | h2 {
17 | padding-top: 0.4em ;
18 | padding-bottom: 0.4em ;
19 | padding-left: 30px ;
20 | padding-right: 30px ;
21 | margin-left: -30px ;
22 | background-color: #E0E0FF ;
23 | }
24 |
25 | h3 {
26 | padding-left: 0.5em ;
27 | border-left: solid #E0E0FF 1em ;
28 | }
29 |
30 | table h3 {
31 | padding-left: 0px ;
32 | border-left: none ;
33 | }
34 |
35 | a:link {
36 | color: #000080 ;
37 | background-color: inherit ;
38 | text-decoration: none ;
39 | }
40 |
41 | a:visited {
42 | background-color: inherit ;
43 | text-decoration: none ;
44 | }
45 |
46 | a:link:hover, a:visited:hover {
47 | color: #000080 ;
48 | background-color: #E0E0FF ;
49 | }
50 |
51 | a:link:active, a:visited:active {
52 | color: #FF0000 ;
53 | }
54 |
55 | hr {
56 | border: 0 ;
57 | height: 1px ;
58 | color: #a0a0a0 ;
59 | background-color: #a0a0a0 ;
60 | }
61 |
62 | :target {
63 | background-color: #F8F8F8 ;
64 | padding: 8px ;
65 | border: solid #a0a0a0 2px ;
66 | }
67 |
68 | .footer {
69 | color: gray ;
70 | font-size: small ;
71 | }
72 |
73 | input[type=text] {
74 | border: solid #a0a0a0 2px ;
75 | border-radius: 2em ;
76 | -moz-border-radius: 2em ;
77 | background-image: url('images/search.png') ;
78 | background-repeat: no-repeat;
79 | background-position: 4px center ;
80 | padding-left: 20px ;
81 | height: 2em ;
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/deps/hiredis/examples/example-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/src/extent.c:
--------------------------------------------------------------------------------
1 | #define JEMALLOC_EXTENT_C_
2 | #include "jemalloc/internal/jemalloc_internal.h"
3 |
4 | /******************************************************************************/
5 |
6 | JEMALLOC_INLINE_C size_t
7 | extent_quantize(size_t size)
8 | {
9 |
10 | /*
11 | * Round down to the nearest chunk size that can actually be requested
12 | * during normal huge allocation.
13 | */
14 | return (index2size(size2index(size + 1) - 1));
15 | }
16 |
17 | JEMALLOC_INLINE_C int
18 | extent_szad_comp(extent_node_t *a, extent_node_t *b)
19 | {
20 | int ret;
21 | size_t a_qsize = extent_quantize(extent_node_size_get(a));
22 | size_t b_qsize = extent_quantize(extent_node_size_get(b));
23 |
24 | /*
25 | * Compare based on quantized size rather than size, in order to sort
26 | * equally useful extents only by address.
27 | */
28 | ret = (a_qsize > b_qsize) - (a_qsize < b_qsize);
29 | if (ret == 0) {
30 | uintptr_t a_addr = (uintptr_t)extent_node_addr_get(a);
31 | uintptr_t b_addr = (uintptr_t)extent_node_addr_get(b);
32 |
33 | ret = (a_addr > b_addr) - (a_addr < b_addr);
34 | }
35 |
36 | return (ret);
37 | }
38 |
39 | /* Generate red-black tree functions. */
40 | rb_gen(, extent_tree_szad_, extent_tree_t, extent_node_t, szad_link,
41 | extent_szad_comp)
42 |
43 | JEMALLOC_INLINE_C int
44 | extent_ad_comp(extent_node_t *a, extent_node_t *b)
45 | {
46 | uintptr_t a_addr = (uintptr_t)extent_node_addr_get(a);
47 | uintptr_t b_addr = (uintptr_t)extent_node_addr_get(b);
48 |
49 | return ((a_addr > b_addr) - (a_addr < b_addr));
50 | }
51 |
52 | /* Generate red-black tree functions. */
53 | rb_gen(, extent_tree_ad_, extent_tree_t, extent_node_t, ad_link, extent_ad_comp)
54 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/graph_tests/removing_nodes_spec.rb:
--------------------------------------------------------------------------------
1 | require 'redis'
2 |
3 | redis = Redis.new
4 |
5 | describe 'Removing nodes' do
6 | it 'should correctly remove nodes from a undirected graph' do
7 | redis.flushdb
8 | redis.gnode 'graph1', 'a', 'b', 'c', 'd'
9 | redis.gedge 'graph1', 'a', 'b', 1
10 | b_neighbours = redis.gneighbours 'graph1', 'b'
11 | expect(b_neighbours).to eq(['a'])
12 | expect((redis.gedges 'graph1').length).to eq(1 * 3)
13 |
14 | response = redis.gnoderem 'graph1', 'a'
15 |
16 | expect(response).to eq(1)
17 | b_neighbours = redis.gneighbours 'graph1', 'b'
18 | expect(b_neighbours).to eq([])
19 |
20 | nodes = redis.gnodes 'graph1', '*'
21 | expect(nodes).to eq(%w[b c d])
22 |
23 | response = redis.gnoderem 'graph1', 'a'
24 | expect(response).to eq(0)
25 |
26 | expect((redis.gedges 'graph1').length).to eq(0 * 3)
27 | end
28 |
29 | it 'should correctly remove edges from directed graphs' do
30 | redis.flushdb
31 | redis.gnode 'graph1', 'a', 'b', 'c', 'd'
32 | redis.gsetdirected 'graph1'
33 | redis.gedge 'graph1', 'b', 'a', 1
34 | b_neighbours = redis.gneighbours 'graph1', 'b'
35 | expect(b_neighbours).to eq(['a'])
36 | expect((redis.gedges 'graph1').length).to eq(1 * 3)
37 |
38 | response = redis.gnoderem 'graph1', 'a'
39 | expect(response).to eq(1)
40 |
41 | b_neighbours = redis.gneighbours 'graph1', 'b'
42 | expect(b_neighbours).to eq([])
43 |
44 | nodes = redis.gnodes 'graph1', '*'
45 | expect(nodes).to eq(%w[b c d])
46 |
47 | response = redis.gnoderem 'graph1', 'a'
48 | expect(response).to eq(0)
49 |
50 | expect((redis.gedges 'graph1').length).to eq(0 * 3)
51 | end
52 | end
53 |
--------------------------------------------------------------------------------
/tests/unit/latency-monitor.tcl:
--------------------------------------------------------------------------------
1 | start_server {tags {"latency-monitor"}} {
2 | # Set a threshold high enough to avoid spurious latency events.
3 | r config set latency-monitor-threshold 200
4 | r latency reset
5 |
6 | test {Test latency events logging} {
7 | r debug sleep 0.3
8 | after 1100
9 | r debug sleep 0.4
10 | after 1100
11 | r debug sleep 0.5
12 | assert {[r latency history command] >= 3}
13 | }
14 |
15 | test {LATENCY HISTORY output is ok} {
16 | set min 250
17 | set max 450
18 | foreach event [r latency history command] {
19 | lassign $event time latency
20 | assert {$latency >= $min && $latency <= $max}
21 | incr min 100
22 | incr max 100
23 | set last_time $time ; # Used in the next test
24 | }
25 | }
26 |
27 | test {LATENCY LATEST output is ok} {
28 | foreach event [r latency latest] {
29 | lassign $event eventname time latency max
30 | assert {$eventname eq "command"}
31 | assert {$max >= 450 & $max <= 650}
32 | assert {$time == $last_time}
33 | break
34 | }
35 | }
36 |
37 | test {LATENCY HISTORY / RESET with wrong event name is fine} {
38 | assert {[llength [r latency history blabla]] == 0}
39 | assert {[r latency reset blabla] == 0}
40 | }
41 |
42 | test {LATENCY DOCTOR produces some output} {
43 | assert {[string length [r latency doctor]] > 0}
44 | }
45 |
46 | test {LATENCY RESET is able to reset events} {
47 | assert {[r latency reset] > 0}
48 | assert {[r latency latest] eq {}}
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/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 | {
16 | unsigned thread_ind = (unsigned)(uintptr_t)arg;
17 | unsigned arena_ind;
18 | void *p;
19 | size_t sz;
20 |
21 | sz = sizeof(arena_ind);
22 | assert_d_eq(mallctl("arenas.extend", &arena_ind, &sz, NULL, 0), 0,
23 | "Error in arenas.extend");
24 |
25 | if (thread_ind % 4 != 3) {
26 | size_t mib[3];
27 | size_t miblen = sizeof(mib) / sizeof(size_t);
28 | const char *dss_precs[] = {"disabled", "primary", "secondary"};
29 | unsigned prec_ind = thread_ind %
30 | (sizeof(dss_precs)/sizeof(char*));
31 | const char *dss = dss_precs[prec_ind];
32 | int expected_err = (have_dss || prec_ind == 0) ? 0 : EFAULT;
33 | assert_d_eq(mallctlnametomib("arena.0.dss", mib, &miblen), 0,
34 | "Error in mallctlnametomib()");
35 | mib[1] = arena_ind;
36 | assert_d_eq(mallctlbymib(mib, miblen, NULL, NULL, (void *)&dss,
37 | sizeof(const char *)), expected_err,
38 | "Error in mallctlbymib()");
39 | }
40 |
41 | p = mallocx(1, MALLOCX_ARENA(arena_ind));
42 | assert_ptr_not_null(p, "Unexpected mallocx() error");
43 | dallocx(p, 0);
44 |
45 | return (NULL);
46 | }
47 |
48 | TEST_BEGIN(test_MALLOCX_ARENA)
49 | {
50 | thd_t thds[NTHREADS];
51 | unsigned i;
52 |
53 | for (i = 0; i < NTHREADS; i++) {
54 | thd_create(&thds[i], thd_start,
55 | (void *)(uintptr_t)i);
56 | }
57 |
58 | for (i = 0; i < NTHREADS; i++)
59 | thd_join(thds[i], NULL);
60 | }
61 | TEST_END
62 |
63 | int
64 | main(void)
65 | {
66 |
67 | return (test(
68 | test_MALLOCX_ARENA));
69 | }
70 |
--------------------------------------------------------------------------------
/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-2015 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/test/unit/zero.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | #ifdef JEMALLOC_FILL
4 | const char *malloc_conf =
5 | "abort:false,junk:false,zero:true,redzone:false,quarantine:0";
6 | #endif
7 |
8 | static void
9 | test_zero(size_t sz_min, size_t sz_max)
10 | {
11 | char *s;
12 | size_t sz_prev, sz, i;
13 |
14 | sz_prev = 0;
15 | s = (char *)mallocx(sz_min, 0);
16 | assert_ptr_not_null((void *)s, "Unexpected mallocx() failure");
17 |
18 | for (sz = sallocx(s, 0); sz <= sz_max;
19 | sz_prev = sz, sz = sallocx(s, 0)) {
20 | if (sz_prev > 0) {
21 | assert_c_eq(s[0], 'a',
22 | "Previously allocated byte %zu/%zu is corrupted",
23 | ZU(0), sz_prev);
24 | assert_c_eq(s[sz_prev-1], 'a',
25 | "Previously allocated byte %zu/%zu is corrupted",
26 | sz_prev-1, sz_prev);
27 | }
28 |
29 | for (i = sz_prev; i < sz; i++) {
30 | assert_c_eq(s[i], 0x0,
31 | "Newly allocated byte %zu/%zu isn't zero-filled",
32 | i, sz);
33 | s[i] = 'a';
34 | }
35 |
36 | if (xallocx(s, sz+1, 0, 0) == sz) {
37 | s = (char *)rallocx(s, sz+1, 0);
38 | assert_ptr_not_null((void *)s,
39 | "Unexpected rallocx() failure");
40 | }
41 | }
42 |
43 | dallocx(s, 0);
44 | }
45 |
46 | TEST_BEGIN(test_zero_small)
47 | {
48 |
49 | test_skip_if(!config_fill);
50 | test_zero(1, SMALL_MAXCLASS-1);
51 | }
52 | TEST_END
53 |
54 | TEST_BEGIN(test_zero_large)
55 | {
56 |
57 | test_skip_if(!config_fill);
58 | test_zero(SMALL_MAXCLASS+1, large_maxclass);
59 | }
60 | TEST_END
61 |
62 | TEST_BEGIN(test_zero_huge)
63 | {
64 |
65 | test_skip_if(!config_fill);
66 | test_zero(large_maxclass+1, chunksize*2);
67 | }
68 | TEST_END
69 |
70 | int
71 | main(void)
72 | {
73 |
74 | return (test(
75 | test_zero_small,
76 | test_zero_large,
77 | test_zero_huge));
78 | }
79 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/jemalloc_typedefs.h.in:
--------------------------------------------------------------------------------
1 | /*
2 | * void *
3 | * chunk_alloc(void *new_addr, size_t size, size_t alignment, bool *zero,
4 | * bool *commit, unsigned arena_ind);
5 | */
6 | typedef void *(chunk_alloc_t)(void *, size_t, size_t, bool *, bool *, unsigned);
7 |
8 | /*
9 | * bool
10 | * chunk_dalloc(void *chunk, size_t size, bool committed, unsigned arena_ind);
11 | */
12 | typedef bool (chunk_dalloc_t)(void *, size_t, bool, unsigned);
13 |
14 | /*
15 | * bool
16 | * chunk_commit(void *chunk, size_t size, size_t offset, size_t length,
17 | * unsigned arena_ind);
18 | */
19 | typedef bool (chunk_commit_t)(void *, size_t, size_t, size_t, unsigned);
20 |
21 | /*
22 | * bool
23 | * chunk_decommit(void *chunk, size_t size, size_t offset, size_t length,
24 | * unsigned arena_ind);
25 | */
26 | typedef bool (chunk_decommit_t)(void *, size_t, size_t, size_t, unsigned);
27 |
28 | /*
29 | * bool
30 | * chunk_purge(void *chunk, size_t size, size_t offset, size_t length,
31 | * unsigned arena_ind);
32 | */
33 | typedef bool (chunk_purge_t)(void *, size_t, size_t, size_t, unsigned);
34 |
35 | /*
36 | * bool
37 | * chunk_split(void *chunk, size_t size, size_t size_a, size_t size_b,
38 | * bool committed, unsigned arena_ind);
39 | */
40 | typedef bool (chunk_split_t)(void *, size_t, size_t, size_t, bool, unsigned);
41 |
42 | /*
43 | * bool
44 | * chunk_merge(void *chunk_a, size_t size_a, void *chunk_b, size_t size_b,
45 | * bool committed, unsigned arena_ind);
46 | */
47 | typedef bool (chunk_merge_t)(void *, size_t, void *, size_t, bool, unsigned);
48 |
49 | typedef struct {
50 | chunk_alloc_t *alloc;
51 | chunk_dalloc_t *dalloc;
52 | chunk_commit_t *commit;
53 | chunk_decommit_t *decommit;
54 | chunk_purge_t *purge;
55 | chunk_split_t *split;
56 | chunk_merge_t *merge;
57 | } chunk_hooks_t;
58 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/deps/jemalloc/.gitignore:
--------------------------------------------------------------------------------
1 | /*.gcov.*
2 |
3 | /bin/jemalloc-config
4 | /bin/jemalloc.sh
5 | /bin/jeprof
6 |
7 | /config.stamp
8 | /config.log
9 | /config.status
10 | /configure
11 |
12 | /doc/html.xsl
13 | /doc/manpages.xsl
14 | /doc/jemalloc.xml
15 | /doc/jemalloc.html
16 | /doc/jemalloc.3
17 |
18 | /jemalloc.pc
19 |
20 | /lib/
21 |
22 | /Makefile
23 |
24 | /include/jemalloc/internal/jemalloc_internal.h
25 | /include/jemalloc/internal/jemalloc_internal_defs.h
26 | /include/jemalloc/internal/private_namespace.h
27 | /include/jemalloc/internal/private_unnamespace.h
28 | /include/jemalloc/internal/public_namespace.h
29 | /include/jemalloc/internal/public_symbols.txt
30 | /include/jemalloc/internal/public_unnamespace.h
31 | /include/jemalloc/internal/size_classes.h
32 | /include/jemalloc/jemalloc.h
33 | /include/jemalloc/jemalloc_defs.h
34 | /include/jemalloc/jemalloc_macros.h
35 | /include/jemalloc/jemalloc_mangle.h
36 | /include/jemalloc/jemalloc_mangle_jet.h
37 | /include/jemalloc/jemalloc_protos.h
38 | /include/jemalloc/jemalloc_protos_jet.h
39 | /include/jemalloc/jemalloc_rename.h
40 | /include/jemalloc/jemalloc_typedefs.h
41 |
42 | /src/*.[od]
43 | /src/*.gcda
44 | /src/*.gcno
45 |
46 | /test/test.sh
47 | test/include/test/jemalloc_test.h
48 | test/include/test/jemalloc_test_defs.h
49 |
50 | /test/integration/[A-Za-z]*
51 | !/test/integration/[A-Za-z]*.*
52 | /test/integration/*.[od]
53 | /test/integration/*.gcda
54 | /test/integration/*.gcno
55 | /test/integration/*.out
56 |
57 | /test/src/*.[od]
58 | /test/src/*.gcda
59 | /test/src/*.gcno
60 |
61 | /test/stress/[A-Za-z]*
62 | !/test/stress/[A-Za-z]*.*
63 | /test/stress/*.[od]
64 | /test/stress/*.gcda
65 | /test/stress/*.gcno
66 | /test/stress/*.out
67 |
68 | /test/unit/[A-Za-z]*
69 | !/test/unit/[A-Za-z]*.*
70 | /test/unit/*.[od]
71 | /test/unit/*.gcda
72 | /test/unit/*.gcno
73 | /test/unit/*.out
74 |
75 | /VERSION
76 |
--------------------------------------------------------------------------------
/deps/jemalloc/bin/jemalloc-config.in:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | usage() {
4 | cat <
7 | Options:
8 | --help | -h : Print usage.
9 | --version : Print jemalloc version.
10 | --revision : Print shared library revision number.
11 | --config : Print configure options used to build jemalloc.
12 | --prefix : Print installation directory prefix.
13 | --bindir : Print binary installation directory.
14 | --datadir : Print data installation directory.
15 | --includedir : Print include installation directory.
16 | --libdir : Print library installation directory.
17 | --mandir : Print manual page installation directory.
18 | --cc : Print compiler used to build jemalloc.
19 | --cflags : Print compiler flags used to build jemalloc.
20 | --cppflags : Print preprocessor flags used to build jemalloc.
21 | --ldflags : Print library flags used to build jemalloc.
22 | --libs : Print libraries jemalloc was linked against.
23 | EOF
24 | }
25 |
26 | prefix="@prefix@"
27 | exec_prefix="@exec_prefix@"
28 |
29 | case "$1" in
30 | --help | -h)
31 | usage
32 | exit 0
33 | ;;
34 | --version)
35 | echo "@jemalloc_version@"
36 | ;;
37 | --revision)
38 | echo "@rev@"
39 | ;;
40 | --config)
41 | echo "@CONFIG@"
42 | ;;
43 | --prefix)
44 | echo "@PREFIX@"
45 | ;;
46 | --bindir)
47 | echo "@BINDIR@"
48 | ;;
49 | --datadir)
50 | echo "@DATADIR@"
51 | ;;
52 | --includedir)
53 | echo "@INCLUDEDIR@"
54 | ;;
55 | --libdir)
56 | echo "@LIBDIR@"
57 | ;;
58 | --mandir)
59 | echo "@MANDIR@"
60 | ;;
61 | --cc)
62 | echo "@CC@"
63 | ;;
64 | --cflags)
65 | echo "@CFLAGS@"
66 | ;;
67 | --cppflags)
68 | echo "@CPPFLAGS@"
69 | ;;
70 | --ldflags)
71 | echo "@LDFLAGS@ @EXTRA_LDFLAGS@"
72 | ;;
73 | --libs)
74 | echo "@LIBS@"
75 | ;;
76 | *)
77 | usage
78 | exit 1
79 | esac
80 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/quarantine.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************/
2 | #ifdef JEMALLOC_H_TYPES
3 |
4 | typedef struct quarantine_obj_s quarantine_obj_t;
5 | typedef struct quarantine_s quarantine_t;
6 |
7 | /* Default per thread quarantine size if valgrind is enabled. */
8 | #define JEMALLOC_VALGRIND_QUARANTINE_DEFAULT (ZU(1) << 24)
9 |
10 | #endif /* JEMALLOC_H_TYPES */
11 | /******************************************************************************/
12 | #ifdef JEMALLOC_H_STRUCTS
13 |
14 | struct quarantine_obj_s {
15 | void *ptr;
16 | size_t usize;
17 | };
18 |
19 | struct quarantine_s {
20 | size_t curbytes;
21 | size_t curobjs;
22 | size_t first;
23 | #define LG_MAXOBJS_INIT 10
24 | size_t lg_maxobjs;
25 | quarantine_obj_t objs[1]; /* Dynamically sized ring buffer. */
26 | };
27 |
28 | #endif /* JEMALLOC_H_STRUCTS */
29 | /******************************************************************************/
30 | #ifdef JEMALLOC_H_EXTERNS
31 |
32 | void quarantine_alloc_hook_work(tsd_t *tsd);
33 | void quarantine(tsd_t *tsd, void *ptr);
34 | void quarantine_cleanup(tsd_t *tsd);
35 |
36 | #endif /* JEMALLOC_H_EXTERNS */
37 | /******************************************************************************/
38 | #ifdef JEMALLOC_H_INLINES
39 |
40 | #ifndef JEMALLOC_ENABLE_INLINE
41 | void quarantine_alloc_hook(void);
42 | #endif
43 |
44 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_QUARANTINE_C_))
45 | JEMALLOC_ALWAYS_INLINE void
46 | quarantine_alloc_hook(void)
47 | {
48 | tsd_t *tsd;
49 |
50 | assert(config_fill && opt_quarantine);
51 |
52 | tsd = tsd_fetch();
53 | if (tsd_quarantine_get(tsd) == NULL)
54 | quarantine_alloc_hook_work(tsd);
55 | }
56 | #endif
57 |
58 | #endif /* JEMALLOC_H_INLINES */
59 | /******************************************************************************/
60 |
61 |
--------------------------------------------------------------------------------
/src/rand.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009-2012, Salvatore Sanfilippo
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions are met:
7 | *
8 | * * Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * * Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * * Neither the name of Redis nor the names of its contributors may be used
14 | * to endorse or promote products derived from this software without
15 | * specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 | * POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #ifndef REDIS_RANDOM_H
31 | #define REDIS_RANDOM_H
32 |
33 | int32_t redisLrand48();
34 | void redisSrand48(int32_t seedval);
35 |
36 | #define REDIS_LRAND48_MAX INT32_MAX
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/integration/thread_arena.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | #define NTHREADS 10
4 |
5 | void *
6 | thd_start(void *arg)
7 | {
8 | unsigned main_arena_ind = *(unsigned *)arg;
9 | void *p;
10 | unsigned arena_ind;
11 | size_t size;
12 | int err;
13 |
14 | p = malloc(1);
15 | assert_ptr_not_null(p, "Error in malloc()");
16 | free(p);
17 |
18 | size = sizeof(arena_ind);
19 | if ((err = mallctl("thread.arena", &arena_ind, &size, &main_arena_ind,
20 | sizeof(main_arena_ind)))) {
21 | char buf[BUFERROR_BUF];
22 |
23 | buferror(err, buf, sizeof(buf));
24 | test_fail("Error in mallctl(): %s", buf);
25 | }
26 |
27 | size = sizeof(arena_ind);
28 | if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 0))) {
29 | char buf[BUFERROR_BUF];
30 |
31 | buferror(err, buf, sizeof(buf));
32 | test_fail("Error in mallctl(): %s", buf);
33 | }
34 | assert_u_eq(arena_ind, main_arena_ind,
35 | "Arena index should be same as for main thread");
36 |
37 | return (NULL);
38 | }
39 |
40 | TEST_BEGIN(test_thread_arena)
41 | {
42 | void *p;
43 | unsigned arena_ind;
44 | size_t size;
45 | int err;
46 | thd_t thds[NTHREADS];
47 | unsigned i;
48 |
49 | p = malloc(1);
50 | assert_ptr_not_null(p, "Error in malloc()");
51 |
52 | size = sizeof(arena_ind);
53 | if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 0))) {
54 | char buf[BUFERROR_BUF];
55 |
56 | buferror(err, buf, sizeof(buf));
57 | test_fail("Error in mallctl(): %s", buf);
58 | }
59 |
60 | for (i = 0; i < NTHREADS; i++) {
61 | thd_create(&thds[i], thd_start,
62 | (void *)&arena_ind);
63 | }
64 |
65 | for (i = 0; i < NTHREADS; i++) {
66 | intptr_t join_ret;
67 | thd_join(thds[i], (void *)&join_ret);
68 | assert_zd_eq(join_ret, 0, "Unexpected thread join error");
69 | }
70 | }
71 | TEST_END
72 |
73 | int
74 | main(void)
75 | {
76 |
77 | return (test(
78 | test_thread_arena));
79 | }
80 |
--------------------------------------------------------------------------------
/CONTRIBUTING:
--------------------------------------------------------------------------------
1 | Note: by contributing code to the Redis project in any form, including sending
2 | a pull request via Github, a code fragment or patch via private email or
3 | public discussion groups, you agree to release your code under the terms
4 | of the BSD license that you can find in the COPYING file included in the Redis
5 | source distribution. You will include BSD license in the COPYING file within
6 | each source file that you contribute.
7 |
8 | # IMPORTANT: HOW TO USE REDIS GITHUB ISSUES
9 |
10 | * Github issues SHOULD ONLY BE USED to report bugs, and for DETAILED feature
11 | requests. Everything else belongs to the Redis Google Group.
12 |
13 | PLEASE DO NOT POST GENERAL QUESTIONS that are not about bugs or suspected
14 | bugs in the Github issues system. We'll be very happy to help you and provide
15 | all the support at the Reddit sub:
16 |
17 | http://reddit.com/r/redis
18 |
19 | There is also an active community of Redis users at Stack Overflow:
20 |
21 | http://stackoverflow.com/questions/tagged/redis
22 |
23 | # How to provide a patch for a new feature
24 |
25 | 1. If it is a major feature or a semantical change, please post it as a new submission in r/redis on Reddit at http://reddit.com/r/redis. Try to be passionate about why the feature is needed, make users upvote your proposal to gain traction and so forth. Read feedbacks about the community. But in this first step **please don't write code yet**.
26 |
27 | 2. If in step 1 you get an acknowledgment from the project leaders, use the
28 | following procedure to submit a patch:
29 |
30 | a. Fork Redis on github ( http://help.github.com/fork-a-repo/ )
31 | b. Create a topic branch (git checkout -b my_branch)
32 | c. Push to your branch (git push origin my_branch)
33 | d. Initiate a pull request on github ( http://help.github.com/send-pull-requests/ )
34 | e. Done :)
35 |
36 | For minor fixes just open a pull request on Github.
37 |
38 | Thanks!
39 |
--------------------------------------------------------------------------------
/deps/jemalloc/include/jemalloc/internal/jemalloc_internal_macros.h:
--------------------------------------------------------------------------------
1 | /*
2 | * JEMALLOC_ALWAYS_INLINE and JEMALLOC_INLINE are used within header files for
3 | * functions that are static inline functions if inlining is enabled, and
4 | * single-definition library-private functions if inlining is disabled.
5 | *
6 | * JEMALLOC_ALWAYS_INLINE_C and JEMALLOC_INLINE_C are for use in .c files, in
7 | * which case the denoted functions are always static, regardless of whether
8 | * inlining is enabled.
9 | */
10 | #if defined(JEMALLOC_DEBUG) || defined(JEMALLOC_CODE_COVERAGE)
11 | /* Disable inlining to make debugging/profiling easier. */
12 | # define JEMALLOC_ALWAYS_INLINE
13 | # define JEMALLOC_ALWAYS_INLINE_C static
14 | # define JEMALLOC_INLINE
15 | # define JEMALLOC_INLINE_C static
16 | # define inline
17 | #else
18 | # define JEMALLOC_ENABLE_INLINE
19 | # ifdef JEMALLOC_HAVE_ATTR
20 | # define JEMALLOC_ALWAYS_INLINE \
21 | static inline JEMALLOC_ATTR(unused) JEMALLOC_ATTR(always_inline)
22 | # define JEMALLOC_ALWAYS_INLINE_C \
23 | static inline JEMALLOC_ATTR(always_inline)
24 | # else
25 | # define JEMALLOC_ALWAYS_INLINE static inline
26 | # define JEMALLOC_ALWAYS_INLINE_C static inline
27 | # endif
28 | # define JEMALLOC_INLINE static inline
29 | # define JEMALLOC_INLINE_C static inline
30 | # ifdef _MSC_VER
31 | # define inline _inline
32 | # endif
33 | #endif
34 |
35 | #ifdef JEMALLOC_CC_SILENCE
36 | # define UNUSED JEMALLOC_ATTR(unused)
37 | #else
38 | # define UNUSED
39 | #endif
40 |
41 | #define ZU(z) ((size_t)z)
42 | #define ZI(z) ((ssize_t)z)
43 | #define QU(q) ((uint64_t)q)
44 | #define QI(q) ((int64_t)q)
45 |
46 | #define KZU(z) ZU(z##ULL)
47 | #define KZI(z) ZI(z##LL)
48 | #define KQU(q) QU(q##ULL)
49 | #define KQI(q) QI(q##LL)
50 |
51 | #ifndef __DECONST
52 | # define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
53 | #endif
54 |
55 | #ifndef JEMALLOC_HAS_RESTRICT
56 | # define restrict
57 | #endif
58 |
--------------------------------------------------------------------------------
/utils/redis-sha1.rb:
--------------------------------------------------------------------------------
1 | # redis-sha1.rb - Copyright (C) 2009 Salvatore Sanfilippo
2 | # BSD license, See the COPYING file for more information.
3 | #
4 | # Performs the SHA1 sum of the whole datset.
5 | # This is useful to spot bugs in persistence related code and to make sure
6 | # Slaves and Masters are in SYNC.
7 | #
8 | # If you hack this code make sure to sort keys and set elements as this are
9 | # unsorted elements. Otherwise the sum may differ with equal dataset.
10 |
11 | require 'rubygems'
12 | require 'redis'
13 | require 'digest/sha1'
14 |
15 | def redisSha1(opts={})
16 | sha1=""
17 | r = Redis.new(opts)
18 | r.keys('*').sort.each{|k|
19 | vtype = r.type?(k)
20 | if vtype == "string"
21 | len = 1
22 | sha1 = Digest::SHA1.hexdigest(sha1+k)
23 | sha1 = Digest::SHA1.hexdigest(sha1+r.get(k))
24 | elsif vtype == "list"
25 | len = r.llen(k)
26 | if len != 0
27 | sha1 = Digest::SHA1.hexdigest(sha1+k)
28 | sha1 = Digest::SHA1.hexdigest(sha1+r.list_range(k,0,-1).join("\x01"))
29 | end
30 | elsif vtype == "set"
31 | len = r.scard(k)
32 | if len != 0
33 | sha1 = Digest::SHA1.hexdigest(sha1+k)
34 | sha1 = Digest::SHA1.hexdigest(sha1+r.set_members(k).to_a.sort.join("\x02"))
35 | end
36 | elsif vtype == "zset"
37 | len = r.zcard(k)
38 | if len != 0
39 | sha1 = Digest::SHA1.hexdigest(sha1+k)
40 | sha1 = Digest::SHA1.hexdigest(sha1+r.zrange(k,0,-1).join("\x01"))
41 | end
42 | end
43 | # puts "#{k} => #{sha1}" if len != 0
44 | }
45 | sha1
46 | end
47 |
48 | host = ARGV[0] || "127.0.0.1"
49 | port = ARGV[1] || "6379"
50 | db = ARGV[2] || "0"
51 | puts "Performing SHA1 of Redis server #{host} #{port} DB: #{db}"
52 | p "Dataset SHA1: #{redisSha1(:host => host, :port => port.to_i, :db => db)}"
53 |
--------------------------------------------------------------------------------
/deps/lua/src/ltm.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #include
9 |
10 | #define ltm_c
11 | #define LUA_CORE
12 |
13 | #include "lua.h"
14 |
15 | #include "lobject.h"
16 | #include "lstate.h"
17 | #include "lstring.h"
18 | #include "ltable.h"
19 | #include "ltm.h"
20 |
21 |
22 |
23 | const char *const luaT_typenames[] = {
24 | "nil", "boolean", "userdata", "number",
25 | "string", "table", "function", "userdata", "thread",
26 | "proto", "upval"
27 | };
28 |
29 |
30 | void luaT_init (lua_State *L) {
31 | static const char *const luaT_eventname[] = { /* ORDER TM */
32 | "__index", "__newindex",
33 | "__gc", "__mode", "__eq",
34 | "__add", "__sub", "__mul", "__div", "__mod",
35 | "__pow", "__unm", "__len", "__lt", "__le",
36 | "__concat", "__call"
37 | };
38 | int i;
39 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]);
41 | luaS_fix(G(L)->tmname[i]); /* never collect these names */
42 | }
43 | }
44 |
45 |
46 | /*
47 | ** function to be used with macro "fasttm": optimized for absence of
48 | ** tag methods
49 | */
50 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
51 | const TValue *tm = luaH_getstr(events, ename);
52 | lua_assert(event <= TM_EQ);
53 | if (ttisnil(tm)) { /* no tag method? */
54 | events->flags |= cast_byte(1u<metatable;
66 | break;
67 | case LUA_TUSERDATA:
68 | mt = uvalue(o)->metatable;
69 | break;
70 | default:
71 | mt = G(L)->mt[ttype(o)];
72 | }
73 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/deps/lua/src/lzio.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** a generic input stream interface
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #include
9 |
10 | #define lzio_c
11 | #define LUA_CORE
12 |
13 | #include "lua.h"
14 |
15 | #include "llimits.h"
16 | #include "lmem.h"
17 | #include "lstate.h"
18 | #include "lzio.h"
19 |
20 |
21 | int luaZ_fill (ZIO *z) {
22 | size_t size;
23 | lua_State *L = z->L;
24 | const char *buff;
25 | lua_unlock(L);
26 | buff = z->reader(L, z->data, &size);
27 | lua_lock(L);
28 | if (buff == NULL || size == 0) return EOZ;
29 | z->n = size - 1;
30 | z->p = buff;
31 | return char2int(*(z->p++));
32 | }
33 |
34 |
35 | int luaZ_lookahead (ZIO *z) {
36 | if (z->n == 0) {
37 | if (luaZ_fill(z) == EOZ)
38 | return EOZ;
39 | else {
40 | z->n++; /* luaZ_fill removed first byte; put back it */
41 | z->p--;
42 | }
43 | }
44 | return char2int(*z->p);
45 | }
46 |
47 |
48 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
49 | z->L = L;
50 | z->reader = reader;
51 | z->data = data;
52 | z->n = 0;
53 | z->p = NULL;
54 | }
55 |
56 |
57 | /* --------------------------------------------------------------- read --- */
58 | size_t luaZ_read (ZIO *z, void *b, size_t n) {
59 | while (n) {
60 | size_t m;
61 | if (luaZ_lookahead(z) == EOZ)
62 | return n; /* return number of missing bytes */
63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
64 | memcpy(b, z->p, m);
65 | z->n -= m;
66 | z->p += m;
67 | b = (char *)b + m;
68 | n -= m;
69 | }
70 | return 0;
71 | }
72 |
73 | /* ------------------------------------------------------------------------ */
74 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
75 | if (n > buff->buffsize) {
76 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
77 | luaZ_resizebuffer(L, buff, n);
78 | }
79 | return buff->buffer;
80 | }
81 |
82 |
83 |
--------------------------------------------------------------------------------
/src/graph.h:
--------------------------------------------------------------------------------
1 | typedef struct ListNode {
2 | void* value;
3 | struct ListNode *next;
4 |
5 | } ListNode;
6 |
7 | typedef struct {
8 | ListNode *root;
9 | ListNode *tail;
10 | int size;
11 | } List;
12 |
13 | typedef struct {
14 | double value1;
15 | double value2;
16 | sds key;
17 | robj *edges;
18 | dict *edges_hash;
19 | robj *incoming; // Only for directed graphs
20 | sds memory_key;
21 | int visited; // TEMP
22 | struct GraphNode *parent;
23 | } GraphNode;
24 |
25 | typedef struct {
26 | GraphNode *node1;
27 | GraphNode *node2;
28 | double value;
29 | sds memory_key;
30 | } GraphEdge;
31 |
32 | typedef struct {
33 | List *nodes; //TODO: Use redis lists like the GraphNode
34 | List *edges; //TODO: Use redis lists like the GraphNode
35 | robj *nodes_hash;
36 | int directed;
37 | } Graph;
38 |
39 | robj *createGraphObject();
40 | Graph* GraphCreate();
41 | int GraphDirected(Graph* graph);
42 | int GraphNodesSize(Graph* graph);
43 | int GraphEdgesSize(Graph* graph);
44 |
45 | List* ListCreate();
46 | ListNode* ListNodeCreate(void* value);
47 | void ListDeleteNode(List *, void *);
48 | void ListAddNode(List *, ListNode *);
49 |
50 | GraphNode* GraphNodeCreate(sds key);
51 | void GraphAddNode(Graph *graph, GraphNode *node);
52 | void GraphDeleteNode(Graph *graph, GraphNode *node);
53 | GraphNode* GraphGetNode(Graph *graph, sds key);
54 | int GraphNodeExists(Graph *graph, sds key);
55 | GraphNode* GraphGetOrAddNode(Graph *graph, sds key);
56 | int GraphNodeOutdegree(Graph *graph, GraphNode *node);
57 |
58 | GraphEdge* GraphGetEdge(Graph *graph, GraphNode *node1, GraphNode *node2);
59 | GraphEdge *GraphGetEdgeByKey(Graph *graph, sds key);
60 | GraphEdge* GraphEdgeCreate(GraphNode *node1, GraphNode *node2, float value);
61 | void GraphAddEdge(Graph *graph, GraphEdge *graph_edge);
62 | void GraphDeleteEdge(Graph *graph, GraphEdge *graphEdge);
63 |
64 | void freeGraphObject(robj *graph_object);
65 |
66 | robj *neighboursToSet(GraphNode *node, Graph *graph_object);
67 |
--------------------------------------------------------------------------------
/src/pqsort.h:
--------------------------------------------------------------------------------
1 | /* The following is the NetBSD libc qsort implementation modified in order to
2 | * support partial sorting of ranges for Redis.
3 | *
4 | * Copyright (c) 2009-2012, Salvatore Sanfilippo
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * * Neither the name of Redis nor the names of its contributors may be used
16 | * to endorse or promote products derived from this software without
17 | * specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 | * POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | * See the pqsort.c file for the original copyright notice. */
32 |
33 | #ifndef __PQSORT_H
34 | #define __PQSORT_H
35 |
36 | void
37 | pqsort(void *a, size_t n, size_t es,
38 | int (*cmp) (const void *, const void *), size_t lrange, size_t rrange);
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/deps/lua/src/ldo.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
3 | ** Stack and Call structure of Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldo_h
8 | #define ldo_h
9 |
10 |
11 | #include "lobject.h"
12 | #include "lstate.h"
13 | #include "lzio.h"
14 |
15 |
16 | #define luaD_checkstack(L,n) \
17 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
18 | luaD_growstack(L, n); \
19 | else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
20 |
21 |
22 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;}
23 |
24 | #define savestack(L,p) ((char *)(p) - (char *)L->stack)
25 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
26 |
27 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
28 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
29 |
30 |
31 | /* results from luaD_precall */
32 | #define PCRLUA 0 /* initiated a call to a Lua function */
33 | #define PCRC 1 /* did a call to a C function */
34 | #define PCRYIELD 2 /* C funtion yielded */
35 |
36 |
37 | /* type of protected functions, to be ran by `runprotected' */
38 | typedef void (*Pfunc) (lua_State *L, void *ud);
39 |
40 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
41 | LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
44 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
45 | ptrdiff_t oldtop, ptrdiff_t ef);
46 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
47 | LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
48 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
49 | LUAI_FUNC void luaD_growstack (lua_State *L, int n);
50 |
51 | LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
52 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
53 |
54 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
55 |
56 | #endif
57 |
58 |
--------------------------------------------------------------------------------
/tests/cluster/tests/12-replica-migration-2.tcl:
--------------------------------------------------------------------------------
1 | # Replica migration test #2.
2 | #
3 | # Check that the status of master that can be targeted by replica migration
4 | # is acquired again, after being getting slots again, in a cluster where the
5 | # other masters have slaves.
6 |
7 | source "../tests/includes/init-tests.tcl"
8 |
9 | # Create a cluster with 5 master and 15 slaves, to make sure there are no
10 | # empty masters and make rebalancing simpler to handle during the test.
11 | test "Create a 5 nodes cluster" {
12 | create_cluster 5 15
13 | }
14 |
15 | test "Cluster is up" {
16 | assert_cluster_state ok
17 | }
18 |
19 | test "Each master should have at least two replicas attached" {
20 | foreach_redis_id id {
21 | if {$id < 5} {
22 | wait_for_condition 1000 50 {
23 | [llength [lindex [R 0 role] 2]] >= 2
24 | } else {
25 | fail "Master #$id does not have 2 slaves as expected"
26 | }
27 | }
28 | }
29 | }
30 |
31 | set master0_id [dict get [get_myself 0] id]
32 | test "Resharding all the master #0 slots away from it" {
33 | set output [exec \
34 | ../../../src/redis-trib.rb rebalance \
35 | --weight ${master0_id}=0 \
36 | 127.0.0.1:[get_instance_attrib redis 0 port] >@ stdout]
37 | }
38 |
39 | test "Master #0 should lose its replicas" {
40 | wait_for_condition 1000 50 {
41 | [llength [lindex [R 0 role] 2]] == 0
42 | } else {
43 | fail "Master #0 still has replicas"
44 | }
45 | }
46 |
47 | test "Resharding back some slot to master #0" {
48 | # Wait for the cluster config to propagate before attempting a
49 | # new resharding.
50 | after 10000
51 | set output [exec \
52 | ../../../src/redis-trib.rb rebalance \
53 | --weight ${master0_id}=.01 \
54 | --use-empty-masters \
55 | 127.0.0.1:[get_instance_attrib redis 0 port] >@ stdout]
56 | }
57 |
58 | test "Master #0 should re-acquire one or more replicas" {
59 | wait_for_condition 1000 50 {
60 | [llength [lindex [R 0 role] 2]] >= 1
61 | } else {
62 | fail "Master #0 has no has replicas"
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/src/timer.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | void
4 | timer_start(timedelta_t *timer)
5 | {
6 |
7 | #ifdef _WIN32
8 | GetSystemTimeAsFileTime(&timer->ft0);
9 | #elif JEMALLOC_CLOCK_GETTIME
10 | if (sysconf(_SC_MONOTONIC_CLOCK) <= 0)
11 | timer->clock_id = CLOCK_REALTIME;
12 | else
13 | timer->clock_id = CLOCK_MONOTONIC;
14 | clock_gettime(timer->clock_id, &timer->ts0);
15 | #else
16 | gettimeofday(&timer->tv0, NULL);
17 | #endif
18 | }
19 |
20 | void
21 | timer_stop(timedelta_t *timer)
22 | {
23 |
24 | #ifdef _WIN32
25 | GetSystemTimeAsFileTime(&timer->ft0);
26 | #elif JEMALLOC_CLOCK_GETTIME
27 | clock_gettime(timer->clock_id, &timer->ts1);
28 | #else
29 | gettimeofday(&timer->tv1, NULL);
30 | #endif
31 | }
32 |
33 | uint64_t
34 | timer_usec(const timedelta_t *timer)
35 | {
36 |
37 | #ifdef _WIN32
38 | uint64_t t0, t1;
39 | t0 = (((uint64_t)timer->ft0.dwHighDateTime) << 32) |
40 | timer->ft0.dwLowDateTime;
41 | t1 = (((uint64_t)timer->ft1.dwHighDateTime) << 32) |
42 | timer->ft1.dwLowDateTime;
43 | return ((t1 - t0) / 10);
44 | #elif JEMALLOC_CLOCK_GETTIME
45 | return (((timer->ts1.tv_sec - timer->ts0.tv_sec) * 1000000) +
46 | (timer->ts1.tv_nsec - timer->ts0.tv_nsec) / 1000);
47 | #else
48 | return (((timer->tv1.tv_sec - timer->tv0.tv_sec) * 1000000) +
49 | timer->tv1.tv_usec - timer->tv0.tv_usec);
50 | #endif
51 | }
52 |
53 | void
54 | timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen)
55 | {
56 | uint64_t t0 = timer_usec(a);
57 | uint64_t t1 = timer_usec(b);
58 | uint64_t mult;
59 | unsigned i = 0;
60 | unsigned j;
61 | int n;
62 |
63 | /* Whole. */
64 | n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1);
65 | i += n;
66 | if (i >= buflen)
67 | return;
68 | mult = 1;
69 | for (j = 0; j < n; j++)
70 | mult *= 10;
71 |
72 | /* Decimal. */
73 | n = malloc_snprintf(&buf[i], buflen-i, ".");
74 | i += n;
75 |
76 | /* Fraction. */
77 | while (i < buflen-1) {
78 | uint64_t round = (i+1 == buflen-1 && ((t0 * mult * 10 / t1) % 10
79 | >= 5)) ? 1 : 0;
80 | n = malloc_snprintf(&buf[i], buflen-i,
81 | "%"FMTu64, (t0 * mult / t1) % 10 + round);
82 | i += n;
83 | mult *= 10;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/deps/jemalloc/test/unit/mq.c:
--------------------------------------------------------------------------------
1 | #include "test/jemalloc_test.h"
2 |
3 | #define NSENDERS 3
4 | #define NMSGS 100000
5 |
6 | typedef struct mq_msg_s mq_msg_t;
7 | struct mq_msg_s {
8 | mq_msg(mq_msg_t) link;
9 | };
10 | mq_gen(static, mq_, mq_t, mq_msg_t, link)
11 |
12 | TEST_BEGIN(test_mq_basic)
13 | {
14 | mq_t mq;
15 | mq_msg_t msg;
16 |
17 | assert_false(mq_init(&mq), "Unexpected mq_init() failure");
18 | assert_u_eq(mq_count(&mq), 0, "mq should be empty");
19 | assert_ptr_null(mq_tryget(&mq),
20 | "mq_tryget() should fail when the queue is empty");
21 |
22 | mq_put(&mq, &msg);
23 | assert_u_eq(mq_count(&mq), 1, "mq should contain one message");
24 | assert_ptr_eq(mq_tryget(&mq), &msg, "mq_tryget() should return msg");
25 |
26 | mq_put(&mq, &msg);
27 | assert_ptr_eq(mq_get(&mq), &msg, "mq_get() should return msg");
28 |
29 | mq_fini(&mq);
30 | }
31 | TEST_END
32 |
33 | static void *
34 | thd_receiver_start(void *arg)
35 | {
36 | mq_t *mq = (mq_t *)arg;
37 | unsigned i;
38 |
39 | for (i = 0; i < (NSENDERS * NMSGS); i++) {
40 | mq_msg_t *msg = mq_get(mq);
41 | assert_ptr_not_null(msg, "mq_get() should never return NULL");
42 | dallocx(msg, 0);
43 | }
44 | return (NULL);
45 | }
46 |
47 | static void *
48 | thd_sender_start(void *arg)
49 | {
50 | mq_t *mq = (mq_t *)arg;
51 | unsigned i;
52 |
53 | for (i = 0; i < NMSGS; i++) {
54 | mq_msg_t *msg;
55 | void *p;
56 | p = mallocx(sizeof(mq_msg_t), 0);
57 | assert_ptr_not_null(p, "Unexpected mallocx() failure");
58 | msg = (mq_msg_t *)p;
59 | mq_put(mq, msg);
60 | }
61 | return (NULL);
62 | }
63 |
64 | TEST_BEGIN(test_mq_threaded)
65 | {
66 | mq_t mq;
67 | thd_t receiver;
68 | thd_t senders[NSENDERS];
69 | unsigned i;
70 |
71 | assert_false(mq_init(&mq), "Unexpected mq_init() failure");
72 |
73 | thd_create(&receiver, thd_receiver_start, (void *)&mq);
74 | for (i = 0; i < NSENDERS; i++)
75 | thd_create(&senders[i], thd_sender_start, (void *)&mq);
76 |
77 | thd_join(receiver, NULL);
78 | for (i = 0; i < NSENDERS; i++)
79 | thd_join(senders[i], NULL);
80 |
81 | mq_fini(&mq);
82 | }
83 | TEST_END
84 |
85 | int
86 | main(void)
87 | {
88 |
89 | return (test(
90 | test_mq_basic,
91 | test_mq_threaded));
92 | }
93 |
94 |
--------------------------------------------------------------------------------
/src/sdsalloc.h:
--------------------------------------------------------------------------------
1 | /* SDSLib 2.0 -- A C dynamic strings library
2 | *
3 | * Copyright (c) 2006-2015, Salvatore Sanfilippo
4 | * Copyright (c) 2015, Redis Labs, Inc
5 | * All rights reserved.
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * * Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | * * Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * * Neither the name of Redis nor the names of its contributors may be used
16 | * to endorse or promote products derived from this software without
17 | * specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 | * POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | /* SDS allocator selection.
33 | *
34 | * This file is used in order to change the SDS allocator at compile time.
35 | * Just define the following defines to what you want to use. Also add
36 | * the include of your alternate allocator if needed (not needed in order
37 | * to use the default libc allocator). */
38 |
39 | #include "zmalloc.h"
40 | #define s_malloc zmalloc
41 | #define s_realloc zrealloc
42 | #define s_free zfree
43 |
--------------------------------------------------------------------------------