Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2067

Server selection is not random on Windows

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Critical - P2
    • Resolution: Fixed
    • 1.5.0
    • 1.7.0
    • libmongoc
    • None

    Description

      In the process of fixing CDRIVER-1639 "Rand used to pick Mongo server is not seeded" I changed how the driver randomly chooses a suitable server when built with Microsoft Visual Studio. Before, it used the standard rand() function on every platform. After, it uses rand_s() in MSVC. I didn't realize that the return value of rand_s() is zero on success, rather than the random number.

      We use its return value as the index into the list of suitable servers; therefore, we always choose the "first" suitable server, typically the first one in the seed list.

      Attachments

        Issue Links

          Activity

            People

              jesse@mongodb.com A. Jesse Jiryu Davis
              jesse@mongodb.com A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: