1. 30 May, 2023 1 commit
  2. 29 May, 2023 1 commit
    • Viktor Söderqvist's avatar
      Helper for setting TCP_USER_TIMEOUT socket option (#1188) · b6a052fe
      Viktor Söderqvist authored
      * Implement redisSetTcpUserTimeout to set socket option TCP_USER_TIMEOUT
      
      * Documentation for redisSetTcpUserTimeout and some more undocumented functions
      
      Documentation for redisReconnect() and the setters of socket options:
      
      * redisKeepAlive()
      * redisEnableKeepAliveWithInterval()
      * redisSetTcpUserTimeout()
      b6a052fe
  3. 14 Oct, 2022 1 commit
    • Bjorn Svensson's avatar
      Fixup of PR734: Coverage of hiredis.c (#1124) · 3b15a04b
      Bjorn Svensson authored
      
      
      Improve coverage (#734)
      
      * Remove duplicate tests
      
      - double covered by:
        "Can parse RESP3 doubles"
      - bool covered via:
        "Can parse RESP3 bool"
      
      * Make (connect) timeout in test config general
      
      * Set error string in Unix connect with invalid timeout
      
      Restructure testcase since redisConnectWithTimeout() and
      redisConnectUnixWithTimeout() now behaves similar.
      
      * Use quiet flag in lcov/genhtml instead of piping to /dev/null
      
      * Fixup of redisCommandArgv test case
      
      * Update test case to match what it covers
      
      Use new test case info text since the previous one seemed copy&pasted.
      The sought coverage was the handling of the parent-chaining
      for a double object, which the test case now focuses on.
      Co-authored-by: default avatarAriel <ashtul@gmail.com>
      3b15a04b
  4. 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
  5. 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
  6. 01 Sep, 2022 1 commit
  7. 29 Aug, 2022 1 commit
  8. 26 Jun, 2022 3 commits
  9. 26 Jul, 2020 1 commit
  10. 22 Jun, 2020 1 commit
  11. 07 Jun, 2020 1 commit
  12. 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
  13. 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
  14. 28 Jan, 2020 1 commit
  15. 12 Aug, 2019 2 commits
  16. 03 Jul, 2019 1 commit
  17. 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
  18. 20 Feb, 2019 2 commits
  19. 28 Jan, 2019 1 commit
  20. 05 Dec, 2018 1 commit
  21. 26 Sep, 2018 3 commits
  22. 01 May, 2018 3 commits
  23. 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
  24. 15 Jun, 2017 1 commit
  25. 15 May, 2017 1 commit
  26. 30 Dec, 2016 1 commit
  27. 07 Jul, 2016 1 commit
  28. 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