Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-18755

Avoid generating random variable names for functions executed in parallel shell

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 3.3.0
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • None
    • Fully Compatible
    • TIG E (01/08/16)
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      Passing a function to startParallelShell() unnecessarily introduces a variable into the started shell's scope (using random numbers to avoid a collision).

      if (typeof(jsCode) == "function") {
          var id = Math.floor(Math.random() * 100000);
          jsCode = "var f" + id + " = " + jsCode.toString() + ";f" + id + "();";
      }
      

      Instead we can have jsCode immediately invoke the function expression, i.e.
      startParallelShell(function() { ... }) becomes --eval (function() { ... })().

            Assignee:
            jonathan.abrahams Jonathan Abrahams (Inactive)
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: