Skip to content

Commit f9018b9

Browse files
authored
Merge pull request #2 from antirez/unstable
update from master
2 parents fd0ee46 + 1d13ff0 commit f9018b9

File tree

206 files changed

+19838
-4187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+19838
-4187
lines changed

.github/workflows/ci.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test-ubuntu-latest:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- name: make
11+
run: make
12+
- name: test
13+
run: |
14+
sudo apt-get install tcl8.5
15+
./runtest --clients 2 --verbose
16+
17+
build-ubuntu-old:
18+
runs-on: ubuntu-16.04
19+
steps:
20+
- uses: actions/checkout@v1
21+
- name: make
22+
run: make
23+
24+
build-macos-latest:
25+
runs-on: macos-latest
26+
steps:
27+
- uses: actions/checkout@v1
28+
- name: make
29+
run: make

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.*.swp
22
*.o
3+
*.xo
4+
*.so
5+
*.d
36
*.log
47
dump.rdb
58
redis-benchmark
@@ -28,3 +31,5 @@ deps/lua/src/liblua.a
2831
.prerequisites
2932
*.dSYM
3033
Makefile.dep
34+
.vscode/*
35+
.idea/*

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ It is as simple as:
3535

3636
% make
3737

38+
To build with TLS support, you'll need OpenSSL development libraries (e.g.
39+
libssl-dev on Debian/Ubuntu) and run:
40+
41+
% make BUILD_TLS=yes
42+
3843
You can run a 32 bit Redis binary using:
3944

4045
% make 32bit
@@ -43,6 +48,13 @@ After building Redis, it is a good idea to test it using:
4348

4449
% make test
4550

51+
If TLS is built, running the tests with TLS enabled (you will need `tcl-tls`
52+
installed):
53+
54+
% ./utils/gen-test-certs.sh
55+
% ./runtest --tls
56+
57+
4658
Fixing build problems with dependencies or cached build options
4759
---------
4860

@@ -125,6 +137,12 @@ as options using the command line. Examples:
125137
All the options in redis.conf are also supported as options using the command
126138
line, with exactly the same name.
127139

140+
Running Redis with TLS:
141+
------------------
142+
143+
Please consult the [TLS.md](TLS.md) file for more information on
144+
how to use Redis with TLS.
145+
128146
Playing with Redis
129147
------------------
130148

@@ -406,7 +424,7 @@ replicas, or to continue the replication after a disconnection.
406424
Other C files
407425
---
408426

409-
* `t_hash.c`, `t_list.c`, `t_set.c`, `t_string.c` and `t_zset.c` contains the implementation of the Redis data types. They implement both an API to access a given data type, and the client commands implementations for these data types.
427+
* `t_hash.c`, `t_list.c`, `t_set.c`, `t_string.c`, `t_zset.c` and `t_stream.c` contains the implementation of the Redis data types. They implement both an API to access a given data type, and the client commands implementations for these data types.
410428
* `ae.c` implements the Redis event loop, it's a self contained library which is simple to read and understand.
411429
* `sds.c` is the Redis string library, check http://github.com/antirez/sds for more information.
412430
* `anet.c` is a library to use POSIX networking in a simpler way compared to the raw interface exposed by the kernel.

TLS.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
TLS Support
2+
===========
3+
4+
Getting Started
5+
---------------
6+
7+
### Building
8+
9+
To build with TLS support you'll need OpenSSL development libraries (e.g.
10+
libssl-dev on Debian/Ubuntu).
11+
12+
Run `make BUILD_TLS=yes`.
13+
14+
### Tests
15+
16+
To run Redis test suite with TLS, you'll need TLS support for TCL (i.e.
17+
`tcl-tls` package on Debian/Ubuntu).
18+
19+
1. Run `./utils/gen-test-certs.sh` to generate a root CA and a server
20+
certificate.
21+
22+
2. Run `./runtest --tls` or `./runtest-cluster --tls` to run Redis and Redis
23+
Cluster tests in TLS mode.
24+
25+
### Running manually
26+
27+
To manually run a Redis server with TLS mode (assuming `gen-test-certs.sh` was
28+
invoked so sample certificates/keys are available):
29+
30+
./src/redis-server --tls-port 6379 --port 0 \
31+
--tls-cert-file ./tests/tls/redis.crt \
32+
--tls-key-file ./tests/tls/redis.key \
33+
--tls-ca-cert-file ./tests/tls/ca.crt
34+
35+
To connect to this Redis server with `redis-cli`:
36+
37+
./src/redis-cli --tls \
38+
--cert ./tests/tls/redis.crt \
39+
--key ./tests/tls/redis.key \
40+
--cacert ./tests/tls/ca.crt
41+
42+
This will disable TCP and enable TLS on port 6379. It's also possible to have
43+
both TCP and TLS available, but you'll need to assign different ports.
44+
45+
To make a Replica connect to the master using TLS, use `--tls-replication yes`,
46+
and to make Redis Cluster use TLS across nodes use `--tls-cluster yes`.
47+
48+
Connections
49+
-----------
50+
51+
All socket operations now go through a connection abstraction layer that hides
52+
I/O and read/write event handling from the caller.
53+
54+
**Multi-threading I/O is not currently supported for TLS**, as a TLS connection
55+
needs to do its own manipulation of AE events which is not thread safe. The
56+
solution is probably to manage independent AE loops for I/O threads and longer
57+
term association of connections with threads. This may potentially improve
58+
overall performance as well.
59+
60+
Sync IO for TLS is currently implemented in a hackish way, i.e. making the
61+
socket blocking and configuring socket-level timeout. This means the timeout
62+
value may not be so accurate, and there would be a lot of syscall overhead.
63+
However I believe that getting rid of syncio completely in favor of pure async
64+
work is probably a better move than trying to fix that. For replication it would
65+
probably not be so hard. For cluster keys migration it might be more difficult,
66+
but there are probably other good reasons to improve that part anyway.
67+
68+
To-Do List
69+
----------
70+
71+
- [ ] Add session caching support. Check if/how it's handled by clients to
72+
assess how useful/important it is.
73+
- [ ] redis-benchmark support. The current implementation is a mix of using
74+
hiredis for parsing and basic networking (establishing connections), but
75+
directly manipulating sockets for most actions. This will need to be cleaned
76+
up for proper TLS support. The best approach is probably to migrate to hiredis
77+
async mode.
78+
- [ ] redis-cli `--slave` and `--rdb` support.
79+
80+
Multi-port
81+
----------
82+
83+
Consider the implications of allowing TLS to be configured on a separate port,
84+
making Redis listening on multiple ports:
85+
86+
1. Startup banner port notification
87+
2. Proctitle
88+
3. How slaves announce themselves
89+
4. Cluster bus port calculation

deps/Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ distclean:
4141

4242
.PHONY: distclean
4343

44+
ifeq ($(BUILD_TLS),yes)
45+
HIREDIS_MAKE_FLAGS = USE_SSL=1
46+
endif
47+
4448
hiredis: .make-prerequisites
4549
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
46-
cd hiredis && $(MAKE) static
50+
cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS)
4751

4852
.PHONY: hiredis
4953

deps/hiredis/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/*.dylib
66
/*.a
77
/*.pc
8+
*.dSYM

deps/hiredis/.travis.yml

+63-11
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,72 @@ addons:
2626
- libc6-dev-i386
2727
- libc6-dbg:i386
2828
- gcc-multilib
29+
- g++-multilib
2930
- valgrind
3031

3132
env:
32-
- CFLAGS="-Werror"
33-
- PRE="valgrind --track-origins=yes --leak-check=full"
34-
- TARGET="32bit" TARGET_VARS="32bit-vars" CFLAGS="-Werror"
35-
- TARGET="32bit" TARGET_VARS="32bit-vars" PRE="valgrind --track-origins=yes --leak-check=full"
33+
- BITS="32"
34+
- BITS="64"
3635

37-
matrix:
38-
exclude:
39-
- os: osx
40-
env: PRE="valgrind --track-origins=yes --leak-check=full"
36+
script:
37+
- EXTRA_CMAKE_OPTS="-DENABLE_EXAMPLES:BOOL=ON -DHIREDIS_SSL:BOOL=ON";
38+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
39+
if [ "$BITS" == "32" ]; then
40+
CFLAGS="-m32 -Werror";
41+
CXXFLAGS="-m32 -Werror";
42+
LDFLAGS="-m32";
43+
EXTRA_CMAKE_OPTS=;
44+
else
45+
CFLAGS="-Werror";
46+
CXXFLAGS="-Werror";
47+
fi;
48+
else
49+
TEST_PREFIX="valgrind --track-origins=yes --leak-check=full";
50+
if [ "$BITS" == "32" ]; then
51+
CFLAGS="-m32 -Werror";
52+
CXXFLAGS="-m32 -Werror";
53+
LDFLAGS="-m32";
54+
EXTRA_CMAKE_OPTS=;
55+
else
56+
CFLAGS="-Werror";
57+
CXXFLAGS="-Werror";
58+
fi;
59+
fi;
60+
export CFLAGS CXXFLAGS LDFLAGS TEST_PREFIX EXTRA_CMAKE_OPTS
61+
- mkdir build/ && cd build/
62+
- cmake .. ${EXTRA_CMAKE_OPTS}
63+
- make VERBOSE=1
64+
- ctest -V
4165

42-
- os: osx
43-
env: TARGET="32bit" TARGET_VARS="32bit-vars" PRE="valgrind --track-origins=yes --leak-check=full"
66+
matrix:
67+
include:
68+
# Windows MinGW cross compile on Linux
69+
- os: linux
70+
dist: xenial
71+
compiler: mingw
72+
addons:
73+
apt:
74+
packages:
75+
- ninja-build
76+
- gcc-mingw-w64-x86-64
77+
- g++-mingw-w64-x86-64
78+
script:
79+
- mkdir build && cd build
80+
- CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_WITH_INSTALL_RPATH=on
81+
- ninja -v
4482

45-
script: make $TARGET CFLAGS="$CFLAGS" && make check PRE="$PRE" && make $TARGET_VARS hiredis-example
83+
# Windows MSVC 2017
84+
- os: windows
85+
compiler: msvc
86+
env:
87+
- MATRIX_EVAL="CC=cl.exe && CXX=cl.exe"
88+
before_install:
89+
- eval "${MATRIX_EVAL}"
90+
install:
91+
- choco install ninja
92+
script:
93+
- mkdir build && cd build
94+
- cmd.exe /C '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 &&
95+
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release &&
96+
ninja -v'
97+
- ctest -V

deps/hiredis/CHANGELOG.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
compare to other values, casting might be necessary or can be removed, if
1313
casting was applied before.
1414

15+
### 0.x.x (unreleased)
16+
**BREAKING CHANGES**:
17+
18+
* Change `redisReply.len` to `size_t`, as it denotes the the size of a string
19+
20+
User code should compare this to `size_t` values as well.
21+
If it was used to compare to other values, casting might be necessary or can be removed, if casting was applied before.
22+
23+
* `redisReplyObjectFunctions.createArray` now takes `size_t` for its length parameter.
24+
1525
### 0.14.0 (2018-09-25)
1626

1727
* Make string2ll static to fix conflict with Redis (Tom Lee [c3188b])
@@ -50,8 +60,9 @@
5060
* Import latest upstream sds. This breaks applications that are linked against the old hiredis v0.13
5161
* Fix warnings, when compiled with -Wshadow
5262
* Make hiredis compile in Cygwin on Windows, now CI-tested
53-
54-
**BREAKING CHANGES**:
63+
* Bulk and multi-bulk lengths less than -1 or greater than `LLONG_MAX` are now
64+
protocol errors. This is consistent with the RESP specification. On 32-bit
65+
platforms, the upper bound is lowered to `SIZE_MAX`.
5566

5667
* Remove backwards compatibility macro's
5768

0 commit comments

Comments
 (0)