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

Server selection is not random on Windows

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.7.0
    • Affects Version/s: 1.5.0
    • Component/s: libmongoc
    • None

      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.

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

              Created:
              Updated:
              Resolved: