Comment 1 for bug 1250805

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

This is how the code looks in activate_tcp_port:

  if (strcasecmp(my_bind_addr_str, MY_BIND_ALL_ADDRESSES) == 0)
  {
    /*
      That's the case when bind-address is set to a special value ('*'),
      meaning "bind to all available IP addresses". If the box supports
      the IPv6 stack, that means binding to '::'. If only IPv4 is available,
      bind to '0.0.0.0'.
    */

    bool ipv6_available= false;

    if (!getaddrinfo(ipv6_all_addresses, port_buf, &hints, &ai))
    {
      /*
        IPv6 might be available (the system might be able to resolve an IPv6
        address, but not be able to create an IPv6-socket). Try to create a
        dummy IPv6-socket. Do not instrument that socket by P_S.
      */

      MYSQL_SOCKET s= mysql_socket_socket(0, AF_INET6, SOCK_STREAM, 0);

      ipv6_available= mysql_socket_getfd(s) != INVALID_SOCKET;

      mysql_socket_close(s);
    }

    if (ipv6_available)
    {
      sql_print_information("IPv6 is available.");

      // Address info (ai) for IPv6 address is already set.

      bind_address_str= ipv6_all_addresses;
    }
    else
    {
      sql_print_information("IPv6 is not available.");

      // Retrieve address info (ai) for IPv4 address.

      if (getaddrinfo(ipv4_all_addresses, port_buf, &hints, &ai))
      {
        sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR));
        sql_print_error("Can't start server: cannot resolve hostname!");
        unireg_abort(1);
      }

      bind_address_str= ipv4_all_addresses;
    }
  }
  else
  {
    if (getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai))
    {
      sql_perror(ER_DEFAULT(ER_IPSOCK_ERROR)); /* purecov: tested */
      sql_print_error("Can't start server: cannot resolve hostname!");
      unireg_abort(1); /* purecov: tested */
    }

    bind_address_str= my_bind_addr_str;
  }

=============================================================

It should be handled similarly in wsrep_check_ip.

=================================================
/**
  MY_BIND_ALL_ADDRESSES defines a special value for the bind-address option,
  which means that the server should listen to all available network addresses,
  both IPv6 (if available) and IPv4.

  Basically, this value instructs the server to make an attempt to bind the
  server socket to '::' address, and rollback to '0.0.0.0' if the attempt fails.
*/
const char *MY_BIND_ALL_ADDRESSES= "*";

=====================================================