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.

136 lines
2.6 KiB

  1. //***************************************************************************
  2. //
  3. // File:
  4. //
  5. // Module: MS SNMP Provider
  6. //
  7. // Purpose:
  8. //
  9. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #include "precomp.h"
  13. #include <provexpt.h>
  14. #include <corafx.h>
  15. #include <objbase.h>
  16. #include <wbemidl.h>
  17. #include <smir.h>
  18. #include <notify.h>
  19. #include <corstore.h>
  20. #include <snmplog.h>
  21. #include <snmpcl.h>
  22. #include <snmpcont.h>
  23. #include <snmptype.h>
  24. #include <snmpauto.h>
  25. #include <snmpevt.h>
  26. #include <snmpthrd.h>
  27. #include <snmpobj.h>
  28. #include <cominit.h>
  29. #include <evtthrd.h>
  30. #include <evtmap.h>
  31. #include <evtprov.h>
  32. extern CCorrCacheWrapper* g_CacheWrapper;
  33. extern CEventProviderWorkerThread* g_pWorkerThread;
  34. CBaseCorrCacheNotify::CBaseCorrCacheNotify()
  35. {
  36. m_cRef=0;
  37. m_dwCookie=0;
  38. m_DoWork = TRUE;
  39. InitializeCriticalSection ( & m_CriticalSection ) ;
  40. }
  41. CBaseCorrCacheNotify::~CBaseCorrCacheNotify()
  42. {
  43. DeleteCriticalSection ( & m_CriticalSection ) ;
  44. }
  45. void CBaseCorrCacheNotify::Detach()
  46. {
  47. EnterCriticalSection ( & m_CriticalSection ) ;
  48. m_DoWork = FALSE;
  49. LeaveCriticalSection ( & m_CriticalSection ) ;
  50. }
  51. /*
  52. * CBaseCorrCacheNotify::QueryInterface
  53. * CBaseCorrCacheNotify::AddRef
  54. * CBaseCorrCacheNotify::Release
  55. *
  56. * Purpose:
  57. * Non-delegating IUnknown members for CBaseCorrCacheNotify.
  58. */
  59. STDMETHODIMP CBaseCorrCacheNotify::QueryInterface(REFIID riid, LPVOID *ppv)
  60. {
  61. *ppv=NULL;
  62. if (IID_IUnknown == riid || IID_ISMIR_Notify == riid)
  63. *ppv=this;
  64. if (NULL!=*ppv)
  65. {
  66. ((LPUNKNOWN)*ppv)->AddRef();
  67. return NOERROR;
  68. }
  69. return ResultFromScode(E_NOINTERFACE);
  70. }
  71. STDMETHODIMP_(ULONG) CBaseCorrCacheNotify::AddRef()
  72. {
  73. return ++m_cRef;
  74. }
  75. STDMETHODIMP_(ULONG) CBaseCorrCacheNotify::Release()
  76. {
  77. if (0!=--m_cRef)
  78. return m_cRef;
  79. delete this;
  80. return 0;
  81. }
  82. STDMETHODIMP CCorrCacheNotify::ChangeNotify()
  83. {
  84. EnterCriticalSection ( & m_CriticalSection ) ;
  85. BOOL bDoWork = m_DoWork;
  86. LeaveCriticalSection ( & m_CriticalSection ) ;
  87. if (bDoWork)
  88. {
  89. (g_CacheWrapper->GetCache())->InvalidateCache();
  90. CCorrCache* cache = new CCorrCache();
  91. g_CacheWrapper->SetCache(cache);
  92. g_CacheWrapper->ReleaseCache();
  93. }
  94. return NOERROR;
  95. }
  96. STDMETHODIMP CEventCacheNotify::ChangeNotify()
  97. {
  98. EnterCriticalSection ( & m_CriticalSection ) ;
  99. BOOL bDoWork = m_DoWork;
  100. LeaveCriticalSection ( & m_CriticalSection ) ;
  101. if (bDoWork)
  102. {
  103. g_pWorkerThread->Clear();
  104. }
  105. return NOERROR;
  106. }