読者です 読者をやめる 読者になる 読者になる

mysql/client.cのDNSラウンドロビンの調査

MySQL/Rubyの方は、libmysqlclientに依存するだろうから、client.cを読む。

      hp = my_gethostbyname_r(host,&tmp_hostent,buff2,sizeof(buff2),
			      &tmp_errno);

      /*
        Don't attempt to connect to non IPv4 addresses as the client could
        end up sending information to a unknown server. For example, a IPv6
        address might be returned from gethostbyname depending on options
        set via the RES_OPTIONS environment variable.
      */
      if (!hp || (hp->h_addrtype != AF_INET))
      {
	my_gethostbyname_r_free();
        set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate,
                                 ER(CR_UNKNOWN_HOST), host, tmp_errno);
	goto error;
      }

      for (i= 0; status && hp->h_addr_list[i]; i++)
      {
        IF_DBUG(char ipaddr[18];)
        memcpy(&sock_addr.sin_addr, hp->h_addr_list[i],
               min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
        DBUG_PRINT("info",("Trying %s...",
                          (my_inet_ntoa(sock_addr.sin_addr, ipaddr), ipaddr)));
        status= my_connect(sock, (struct sockaddr *) &sock_addr,
                           sizeof(sock_addr), mysql->options.connect_timeout);
      }

だいたい、Rubyと一緒かな。