Source code of Windows XP (NT5)
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.

122 lines
2.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: R U N D O W N . C P P
  7. //
  8. // Contents: RPC rundown support
  9. //
  10. // Notes:
  11. //
  12. // Author: mbend 12 Nov 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "rundown.h"
  18. CSsdpRundownSupport CSsdpRundownSupport::s_instance;
  19. CSsdpRundownSupport::CSsdpRundownSupport()
  20. {
  21. }
  22. CSsdpRundownSupport::~CSsdpRundownSupport()
  23. {
  24. CLock lock(m_critSec);
  25. RundownList::Iterator iter;
  26. if(S_OK == m_rundownList.GetIterator(iter))
  27. {
  28. CRundownHelperBase ** ppBase = NULL;
  29. while(S_OK == iter.HrGetItem(&ppBase))
  30. {
  31. delete *ppBase;
  32. if(S_OK != iter.HrNext())
  33. {
  34. break;
  35. }
  36. }
  37. }
  38. m_rundownList.Clear();
  39. }
  40. CSsdpRundownSupport & CSsdpRundownSupport::Instance()
  41. {
  42. return s_instance;
  43. }
  44. void CSsdpRundownSupport::RemoveRundownItem(void * pvItem)
  45. {
  46. CRundownHelperBase * pBase = NULL;
  47. {
  48. CLock lock(m_critSec);
  49. RundownList::Iterator iter;
  50. if(S_OK == m_rundownList.GetIterator(iter))
  51. {
  52. CRundownHelperBase ** ppBase = NULL;
  53. while(S_OK == iter.HrGetItem(&ppBase))
  54. {
  55. if((*ppBase)->IsMatch(pvItem))
  56. {
  57. pBase = *ppBase;
  58. iter.HrErase();
  59. break;
  60. }
  61. if(S_OK != iter.HrNext())
  62. {
  63. break;
  64. }
  65. }
  66. }
  67. }
  68. if(pBase)
  69. {
  70. delete pBase;
  71. }
  72. }
  73. void CSsdpRundownSupport::DoRundown(void * pvItem)
  74. {
  75. CRundownHelperBase * pBase = NULL;
  76. {
  77. CLock lock(m_critSec);
  78. RundownList::Iterator iter;
  79. if(S_OK == m_rundownList.GetIterator(iter))
  80. {
  81. CRundownHelperBase ** ppBaseIter = NULL;
  82. while(S_OK == iter.HrGetItem(&ppBaseIter))
  83. {
  84. if((*ppBaseIter)->IsMatch(pvItem))
  85. {
  86. pBase = *ppBaseIter;
  87. iter.HrErase();
  88. break;
  89. }
  90. if(S_OK != iter.HrNext())
  91. {
  92. break;
  93. }
  94. }
  95. }
  96. }
  97. if(pBase)
  98. {
  99. pBase->OnRundown();
  100. delete pBase;
  101. TraceTag(ttidSsdpRpcIf, "Rundown called for %p", pvItem);
  102. }
  103. }
  104. HRESULT CSsdpRundownSupport::HrAddItemInternal(CRundownHelperBase * pBase)
  105. {
  106. HRESULT hr = S_OK;
  107. CLock lock(m_critSec);
  108. hr = m_rundownList.HrPushFrontTransfer(pBase);
  109. TraceHr(ttidError, FAL, hr, FALSE, "CSsdpRundownSupport::HrAddItemInternal");
  110. return hr;
  111. }