Bug #12628 off by one on random selection of multiple hosts/ip addresses
Submitted: 17 Aug 2005 17:55 Modified: 18 Aug 2005 20:56
Reporter: A M Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.4 OS:Windows (Win XP)
Assigned to: Reggie Burnett CPU Architecture:Any

[17 Aug 2005 17:55] A M
Description:
Off by one bug in StreamCreator.GetStream(int), when a random IP address is selected out of the ipAddresses array list.

Therefore, with 2 hosts/IPs in the ConnectString, Connector/net only tries to connect to the first.

Note: both in ms.net and mono, System.Random.Next(int N) generates an integer larger or equal to zero and *less than* N.

How to repeat:
Use a connectstring with 2 hosts/ips.
Connections will only be attempted for the first host/ip, and none for the second.

Suggested fix:
79c79
< 			int index = random.Next(ipAddresses.Count-1);
---
> 			int index = random.Next(ipAddresses.Count);
[18 Aug 2005 13:52] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Fix will be in 1.0.5
[18 Aug 2005 20:56] Mike Hillyer
Documented in 1.0.5 changelog:

<listitem>
        <para>
          With multiple hosts in the connection string, &cnet;
          would not connect to the last host in the list. (Bug #12628)
        </para>
      </listitem>