Commit Graph

1011 Commits (master)

Author SHA1 Message Date
Kristján Valur Jónsson 1343988cee Fix typos 2022-06-26 14:42:08 -07:00
Kristján Valur Jónsson 47b57aa243 Add some documentation on connect/disconnect callbacks and command callbacks 2022-06-26 14:42:02 -07:00
Michael Grunder a890d9ce20
Merge pull request #1073 from michael-grunder/kristjanvalur-pr1
Fix async connect on Windows
2022-06-26 14:23:12 -07:00
michael-grunder f246ee433d Whitespace, style 2022-06-26 14:14:58 -07:00
Kristján Valur Jónsson 94c1985bde Use correct type for getsockopt() 2022-06-26 13:19:40 -07:00
Kristján Valur Jónsson 5e002bc21c Support failed async connects on windows. 2022-06-26 13:19:33 -07:00
Michael Grunder 5d68ad2f48
Merge pull request #1072 from michael-grunder/fix-redis7-unit-tests
Fix tests so they work for Redis 7.0
2022-06-26 12:18:54 -07:00
michael-grunder f4b6ed2898 Fix tests so they work for Redis 7.0
* Redis >= 7.0.0 disables the `DEBUG` command by default, which we need
  for our unit tests.

* Downgrade to Redis 6.2.x in macOS temporarily

  There is a macOS specific TLS error on large payloads when running
  against 7.x.x so temporarily run our tests against 6.2, while we
  investigate the root cause.
2022-06-26 12:03:50 -07:00
Michael Grunder 95a0c1283a
Merge pull request #1058 from orgads/win64
Fix warnings on Win64
2022-05-04 12:22:29 -07:00
Orgad Shaneh eedb37a65d Fix warnings on Win64
read.c:399:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  399 |                     obj = (void*)(long)cur->type;
      |                           ^
2022-04-24 13:12:30 +03:00
Michael Grunder 47c3ecefc0
Merge pull request #1062 from yossigo/fix-push-notification-order
Handle push notifications before or after reply.
2022-04-23 14:31:09 -07:00
Michael Grunder e23d91c97b
Merge pull request #1061 from yossigo/update-redis-apt
Use official repository for redis package.
2022-04-23 14:21:22 -07:00
Michael Grunder 34211ad542
Merge pull request #1063 from redis/fix-windows-tests
Whitelist hiredis repo path in cygwin
2022-04-23 13:40:10 -07:00
michael-grunder 9957af7e3c Whitelist hiredis repo path in cygwin 2022-04-23 13:25:57 -07:00
Yossi Gottlieb b455b33818 Handle push notifications before or after reply. 2022-04-22 15:35:55 +03:00
Yossi Gottlieb aed9ce4462 Use official repository for redis package. 2022-04-22 15:20:04 +03:00
Michael Grunder d7683f35aa
Merge pull request #1047 from Nordix/unsubscribe-handling
Unsubscribe handling in async
2022-04-05 13:00:54 -07:00
Michael Grunder 7c44a9d7ec
Merge pull request #1045 from Nordix/sds-updates
Update hiredis sds with improvements found in redis
2022-04-05 12:55:25 -07:00
Orgad Shaneh dd4bf97836 Use the same name for static and shared libraries
On all system except MSVC, the targets are different.

Unix: libhiredis.so, libhiredis.a
MinGW: libhiredis.dll+libhiredis.dll.a, libhiredis.a
MSVC: hiredis.dll+hiredis.lib, hiredis_static.lib
2022-03-29 17:19:52 +03:00
Kristján Valur Jónsson ff57c18b9e Embed debug information in windows static lib, rather than create a .pdb file
Using .pdb files with .lib files on windows is very inconvenient, particularly if the .lib
file is then linked as part of a different .dll.  Chances are that the original .pdb
will not be picked up or distributed along with the tooling.
2022-03-24 14:41:22 +00:00
smmir-cent 8310ad4f5c fix cmake version 2022-03-18 20:27:01 +00:00
Björn Svensson 7123b87f6d Handle any pipelined unsubscribe in async
Redis responds to an unsubscribe with one or many replies, depending
on the current subscribe state. When channels/patterns names are
provided in a command each given name will trigger a reply even if
duplicated or not subscribed to.
To know when we can return from the subscribed state we need to do
bookkeeping on pending additional unsubscribe replies, and make sure
we receive them all before switching state.
2022-02-03 09:26:01 +01:00
Björn Svensson b6fb548fc6 Ignore pubsub replies without a channel/pattern 2022-02-02 23:43:21 +01:00
Björn Svensson 00b82683bb Handle overflows as errors instead of asserting 2022-02-02 10:44:52 +01:00
Björn Svensson 64062a1d40 Catch size_t overflows in sds.c
Equivalent changes introduced to redis sds.c via:
https://github.com/redis/redis/pull/8522
https://github.com/redis/redis/pull/9584
2022-02-01 18:34:38 +01:00
Björn Svensson 066c6de79e Use size_t/long to avoid truncation
Equivalent changes introduced to redis sds.c via:
https://github.com/redis/redis/pull/4568
2022-02-01 18:34:38 +01:00
Michael Grunder f8de9a4bd4
Merge pull request #1046 from redis/rockylinux-ci
CentOS 8 is EOL, switch to RockyLinux
2022-02-01 09:10:30 -08:00
michael-grunder a41c9bc8b7 CentOS 8 is EOL, switch to RockyLinux 2022-02-01 08:57:37 -08:00
Bjorn Svensson be41ed60d7
Avoid incorrect call to the previous reply's callback (#1040)
* No reuse of the previous reply callback

When multiple replies are parsed from a socket in one read
a previously found callback might get reused when the current
reply has no known callback.

This can be triggered by the added testcase which unsubscribe to
subscribed (A,B) and a non-subscribed channel (X).
Without this correction a callback for wrong channel is called.
-  In 'unsubscribe B X A', B's callback is called when handling X.
-  Now this is not done, i.e. there is no callback called for X.

* Re-push monitor callback for each reply

MONITORING used the same callback for all replies while parsing
multiple responses. This handling was changed to avoid calling
the wrong callback in some scenarios.
Now also change monitorings repush to work with this change.

Includes an added async monitoring testcase.
2022-01-27 18:30:58 -08:00
Dietmar Scheidl f2e8010d95 fix building on AIX and SunOS (#1031) 2022-01-24 12:12:19 -08:00
MichaelSuen e73ab2f232
Add timeout support for libuv adapter (#1016)
Add timeout to libuv adapter

Co-authored-by: sunmingqi <sunmingqi@corp.netease.com>
Co-authored-by: sunmingqi <smq222@126.com>
Co-authored-by: Michael Grunder <michael.grunder@gmail.com>
Co-authored-by: Viktor Söderqvist <viktor@zuiderkwast.se>
2022-01-18 10:59:18 -08:00
Bjorn Svensson f2ce5980e6
Allow sending commands after sending an unsubscribe (#1036)
* Add test of async commands after unsubscribe

Verify that commands are handled after unsubscribing from a channel.
A command is sent before the `unsubscribe` response is received,
which currently triggers an assert in async.c:567:

`redisProcessCallbacks: Assertion `(c->flags & REDIS_SUBSCRIBED || c->flags & REDIS_MONITORING)' failed.`

* Handle async commands after an unsubscribe

When unsubscribing from the last channel we move from the `subscribe`
state to a normal state. These states uses different holders for the
command callback information.
By moving the callback info during the state change the callback order
can be maintained.
2022-01-18 10:09:38 -08:00
Bjorn Svensson ff860e55db
Correction for command timeout during pubsub (#1038)
* Add test of command timeout during pubsub

A timeout of a non-subscribe command will be ignored during pubsub.
It will be handled as an idle timeout and a response is awaited for.

* Correction for command timeout during pubsub

Disconnect when a sent non-subscribe command triggers a timeout.
2022-01-11 10:19:43 -08:00
Fabrice Fontaine 24d5344934
CMakeLists.txt: allow building without a C++ compiler (#872)
Define hiredis as a C project (and use a single PROJECT statement) to
avoid the following build failure if a C++ compiler is not found:

CMake Error at CMakeLists.txt:3 (PROJECT):
  The CMAKE_CXX_COMPILER:

    /srv/storage/autobuild/run/instance-1/output-1/host/bin/arm-linux-g++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

The only cpp source file is examples/example-qt.cpp which is never
compiled with cmake buildsystem. This file is compiled only with the
Makefile buildsystem so perhaps it should be removed. If it is added to
the cmake buildsystem, a call to enable_language(CXX) will have to be
added.

Fixes:
 - http://autobuild.buildroot.org/results/830ec3398cd29b9fc5cde06a225ef531d7a9d850

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-01-08 18:57:13 -08:00
Peter Tummillo 4ece9a02ed
Fix adapters/libevent.h compilation for 64-bit Windows (#937)
Where SOCKET is a 64-bit unsigned integer.
2022-01-05 10:43:51 -08:00
michael-grunder 799edfaadf Don't link with crypto libs if USE_SSL isn't set. 2021-12-24 11:13:28 -08:00
zhenwei pi f74b08182c Makefile: move SSL options into a block and refine rules
Move SSL options into two blocks to make it easy to read:
  1, first part: SSL variables part
  1, second part: SSL building rules part
and change global rules to make it easy to maintain. For the further
step, it gets extensible to add another type.

New version of the library building rule:
	static: $(STLIBNAME) $(SSL_STLIB)
	dynamic: $(DYLIBNAME) $(SSL_DYLIB)

Compare with the orignal version:
	dynamic: $(DYLIBNAME)
	static: $(STLIBNAME)
	ifeq ($(USE_SSL),1)
	dynamic: $(SSL_DYLIBNAME)
	static: $(SSL_STLIBNAME)
	endif

If we want to add a new type(Ex, RDMA), for the new version, we can
do like this:
	########### RDMA variables start ###############
	.....
	########### RDMA variables end   ###############

	static: $(STLIBNAME) $(SSL_STLIB) $(RDMA_STLIB)
	dynamic: $(DYLIBNAME) $(SSL_DYLIB) $(RDMA_DYLIB)

	########### RDMA building rules start ###############
	.....
	########### RDMA building rules end   ###############

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2021-12-23 17:26:35 +08:00
Eric Deng f347743b7d
Update CMakeLists.txt for more portability (#1005)
add alias hiredis::hiredis and hiredis::hiredis_static so when this project is FetchContent, it behave the same as find_package-ed.
e.g.
```
find_package(hiredis 1.0.2 QUIET)
if (NOT hiredis_FOUND)
    FetchContent_Declare(
            hiredis
            GIT_REPOSITORY https://github.com/redis/hiredis.git
            GIT_TAG v1.0.2
    )
    FetchContent_MakeAvailable(hiredis)
endif ()
# later
target_link_libraries(target **hiredis::hiredis**) #can always use hiredis::hiredis to ref to this project. no matter find_package or FetchContent
```
this is actually sort of best practice when making a CMake lib.
2021-12-22 10:47:03 -08:00
sundb f2be748024
Fix integer overflow when format command larger than 4GB (#1030) 2021-12-22 10:45:52 -08:00
Bjorn Svensson 58aacdac65
Handle array response in parallell with pubsub using RESP3 (#1014)
RESP3 allows sending commands in parallell with pubsub handling
and these commands might get responded with a REDIS_REPLY_ARRAY.
This conflicts with the pubsub response handling for RESP2 and
results in a faulty state when using RESP3.

Add functionality to keep track of PUSH/RESP3 support on the connection
and only expect the message type REDIS_REPLY_PUSH as subscribe messages
when once seen.
2021-12-22 10:44:29 -08:00
Bjorn Svensson d3384260e7
Support PING while subscribing (RESP2) (#1027)
* Handle PING during pubsub in RESP2

* Rename invalid callback list

Some commands are valid to send during a subscribe in RESP2, and
most in RESP3. Renaming the callback list from `invalid` to `replies`
to detail this fact.

* Fix review comment
2021-12-16 12:38:15 -08:00
Michael Grunder e3a479e409
FreeBSD build fixes + CI (#1026)
* BSD linkage fix proposal

* Touch up the Makefile to fix BSD builds

Fixes #984

* Add a build in FreeBSD to GitHub Actions

Lots of people use hiredis in FreeBSD so this should reduce some pain
moving forward.

Co-authored-by: David Carlier <devnexen@gmail.com>
2021-12-16 12:36:05 -08:00
sundb c6657ef65b
Merge branch 'redis:master' into master 2021-12-16 17:42:58 +08:00
Bjorn Svensson da5a4ff362
Add asynchronous test for pubsub using RESP3 (#1012)
* Include `unsubscribe` as a subscribe reply in RESP3

By providing the (p)unsubscribe message via the subscribe callback,
instead of via the push callback, we get the same behavior in RESP3
as in RESP2.

* Add asynchronous test for pubsub using RESP3

The testcase will subscribe to a channel, and via a second client
a message is published to the channel. After receiving the message
the testcase will unsubscribe and disconnect.

This RESP3 testcase reuses the subscribe callback from the RESP2
testcase to make sure we have a common behavior.
2021-12-01 11:43:23 -08:00
Bjorn Svensson b5716ee829
Valgrind returns error exit code when errors found (#1011)
By default Valgrind will return the exit code from the tested process.
Since our test can return 0 (ALL TESTS PASS) even when a leak was
found we need to tell Valgrind to return an error code.
This will fail the CI job when issues are found.
2021-11-24 23:09:23 -08:00
Michael Grunder 1aed21a8c5
Move to using make directly in Cygwin (#1020)
CMake started hanging when trying to detect the C compiler ABI in cygin,
so for now just build with make directly.
2021-11-18 13:50:09 -08:00
Björn Svensson a83f4b8905 Correct CMake warning for libevent adapter example 2021-11-18 09:14:39 -08:00
Björn Svensson c4333203e3 Remove unused parameter warning in libev adapter
A warning in `redisLibevTimeout(..)` is triggered when building the
libev adapter with Clang using -Wextra/-Wunused-parameter.
Works fine with gcc..
2021-11-18 09:14:39 -08:00
michael-grunder 7ad38dc4a8 Small tweaks of the async tests 2021-11-17 14:37:27 -08:00
Pei-Hsuan Hung 50cdcab49d Fix potential fault at createDoubleObject
Resolves #963.

Add additional check to `hi_malloc` for `r->str` when len equals to
SIZE_MAX.
2021-11-01 12:17:05 +08:00