Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.9 KiB

  1. /*
  2. This script provides accurately timed update events.
  3. */
  4. Include('types.js');
  5. Include('utils.js');
  6. var g_strWaitFor = 'publicdataupdateexit';
  7. var g_nMinimumPeriod = 5000; // Minimum wait before updating the same machine twice.
  8. var g_nDelayBetweenMachines = 1000; // Minimum spread between machines
  9. var g_nDelayHandleBuildWaiting = 10000; // Minimum spread between handlebuildwaiting checks
  10. function publicdataupdate_js::OnScriptError(strFile, nLine, nChar, strText, sCode, strSource, strDescription)
  11. {
  12. return CommonOnScriptError("publicdataupdate_js", strFile, nLine, nChar, strText, sCode, strSource, strDescription);
  13. }
  14. function publicdataupdate_js::ScriptMain()
  15. {
  16. var nEvent;
  17. var strMachineName;
  18. var nCur;
  19. var nNow;
  20. var nDelay;
  21. var nLastBuildWaitingTime = 0;
  22. CommonVersionCheck(/* $DROPVERSION: */ "V(########) F(!!!!!!!!!!!!!!)" /* $ */);
  23. LogMsg('ScriptMain()');
  24. do
  25. {
  26. nNow = (new Date()).getTime();
  27. if (nNow - nLastBuildWaitingTime > g_nDelayHandleBuildWaiting)
  28. {
  29. nLastBuildWaitingTime = nNow;
  30. SignalThreadSync("handlebuildwaiting");
  31. }
  32. for(strMachineName in PublicData.aBuild[0].hMachine)
  33. {
  34. if (!PublicData.aBuild[0].hMachine.__isPublicMember(strMachineName))
  35. continue;
  36. SignalThreadSync('Update' + strMachineName);
  37. nEvent = WaitForSync(g_strWaitFor, g_nDelayBetweenMachines);
  38. if (nEvent == 1)
  39. break;
  40. }
  41. nCur = (new Date()).getTime();
  42. nDelay = g_nMinimumPeriod - (nCur - nNow);
  43. if (nDelay < 1)
  44. nDelay = 1;
  45. // If nEvent was set to 1 in the loop, this wait will return immediatly as well.
  46. nEvent = WaitForSync(g_strWaitFor, nDelay);
  47. }
  48. while( nEvent != 1);
  49. LogMsg('ScriptMain() EXIT');
  50. }