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

Server selection is not random on Windows

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Critical - P2 Critical - P2
    • 1.7.0
    • 1.5.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

        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: