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.

113 lines
2.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: scvgr.cxx
  7. //
  8. // Contents: CSAScavengerTask class implementation.
  9. //
  10. // Classes: CSAScavengerTask
  11. //
  12. // Functions: None.
  13. //
  14. // History: 21-Jul-96 MarkBl Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "..\pch\headers.hxx"
  18. #pragma hdrstop
  19. #include "debug.hxx"
  20. #include "lsa.hxx"
  21. #include "task.hxx"
  22. #include "scvgr.hxx"
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Method: CSAScavengerTask::Initialize
  26. //
  27. // Synopsis: Initialize the scavenger task by creating a wait event handle.
  28. //
  29. // Arguments: None.
  30. //
  31. // Returns: S_OK
  32. // CreateEvent HRESULT error code on failure.
  33. //
  34. // Notes: None.
  35. //
  36. //----------------------------------------------------------------------------
  37. HRESULT
  38. CSAScavengerTask::Initialize(void)
  39. {
  40. TRACE3(CSAScavengerTask, Initialize);
  41. _hWaitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  42. if (_hWaitEvent == NULL)
  43. {
  44. CHECK_HRESULT(HRESULT_FROM_WIN32(GetLastError()));
  45. return(HRESULT_FROM_WIN32(GetLastError()));
  46. }
  47. return(S_OK);
  48. }
  49. //+---------------------------------------------------------------------------
  50. //
  51. // Method: CSAScavengerTask::PerformTask
  52. //
  53. // Synopsis: Let ScavengeSASecurityDBase do the actual work of cleaning
  54. // up the scheduling agent security database.
  55. //
  56. // Arguments: None.
  57. //
  58. // Returns: None.
  59. //
  60. // Notes: None.
  61. //
  62. //----------------------------------------------------------------------------
  63. void
  64. CSAScavengerTask::PerformTask(void)
  65. {
  66. TRACE3(CSAScavenger, PerformTask);
  67. DWORD dwRet = WaitForSingleObject(_hWaitEvent, _msWaitTime);
  68. if (dwRet == WAIT_OBJECT_0)
  69. {
  70. //
  71. // The scavenger is to shutdown.
  72. //
  73. ResetEvent(_hWaitEvent);
  74. return;
  75. }
  76. else if (dwRet == WAIT_TIMEOUT)
  77. {
  78. ScavengeSASecurityDBase();
  79. ResetEvent(_hWaitEvent);
  80. }
  81. }
  82. //+---------------------------------------------------------------------------
  83. //
  84. // Method: CSAScavengerTask::Shutdown
  85. //
  86. // Synopsis: Signal the scavenger to shut down by signalling its wait
  87. // event.
  88. //
  89. // Arguments: None.
  90. //
  91. // Returns: None.
  92. //
  93. // Notes: None.
  94. //
  95. //----------------------------------------------------------------------------
  96. void
  97. CSAScavengerTask::Shutdown(void)
  98. {
  99. TRACE3(CSAScavengerTask, Shutdown);
  100. SetEvent(_hWaitEvent);
  101. }