1. 20 Apr, 2022 1 commit
  2. 19 Dec, 2021 1 commit
    • Binbin's avatar
      Fix some nonsense came from LGTM (#9962) · 0fb1aa06
      Binbin authored
      1. Local variable 's' hides a parameter of the same name.
      ```
      int anetTcpAccept(char *err, int s, char *ip, size_t ip_len, int *port) {
          if ((fd = anetGenericAccept(err,s,(struct sockaddr*)&sa,&salen)) == ANET_ERR){}
      }
      ```
      Change the parameter name from `s` to `serversock`,
      also unified with the header file definition.
      
      2. Comparison is always false because i <= 48.
      ```
      for (i = 0; i < DICT_STATS_VECTLEN-1; i++) {  // i < 49
          (i == DICT_STATS_VECTLEN-1)?">= ":"",  // i == 49
      }
      ```
      `i == DICT_STATS_VECTLEN-1` always result false, it is a dead code.
      
      3. Empty block without comment.
      `else if (!strcasecmp(opt,"ch")) {}`, add a comment to avoid warnings.
      
      4. Bit field fill of type int should have explicitly unsigned integral, explicitly signed integral, or enumeration type.
      Modify `int fill: QL_FILL_BITS;` to `unsigned int fill: QL_FILL_BITS;`
      
      5. The result of this call to reconnectingRedisCommand is not checked for null, but 80% of calls to reconnectingRedisCommand check for null.
      Just a cleanup job like others.
      0fb1aa06
  3. 16 Dec, 2021 1 commit
  4. 06 Oct, 2021 1 commit
  5. 05 Jul, 2021 1 commit
    • Oran Agra's avatar
      Use accept4 on linux instead of fcntl to make a client socket non-blocking (#9177) · 5a3de819
      Oran Agra authored
      
      
      This reduces system calls on linux when a new connection is made / accepted.
      
      Changes:
      * Add the SOCK_CLOEXEC option to the accept4() call
        This  ensure that a fork/exec call does not leak a file descriptor.
      * Move anetCloexec and connNonBlock info anetGenericAccept
      * Moving connNonBlock from accept handlers to anetGenericAccept
      
      Moving connNonBlock from createClient, is safe because createClient is
      used in the following ways:
      1. without a connection (fake client)
      2. on an accepted connection (see above)
      3. creating the master client by using connConnect (see below)
      
      The third case, can either use anetTcpNonBlockConnect, or connTLSConnect
      which is by default non-blocking.
      Co-authored-by: default avatarRajiv Kurian <geetasen@gmail.com>
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      Co-authored-by: default avatarYoav Steinberg <yoav@redislabs.com>
      5a3de819
  6. 11 May, 2021 1 commit
  7. 21 Apr, 2021 2 commits
  8. 17 Mar, 2021 1 commit
    • Yossi Gottlieb's avatar
      Cleanup: remove dead code from anet. (#8660) · f657315e
      Yossi Gottlieb authored
      In the long term we may want to move away from anet completely and have
      everything implemented natively in connection.c, instead of having an
      extra layer.
      
      For now, just get rid of unused code.
      f657315e
  9. 28 Jan, 2021 1 commit
    • Yossi Gottlieb's avatar
      Add hostname support in Sentinel. (#8282) · bb7cd974
      Yossi Gottlieb authored
      
      
      This is both a bugfix and an enhancement.
      
      Internally, Sentinel relies entirely on IP addresses to identify
      instances. When configured with a new master, it also requires users to
      specify and IP and not hostname.
      
      However, replicas may use the replica-announce-ip configuration to
      announce a hostname. When that happens, Sentinel fails to match the
      announced hostname with the expected IP and considers that a different
      instance, triggering reconfiguration, etc.
      
      Another use case is where TLS is used and clients are expected to match
      the hostname to connect to with the certificate's SAN attribute. To
      properly implement this configuration, it is necessary for Sentinel to
      redirect clients to a hostname rather than an IP address.
      
      The new 'resolve-hostnames' configuration parameter determines if
      Sentinel is willing to accept hostnames. It is set by default to no,
      which maintains backwards compatibility and avoids unexpected DNS
      resolution delays on systems with DNS configuration issues.
      
      Internally, Sentinel continues to identify instances by their resolved
      IP address and will also report the IP by default. The new
      'announce-hostnames' parameter determines if Sentinel should prefer to
      announce a hostname, when available, rather than an IP address. This
      applies to addresses returned to clients, as well as their
      representation in the configuration file, REPLICAOF configuration
      commands, etc.
      
      This commit also introduces SENTINEL CONFIG GET and SENTINEL CONFIG SET
      which can be used to introspect or configure global Sentinel
      configuration that was previously was only possible by directly
      accessing the configuration file and possibly restarting the instance.
      Co-authored-by: default avatarmyl1024 <myl92916@qq.com>
      Co-authored-by: default avatarsundb <sundbcn@gmail.com>
      bb7cd974
  10. 19 Jan, 2021 2 commits
  11. 09 Dec, 2020 1 commit
  12. 28 Oct, 2020 2 commits
    • yoav-steinberg's avatar
      Add local address to CLIENT LIST, and a CLIENT KILL filter. (#7913) · 84b3c18f
      yoav-steinberg authored
      Useful when you want to know through which bind address the client connected to
      the server in case of multiple bind addresses.
      
      - Adding `laddr` field to CLIENT list showing the local (bind) address.
      - Adding `LADDR` option to CLIENT KILL to kill all the clients connected
        to a specific local address.
      - Refactoring to share code.
      84b3c18f
    • Oran Agra's avatar
      Optionally (default) fail to start if requested bind address is not available (#7936) · 441bfa2d
      Oran Agra authored
      Background:
      #3467 (redis 4.0.0), started ignoring ENOPROTOOPT, but did that only for
      the default bind (in case bind config wasn't explicitly set).
      #5598 (redis 5.0.3), added that for bind addresses explicitly set
      (following bug reports in Debian for redis 4.0.9 and 5.0.1), it
      also ignored a bunch of other errors like EPROTONOSUPPORT which was
      requested in #3894, and also added EADDRNOTAVAIL (wasn't clear why).
      
      This (ignoring EADDRNOTAVAIL) makes redis start successfully, even if a
      certain network interface isn't up yet , in which case we rather redis
      fail and will be re-tried when the NIC is up, see #7933.
      
      However, it turns out that when IPv6 is disabled (supported but unused),
      the error we're getting is EADDRNOTAVAIL. and in many systems the
      default config file tries to bind to localhost for both v4 and v6 and
      would like to silently ignore the error on v6 if disabled.
      This means that we sometimes want to ignore EADDRNOTAVAIL and other times
      we wanna fail.
      
      So this commit changes these main things:
      1. Ignore all the errors we ignore for both explicitly requested bind
         address and a default implicit one.
      2. Add a '-' prefix to allow EADDRNOTAVAIL be ignored (by default that's
         different than the previous behavior).
      3. Restructure that function in a more readable and maintainable way see
         below.
      4. Make the default behavior of listening to all achievable by setting
        a bind config directive to * (previously only possible by omitting
        it)
      5. document everything.
      
      The old structure of this function was that even if there are no bind
      addresses requested, the loop that runs though the bind addresses runs
      at least once anyway!
      In that one iteration of the loop it binds to both v4 and v6 addresses,
      handles errors for each of them separately, and then eventually at the
      if-else chain, handles the error of the last bind attempt again!
      This was very hard to read and very error prone to maintain, instead now
      when the bind info is missing we create one with two entries, and run
      the simple loop twice.
      441bfa2d
  13. 07 Oct, 2019 1 commit
    • Yossi Gottlieb's avatar
      TLS: Connections refactoring and TLS support. · b087dd1d
      Yossi Gottlieb authored
      * Introduce a connection abstraction layer for all socket operations and
      integrate it across the code base.
      * Provide an optional TLS connections implementation based on OpenSSL.
      * Pull a newer version of hiredis with TLS support.
      * Tests, redis-cli updates for TLS support.
      b087dd1d
  14. 08 Jul, 2019 1 commit
    • Oran Agra's avatar
      diskless replication on slave side (don't store rdb to file), plus some other related fixes · 2de544cf
      Oran Agra authored
      The implementation of the diskless replication was currently diskless only on the master side.
      The slave side was still storing the received rdb file to the disk before loading it back in and parsing it.
      
      This commit adds two modes to load rdb directly from socket:
      1) when-empty
      2) using "swapdb"
      the third mode of using diskless slave by flushdb is risky and currently not included.
      
      other changes:
      --------------
      distinguish between aof configuration and state so that we can re-enable aof only when sync eventually
      succeeds (and not when exiting from readSyncBulkPayload after a failed attempt)
      also a CONFIG GET and INFO during rdb loading would have lied
      
      When loading rdb from the network, don't kill the server on short read (that can be a network error)
      
      Fix rdb check when performed on preamble AOF
      
      tests:
      run replication tests for diskless slave too
      make replication test a bit more aggressive
      Add test for diskless load swapdb
      2de544cf
  15. 21 Mar, 2018 2 commits
  16. 08 Aug, 2017 1 commit
  17. 18 Apr, 2017 2 commits
  18. 07 Mar, 2017 1 commit
  19. 09 Sep, 2016 1 commit
  20. 11 Jun, 2015 2 commits
    • antirez's avatar
      anet.c: new API anetTcpNonBlockBestEffortBindConnect() · a017b7ec
      antirez authored
      This performs a best effort source address binding attempt. If it is
      possible to bind the local address and still have a successful
      connect(), then this socket is returned. Otherwise the call is retried
      without source address binding attempt.
      
      Related to issues #2609 and #2612.
      a017b7ec
    • antirez's avatar
      anetTcpGenericConnect(), jump to error not end on error · 8fa8b251
      antirez authored
      Two code paths jumped to the "ok, return the socket to the user" code
      path to handle error conditions.
      
      Related to issues #2609 and #2612.
      8fa8b251
  21. 21 May, 2015 1 commit
  22. 19 Jan, 2015 1 commit
    • Matt Stancliff's avatar
      Improve networking type correctness · 53c082ec
      Matt Stancliff authored
      read() and write() return ssize_t (signed long), not int.
      
      For other offsets, we can use the unsigned size_t type instead
      of a signed offset (since our replication offsets and buffer
      positions are never negative).
      53c082ec
  23. 11 Dec, 2014 2 commits
  24. 22 Oct, 2014 1 commit
  25. 17 Oct, 2014 1 commit
  26. 18 Sep, 2014 3 commits
  27. 13 Aug, 2014 1 commit
  28. 07 Aug, 2014 1 commit
    • kingsumos's avatar
      cluster: fix node connection memory leak · 1a5e5b6b
      kingsumos authored
      Cluster leaks memory while connecting due to missing freeaddrinfo()
      
      (Commit modified by @antirez. The freeaddrinfo() call was misplaced so
       in case of no address was bound, the memory leak was still there).
      
      Closes #1801
      1a5e5b6b
  29. 26 Jun, 2014 1 commit
  30. 24 Apr, 2014 1 commit
  31. 04 Mar, 2014 1 commit
    • Matt Stancliff's avatar
      Bind source address for cluster communication · e5b1e7be
      Matt Stancliff authored
      The first address specified as a bind parameter
      (server.bindaddr[0]) gets used as the source IP
      for cluster communication.
      
      If no bind address is specified by the user, the
      behavior is unchanged.
      
      This patch allows multiple Redis Cluster instances
      to communicate when running on the same interface
      of the same host.
      e5b1e7be