lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

120-fix_INET6.patch (1573B)


      1 --- a/src/sock.c
      2 +++ b/src/sock.c
      3 @@ -39,8 +39,7 @@
      4   * returned if the bind succeeded.  Otherwise, -1 is returned
      5   * to indicate an error.
      6   */
      7 -static int
      8 -bind_socket (int sockfd, const char *addr, int family)
      9 +static int bind_socket (int sockfd, const char *addr)
     10  {
     11          struct addrinfo hints, *res, *ressave;
     12  
     13 @@ -48,7 +47,7 @@ bind_socket (int sockfd, const char *add
     14          assert (addr != NULL && strlen (addr) != 0);
     15  
     16          memset (&hints, 0, sizeof (struct addrinfo));
     17 -        hints.ai_family = family;
     18 +        hints.ai_family = AF_UNSPEC;
     19          hints.ai_socktype = SOCK_STREAM;
     20  
     21          /* The local port it not important */
     22 @@ -106,14 +105,12 @@ int opensock (const char *host, int port
     23  
     24                  /* Bind to the specified address */
     25                  if (bind_to) {
     26 -                        if (bind_socket (sockfd, bind_to,
     27 -                                         res->ai_family) < 0) {
     28 +                        if (bind_socket (sockfd, bind_to) < 0) {
     29                                  close (sockfd);
     30                                  continue;       /* can't bind, so try again */
     31                          }
     32                  } else if (config.bind_address) {
     33 -                        if (bind_socket (sockfd, config.bind_address,
     34 -                                         res->ai_family) < 0) {
     35 +                        if (bind_socket (sockfd, config.bind_address) < 0) {
     36                                  close (sockfd);
     37                                  continue;       /* can't bind, so try again */
     38                          }