[SERVER-18755] Avoid generating random variable names for functions executed in parallel shell Created: 30/May/15  Updated: 05/Feb/16  Resolved: 11/Dec/15

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.3.0

Type: Task Priority: Trivial - P5
Reporter: Max Hirschhorn Assignee: Jonathan Abrahams
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: TIG E (01/08/16)
Participants:

 Description   

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() { ... })().



 Comments   
Comment by Githook User [ 11/Dec/15 ]

Author:

{u'username': u'hptabster', u'name': u'Jonathan Abrahams', u'email': u'jonathan@mongodb.com'}

Message: SERVER-18755 Change startParallelShell function invocation - remove random name
Branch: master
https://github.com/mongodb/mongo/commit/8410dcd702c59ca664ae8f0c4b67a399111901b3

Generated at Thu Feb 08 03:48:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.