Commit Graph

1011 Commits (master)

Author SHA1 Message Date
Michael Grunder 61b5b299f0
Use a windows specific keepalive function. (#1104)
Use a windows specific keepalive function.

While it is possible to toggle `TCP_KEEPALIVE` in windows via
setsockopt, you have to use `WSAIoctl` to set the interval.

Since `WSAIoctl` can actually do all of this in one call (toggle the
option, and set the corresponding interval), just use that in Windows
and avoid the call to `setsockopt` alltogether.

Fixes: #1100
2022-09-03 12:39:57 -07:00
zhenwei pi fce8abc1c1 Introduce .close method for redisContextFuncs
Currently, hiredis supports TCP/SSL/Unix, all of the connection types
use a single FD(int), close() is enough to close a connection. For the
further step, introduce .close method for redisContextFuncs, this
allows to close a complex connection context, for example RDMA.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2022-09-02 10:25:52 -07:00
Michael Grunder cfb6ca8811
Add REDIS_OPT_PREFER_UNSPEC (#1101)
Add REDIS_OPT_PREFER_UNSPEC

See: #1099, #1096

Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2022-09-02 09:57:18 -07:00
michael-grunder cc7c35ce60 Update documentation to explain redisConnectWithOptions.
Additionally document the new `REDIS_OPT_PREFER_IPV4`,
`REDIS_OPT_PREFER_IPV6` as well as the rest of our existing options.

See #1096
2022-09-01 18:40:12 -07:00
zhangtaoXT5 bc8d837b72
fix heap-buffer-overflow (#957)
Prevent incrementing passed a `\0` in our format string.

Co-authored-by: Michael Grunder <michael.grunder@gmail.com>
Co-authored-by: Kristján Valur Jónsson <sweskman@gmail.com>
2022-09-01 13:45:28 -07:00
Anton Tiurin ca4a0e850b uvadapter: reduce number of uv_poll_start calls
Internally uv_poll_start iterates over all
attached event handlers to update event mask. It's
quite expensive operation if there many event handlers attached
to a loop.
As redisLibuvEvents.events is a copy of what libuv should see,
we can rely on it to avoid event mask updates.

Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
2022-09-01 12:37:30 -07:00
Tongliang Liao 35d398c903 Fix cmake config path on Linux.
CMake config files were installed to `/usr/local/share/hiredis`, which is not recognizable by `find_package()`.
I'm not sure why it was set that way.
Given the commit introducing it is for Windows, I keep that behavior consistent there, but fix the rest.
2022-09-01 10:43:36 -07:00
Viktor Söderqvist 10c78c6e17 Add possibility to prefer IPv6, IPv4 or unspecified 2022-09-01 10:42:36 -07:00
Björn Svensson 1abe0c8285 fuzzer: No alloc in redisFormatCommand() when fail 2022-09-01 10:35:07 -07:00
Björn Svensson 329eaf9bae Fix heap-buffer-overflow issue in redisvFormatCommad
A command with a faulty formatting string that lacks the
conversion specifier results in a ASAN heap-buffer-overflow.
This was due to that strchr() matches on null-termination,
which triggers a continuation of the string parsing.
2022-09-01 10:35:07 -07:00
michael-grunder eaae7321c2 Polling adapter requires sockcompat.h
We need to install our socket compatibility header as the new polling
adapter needs it.
2022-09-01 00:50:23 -07:00
bugwz 0a5fa3ddee Regression test for off-by-one parsing error
See: #916
2022-08-31 09:42:10 -07:00
Pei-Hsuan Hung 9e174e8f7d Add do while(0) protection for macros
Wrapping multi-line macros in do...while(0) statement prevents
potential dangling else problem.
2022-08-30 11:41:59 -07:00
michael-grunder 4ad99c69a2 Rework asSleep to be a generic millisleep function. 2022-08-29 16:22:20 -07:00
Arseniy Simonov 75cb6c1ea6 Do store command timeout in the context for redisSetTimeout (#593) 2022-08-29 16:22:20 -07:00
Lipraxde c57cad658d CMake: remove dict.c form hiredis_sources
Commit c6b8bd77c0 to make all functions in dict.c static. If a CMake project set warning unused functions, and include hiredis using add_subdirectory , this cause warnings / errors.
2022-08-29 14:31:51 -07:00
Kristján Valur Jónsson 8491a65a95
Add Github Actions CI workflow for hiredis: Arm, Arm64, 386, windows. (#943)
* Add docker support to test.sh
specifying a REDIS_DOCKER env var will run this as a server.
* Add initial test workflow
* Add workflow test to test 32 bit build
* Add ARM x compilation tests
* Add tests for windows platform
* Test with valgrind
2022-08-29 14:30:08 -07:00
Michael Grunder 77e4f09ea8
Merge pull request #964 from afcidk/fix-createDoubleObject
Fix potential fault at createDoubleObject
2022-08-29 12:24:57 -07:00
Michael Grunder 9219f7e7c3
Merge pull request #901 from devnexen/illumos_test_fix
Illumos test fixes, error message difference fot bad hostname test.
2022-08-29 11:35:13 -07:00
Michael Grunder 810cc6104c
Merge pull request #905 from sundb/master
Remove semicolon after do-while in _EL_CLEANUP
2022-08-29 11:30:36 -07:00
Michael Grunder df8b74d69e
Merge pull request #1091 from redis/ssl-error-ub-fix
Fix some undefined behavior
2022-08-29 11:29:04 -07:00
jengab 0ed6cdec35 Fix some undefined behaviour
- redisSSLContextError must always be initialized at defintion,
  otherwise when SSL connect succeeds it may not be assigned to a valid error.
  Thus the memory trash remains in the variable, which may sign a misleading error.
2022-08-29 11:12:53 -07:00
Michael Grunder 507a6dcaa5
Merge pull request #1090 from Nordix/subscribe-oom-error
Copy OOM errors to redisAsyncContext when finding subscribe callback
2022-08-29 09:17:53 -07:00
Björn Svensson b044eaa6a7 Copy error to redisAsyncContext when finding subscribe cb 2022-08-29 13:34:27 +02:00
Michael Grunder e0200b797b
Merge pull request #1087 from redis/const-and-non-const-callback
Maintain backward compatibiliy withour onConnect callback.
2022-08-26 10:35:38 -07:00
michael-grunder 6a3e96ad21 Maintain backward compatibiliy withour onConnect callback.
In f69fac7690, our async onConnect
callback was improved to take a non-const redisAsyncContext allowing it
to be reentrant.

Unfortunately, this is a breaking change we can't make until hiredis
v2.0.0.

This commit creates a separate callback member and corresponding
function that allows us to use the new functionality, while maintaining
our existing API for legacy code.

Fixes #1086
2022-08-26 10:14:47 -07:00
Michael Grunder e7afd998f9
Merge pull request #1079 from SukkaW/drop-macos-10.15-runner
CI: bump macos runner version
2022-08-26 10:14:31 -07:00
Michael Grunder 17c8fe0798
Merge pull request #931 from kristjanvalur/pr2
Stability: Support calling redisAsyncCommand and redisAsyncDisconnect from the onConnected callback
2022-08-19 11:29:00 -07:00
Michael Grunder b808c0c206
Merge pull request #1083 from chayim/ck-drafter
Support for generating release notes
2022-08-17 12:22:33 -07:00
Michael Grunder 367a82bf02
Merge pull request #1085 from stanhu/ssl-improve-options-setting
Make it possible to set SSL verify mode
2022-08-15 17:19:51 -07:00
Stan Hu 71119a71d7
Make it possible to set SSL verify mode
If no SSL certificates are provided, many Redis clients default to
disabling SSL peer verification. Previously it was a bit cumbersome to
configure this because the client would either have to reimplement
`redisCreateSSLContext()` or reach into the internals to set the
OpenSSL verify mode.

We can improve the SSL API by introducing a
`redisCreateSSLContextWithOptions()` call that takes into structured
parameters for SSL initialization. This structure contains a verify
mode that is used to set the OpenSSL verify mode.

Relates to https://github.com/redis/hiredis/issues/646
2022-08-15 11:21:44 -07:00
Michael Grunder dd7979ac10
Merge pull request #1084 from stanhu/sh-improve-ssl-docs
Improve example for SSL initialization in README.md
2022-08-10 14:43:23 -07:00
Stan Hu c71116178b
Improve example for SSL initialization in README.md
The previous example left `ssl_error`
uninitialized. `redisCreateSSLContex` is not guaranteed to set this
when no error occurs.

Use the `REDIS_SSL_CTX_NONE` constant instead of 0 to be precise.
2022-08-10 00:38:33 -07:00
Chayim I. Kirshen 5c9b6b571e Release drafter 2022-08-10 09:40:30 +03:00
Sukka a606ccf2a5
CI: use recommended `vmactions/freebsd-vm@v0`
Co-authored-by: Bjorn Svensson <bjorn.a.svensson@est.tech>
2022-08-05 17:07:18 +08:00
Michael Grunder 0865c115ba
Merge pull request #1080 from Nordix/readme-corrections
Fix README typos
2022-08-04 09:18:26 -07:00
Björn Svensson f6cee7142c Fix README typos 2022-08-04 12:07:14 +02:00
Michael Grunder 06be7ff312
Merge pull request #1050 from smmir-cent/fix-cmake-version
fix cmake version
2022-07-31 14:54:13 -07:00
SukkaW 7dd833d544 CI: bump macos runner version 2022-07-25 13:43:19 +08:00
Kristján Valur Jónsson f69fac7690
Drop `const` on redisAsyncContext in redisConnectCallback
Since the callback is now re-entrant, it can call apis such as redisAsyncDisconnect()
2022-07-08 13:52:43 +00:00
Kristján Valur Jónsson 005d7edebe
Support calling redisAsyncDisconnect from the onConnected callback, by deferring context deletion 2022-07-08 13:52:22 +00:00
Kristján Valur Jónsson 6ed060920f
Add async regression test for issue #931 2022-07-08 13:52:22 +00:00
Michael Grunder eaa2a7ee77
Merge pull request #932 from kristjanvalur/pr3
Polling adapter and example
2022-07-07 11:43:19 -07:00
Kristján Valur Jónsson 2ccef30f3e Add regression test for issue #945 2022-07-05 11:17:30 +00:00
Kristján Valur Jónsson 4b901d44ad Initial async tests 2022-07-05 11:17:30 +00:00
Kristján Valur Jónsson 31c91408ef Polling adapter and example 2022-07-05 11:14:03 +00:00
Michael Grunder 8a15f4d657
Merge pull request #1057 from orgads/static-name
Use the same name for static and shared libraries
2022-06-26 16:49:19 -07:00
Michael Grunder 902dd047fe
Merge pull request #1054 from kristjanvalur/pr08
Embed debug information in windows static .lib file
2022-06-26 16:07:34 -07:00
Michael Grunder c78d0926bf
Merge pull request #1074 from michael-grunder/kristjanvalur-pr4
Improved async documentation
2022-06-26 15:42:00 -07:00
michael-grunder 2b115d56cd Whitespace 2022-06-26 14:42:31 -07:00