Commit Graph

144 Commits

Author SHA1 Message Date
michael-grunder d5b4c69b71 Prepare for v1.0.0 GA 2020-08-03 11:18:07 -07:00
michael-grunder a853467542 Update notes preparing for v1.0.0-rc1 2020-07-29 13:39:28 -07:00
Michael Grunder d8ff72387d
Move SSL management to a distinct private pointer. (#855)
We need to allow our users to use redisContext->privdata as context
for any RESP3 PUSH messages, which means we can't use it for managing
SSL connections.

Bulletpoints:

* Create a secondary redisContext member for internal use only called
  privctx and rename the redisContextFuncs->free_privdata accordingly.

* Adds a `free_privdata` function pointer so the user can tie allocated
  memory to the lifetime of a redisContext (like they can already do
  with redisAsyncContext)

* Enables SSL tests in .travis.yml
2020-07-29 11:53:03 -07:00
Michael Grunder be32bcdc8e
Minor refactor for scheduling an async timer. (#854)
Small change to the logic introduced in #839
2020-07-26 13:03:42 -07:00
valentinogeron 38b5ae543f
add a command_timeout to redisContextOptions (#839)
Add an additional timeout so the user has a convenient way of controlling distinct connect and command timeouts
2020-07-26 12:32:27 -07:00
Michael Grunder 2e7d7cbabd
Resp3 oob push support (#841)
Proper support for RESP3 PUSH messages.

By default, PUSH messages are now intercepted and the reply memory freed.  
This means existing code should work unchanged when connecting to Redis
>= 6.0.0 even if `CLIENT TRACKING` were then enabled.

Additionally, we define two callbacks users can configure if they wish to handle
these messages in a custom way:

void redisPushFn(void *privdata, void *reply);
void redisAsyncPushFn(redisAsyncContext *ac, void *reply);

See #825
2020-07-19 18:54:42 -07:00
Michael Grunder 6448f735d5
sdsrange overflow fix (#830)
Fix overflow bug in `sdsrange`
2020-06-07 14:38:16 -07:00
Michael Grunder 5c9f49e212
Resp3 verbatim string support (#805)
Pull RESP3 verbatim string handling from Redis

Fixes #802
2020-05-19 12:56:02 -07:00
michael-grunder 139f966cc8 Bump version to 0.15.0 2020-02-28 11:04:52 -08:00
Michael Grunder 669ac9d0c8
Safe allocation wrappers (#754)
Create allocation wrappers with a configurable OOM handler (defaults to abort()).

See #752, #747
2020-01-28 12:13:05 -08:00
ShooterIT 386b9950f3 fix spelling mistakes 2020-01-01 14:42:10 +08:00
Yossi Gottlieb 5c85a04164 Use a const funcs in redisContext. 2019-09-01 13:46:07 +03:00
Yossi Gottlieb 8715ba5c82 wip: SSL code reorganization, see #705. 2019-08-29 22:09:37 +03:00
Mark Nunberg ff4fa45422
Merge pull request #697 from yossigo/resp3
Port RESP3 support from Redis.
2019-08-27 06:59:32 -04:00
Marcus Geelnard 85fee25653 MinGW fix: Use _MSC_VER instead of _WIN32 where appropriate
Use _MSC_VER (instead of _WIN32) for things that are specific for
Visual Studio.

Also remove #include <winsock2.h> from hiredis.h, as it leaks too
many symbols and defines into the global namespace, which is
undesirable for a public interface header. Anyone who uses the
the affected parts of the hiredis API needs to include the
appropriate headers anyway in order to declare struct timeval
variables.
2019-08-09 11:49:02 +02:00
Yossi Gottlieb 91de9c975a RESP3 support changes from Redis.
This corresponds to commits d5c54f0b..bea09a7f in the redis repository.
2019-08-04 12:13:04 +03:00
jinjiazhang cdb836d5f8 Fix Compile Error On Windows (Visual Studio) 2019-04-13 10:38:34 +08:00
m dc6d19b9ec Port network layer to Winsock
With this change, Hiredis builds with MinGW and runs on Windows.
2019-04-01 11:54:37 +02:00
m e84086cb92 Introduce a redisFD type
The redisFD type should be equal to the system native socket file
desciptor type (for POSIX, this is a plain int).

We also introduce the REDIS_INVALID_FD value, which maps to -1 on POSIX
systems.
2019-04-01 11:52:24 +02:00
Mark Nunberg 5eb6958870 Allow option for async connections to not automatically free 2019-02-21 11:49:25 -05:00
valentino 58222c26f4 Support SNI 2019-02-20 09:10:10 -05:00
Mark Nunberg 53d9b12b76 Fix bug in options macro 2019-02-20 09:10:10 -05:00
Mark Nunberg e4a78006e7 Provide option-struct initialization
This reduces the boilerplate of all the redisConnectXXX functions, and
allows us to provide more connection options in the future.
2019-02-20 09:10:10 -05:00
Mark Nunberg 0c14544906 Initial SSL (sync) implementation 2019-02-20 09:10:10 -05:00
Mark Nunberg 49974c9359 Call connect(2) again for non-blocking connect
This retrieves the actual error which occurred, as getsockopt is not
always reliable in this regard.
2018-09-25 20:21:37 -04:00
Tom Lee 29c82b728c Prepare for the 0.14.0 release
SONAME bumped to 0.14 because we've broken ABI compatibility with 0.13.x
2018-09-25 15:48:07 -07:00
Justin Brewer d1c1b668c1 Drop __redis_strerror_r
Since _GNU_SOURCE is now guaranteed to be unset, it is no longer
necessary to support the GNU-specific version of strerror_r.

Drop __redis_strerror_r from the header, and call strerror_r directly.
This breaks any external users of this macro, but they shouldn't have
been using it in  the first place.

Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
2018-04-30 21:45:13 -05:00
Ichito Nagata 2ec7740c3a suppress gcc complaint 2017-03-22 17:03:52 +09:00
Donald Whyte 41b07dab5e Remove trailing comma in redisConnectionType enum
Remove trailing comma in last value of `redisConnectionType` enum. This causes a compiler warning on Solaris compilers. I'd like to build this on Solaris with `-Werror`. However, due to the trailing comma, I cannot do that.

This PR removes the trailing comma, which should prevent it causing compiler warnings on any architecture.
2016-10-25 09:25:24 +01:00
Jan-Erik Rediger 97ac0d1f50 fix: Change string length type to size_t 2016-04-20 17:00:14 +02:00
not-a-robot 36bddcf6ed Auto merge of #391 - redis:catch-error-buf-overflow, r=badboy
Prevent buffer overflow when formatting the error

strncat might copy n+1 bytes (n bytes from the source plus a terminating nul byte).
Also strncat appends after the first found nul byte. But all we pass is
a buffer we might not have zeroed out already.

Closes #380
2016-04-20 15:31:23 +02:00
Jan-Erik Rediger 0335cb3e98 Prevent buffer overflow when formatting the error
strncat might copy n+1 bytes (n bytes from the source plus a terminating nul byte).
Also strncat appends after the first found nul byte. But all we pass is
a buffer we might not have zeroed out already.

Closes #380
2015-11-18 14:37:47 +01:00
charsyam e2f6ee239c fixing typos 2015-10-28 02:19:24 +09:00
Jan-Erik Rediger 010756025e Release version 0.13.3 2015-09-16 12:25:02 +02:00
Jan-Erik Rediger 53c32439bf Release version 0.13.2 2015-08-25 14:16:20 +02:00
Jan-Erik Rediger 9644a96a48 Use stable soname version 2015-07-27 22:14:03 +02:00
Jan-Erik Rediger f58dd249d6 Release version 0.13.1 2015-05-03 22:58:11 +02:00
Alex Balashov d132d676e9 Renamed redisContext struct member 'unix' to 'unix_sock' to avoid encountering defined constant 'unix' in GNU C environment (see commit d8145d79ce).
Not all code using hiredis can compile using '-std=c99', and/or not all users are able to easily make that change to the build process of various open-source projects, so it is more pragmatic to choose a different identifier that does not impose this requirement.
2015-04-30 15:01:31 -04:00
Jan-Erik Rediger 31436c33ac Release version 0.13.0 2015-04-16 21:30:43 +02:00
Jan-Erik Rediger af598dbce5 Change copyright date and add copyright holder 2015-04-16 21:29:41 +02:00
Jan-Erik Rediger b676007253 Document reconnect method 2015-04-16 21:01:00 +02:00
Jan-Erik Rediger d9e0b0f6ab Implement a reconnect method for the client context
Originally implemented by @abedra as part of #306.

In case a write or read times out, we force an error state, because we
can't guarantuee that the next read will get the right data.
Instead we need to reconnect to have a clean-state connection, which is
now easily possible with this method.
2015-04-16 21:00:30 +02:00
Matt Stancliff 9be3a07d8a Release hiredis 0.12.1
Major fix:
  - `make install` now works properly

Minor fix:
  - `make test` now works after `make 32bit` on a 64-bit platform
  - added more automated travis tests
2015-01-26 10:08:40 -05:00
Matt Stancliff 7b51834c16 Increase version to 0.12.0 2015-01-22 16:00:38 -05:00
Matt Stancliff 195aca3427 Improve digit counting for multibulk creation
This replaces the old intlen() implementation with a slightly
faster way of counting digits.

Implementation taken from the same place where digits10() in
redis/src/util.c came from.

The old 'intlen' allowed negative inputs, but no usage in hiredis
was passing negative numbers, so that ability is removed.  Also,
the new implementation can count higher (uint64_t) instead of
limited to just int as before.

Fixes #295 by replacing implementation
2015-01-22 16:00:38 -05:00
Matt Stancliff cc20232406 Fix errno error buffers to not clobber errors
The strerror_r API has two flavors depending on system options.

The bad flavor uses a static buffer for returning results, so if
you save the pointer from strerror_r, the string you're referencing
becomes useless if anybody else calls strerror_r again

The good flavor does what you expect: it writes the error to your buffer.

This commit uses strerror_r directly if it's a good version or copies
the static buffer into our private buffer if it's a bad version.

Thanks to gemorin for explaining the problem and drafting a fix.

Fixes #239
2015-01-05 16:53:23 -05:00
tzickel ba3e74c408 Refactor reading code into read.c
Makes hiredis reading functions easier to include in external projects

[fixed all merge conflicts against current version]

Closes #249
2015-01-05 16:53:22 -05:00
Matt Stancliff 9a753b4251 Add API to free hiredis (sds) formattings
External callers may not know about sdsfree, so let's
give them an easy way to know how to free their sds result.
2015-01-05 16:39:30 -05:00
Mareq 1b392eb796 Add API to free hiredis (char *) formattings
[Cleaned up:
  - name of function: freeRedis... -> redisFree...
  - return value of function (free doesn't return anything)
  - parameter type for function.
    - we don't need to free a char**, the char** is just
    for returning from the assignment functoin.]

Closes #250
2015-01-05 16:39:30 -05:00
mike 7c4d2557c4 Add support for SO_REUSEADDR
[This introduces some new API functions.]

* Adds new flag to the connection context indicating SO_REUSEADDR
  should be set.
* Adds max number of retries constant for when connect() hits
  EADDRNOTAVAIL.
* Adds new function, redisAsyncConnectBindWithReuse(), letting
  clients enable this functionality.

[Removed trailing whitespace in new header lines.]

Closes #264
2015-01-05 16:39:30 -05:00