1. 07 Sep, 2022 1 commit
  2. 05 Sep, 2022 1 commit
    • Michael Grunder's avatar
      Fix protocol error (#1106) · 79ae5ffc
      Michael Grunder authored
      
      
      Fix ProtocolError
      
      This commit attempts to fix hiredis such that a recoverable write error
      will be retried rather than throwing a hard error.
      
      Since our read/write functions are now behind function pointers, we
      specify semantically that a return value of < 0 is a hard error, 0 a
      recoverable error, and > 0 a success.
      
      Our default `redisNetRead` function was already doing something similar
      so this also improves code consistency.
      
      Resolves #961
      Co-authored-by: default avatarMaksim Tuleika <maksim.tuleika@appcast.io>
      79ae5ffc
  3. 03 Sep, 2022 1 commit
    • Michael Grunder's avatar
      Use a windows specific keepalive function. (#1104) · 61b5b299
      Michael Grunder authored
      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
      61b5b299
  4. 01 Sep, 2022 1 commit
  5. 29 Aug, 2022 1 commit
  6. 26 Jun, 2022 3 commits
  7. 26 Jul, 2020 1 commit
  8. 22 Jun, 2020 1 commit
  9. 07 Jun, 2020 1 commit
  10. 22 May, 2020 1 commit
    • Michael Grunder's avatar
      Allow users to replace allocator and handle OOM everywhere. (#800) · 8e0264cf
      Michael Grunder authored
      * Adds an indirection to every allocation/deallocation to allow users to 
        plug in ones of their choosing (use custom functions, jemalloc, etc).
      
      * Gracefully handle OOM everywhere in hiredis.  This should make it possible
        for users of the library to have more flexibility in how they handle such situations.
      
      * Changes `redisReaderTask->elements` from an `int` to a `long long` to prevent
        a possible overflow when transferring the task elements into a `redisReply`.
      
      * Adds a configurable `max elements` member to `redisReader` that defaults to
        2^32 - 1.  This can be set to "unlimited" by setting the value to zero.
      8e0264cf
  11. 03 Apr, 2020 1 commit
    • Michael Grunder's avatar
      Win32 tests and timeout fix (#776) · cc9d0329
      Michael Grunder authored
      Unit tests in Windows and a Windows timeout fix
      
      This commit gets our unit tests compiling and running on Windows as well as removes a duplicated `timeval` -> `DWORD` conversion logic in sockcompat.c 
      
      There are minor differences in behavior between Linux and Windows to note:
      
      1.  In Windows, opening a non-existent hangs forever in WSAPoll whereas
          it correctly returns with a "Connection refused" error on Linux.
          For that reason, I simply skip this test in Windows.
      
          It may be related to this known issue:
          https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
      
      2.  Timeouts are handled slightly differently in Windows and Linux.  
          In Linux, we intentionally set REDIS_ERR_IO for connection
          timeouts whereas in Windows we set REDIS_ERR_TIMEOUT.  It may be
          prudent to fix this discrepancy although there are almost certainly
          users relying on the current behavior.
      cc9d0329
  12. 28 Jan, 2020 1 commit
  13. 12 Aug, 2019 2 commits
  14. 03 Jul, 2019 1 commit
  15. 01 Apr, 2019 4 commits
    • m's avatar
      Port network layer to Winsock · dc6d19b9
      m authored
      With this change, Hiredis builds with MinGW and runs on Windows.
      dc6d19b9
    • m's avatar
      Use recv/send instead of read/write · 1d092a23
      m authored
      The recv/send calls are more portable than read/write, since unlike the
      latter, the former work with Windows sockets.
      
      We also check for EWOULDBLOCK instead of EAGAIN. On most Unices, EAGAIN
      and EWOULDBLBOCK are the same thing. However, on Windows they are
      different, and send/recv are expected to give EWOULDBLOCK for
      non-blocking sockets.
      1d092a23
    • m's avatar
      Introduce a redisFD type · e84086cb
      m authored
      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.
      e84086cb
    • m's avatar
      Move network I/O calls to net.c · 1788f41f
      m authored
      This makes hiredis.c free from system calls related to socket I/O. This
      is also makes the treatment of raw socket connections more similar to
      the SSL backend.
      1788f41f
  16. 20 Feb, 2019 2 commits
  17. 28 Jan, 2019 1 commit
  18. 05 Dec, 2018 1 commit
  19. 26 Sep, 2018 3 commits
  20. 01 May, 2018 3 commits
  21. 28 Apr, 2018 2 commits
    • Justin Brewer's avatar
      Strip down fmacros.h · 49bbaacc
      Justin Brewer authored
      
      
      strerror_r and addrinfo require _POSIX_C_SOURCE >= 200112L,  which is
      implied by _XOPEN_SOURCE >= 600. With the removal of AF_LOCAL usage,
      the only non-standard features being used are the TCP_KEEP* socket
      flags. _DARWIN_C_SOURCE is required to expose TCP_KEEPALIVE.
      
      Fall back to using _XOPEN_SOURCE 600 for all platforms, and
      additionally define _DARWIN_C_SOURCE for Darwin.
      Signed-off-by: default avatarJustin Brewer <jzb0012@auburn.edu>
      49bbaacc
    • Justin Brewer's avatar
      Use AF_UNIX · bbeab800
      Justin Brewer authored
      
      
      AF_LOCAL is the old, non-standardized name for AF_UNIX. Just use
      AF_UNIX, rather than wrestling with platform specifics of AF_LOCAL
      definitions.
      Signed-off-by: default avatarJustin Brewer <jzb0012@auburn.edu>
      bbeab800
  22. 15 Jun, 2017 1 commit
  23. 15 May, 2017 1 commit
  24. 30 Dec, 2016 1 commit
  25. 07 Jul, 2016 1 commit
  26. 18 Nov, 2015 1 commit
    • Tom Lee's avatar
      Fix potential race in 'invalid timeout' tests · d4b715f0
      Tom Lee authored
      It's possible for the call to connect() to succeed on the very first
      try, in which case the logic for checking for invalid timeout fields is
      never executed. When this happens, the tests fail because they expect a
      REDIS_ERR_IO but no such failure has occurred.
      
      Tests aside, this is a potential source of irritating and hard-to-find
      intermittent bugs.
      
      This patch forces the validation to occur early so that we get
      predictable behavior whenever an invalid timeout is specified.
      d4b715f0
  27. 30 Apr, 2015 1 commit
    • Alex Balashov's avatar
      Renamed redisContext struct member 'unix' to 'unix_sock' to avoid encountering... · d132d676
      Alex Balashov authored
      Renamed redisContext struct member 'unix' to 'unix_sock' to avoid encountering defined constant 'unix' in GNU C environment (see commit d8145d79).
      
      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.
      d132d676
  28. 16 Apr, 2015 1 commit