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.

183 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name :
  4. setable.hxx
  5. Abstract:
  6. This module just defines the Server Extensions (Module) table.
  7. Author:
  8. Murali R. Krishnan ( MuraliK ) 07-Feb-1997
  9. Environment:
  10. User Mode - Win32
  11. Project:
  12. Internet Server Applications Host DLL
  13. Revision History:
  14. --*/
  15. # ifndef _SETABLE_HXX_
  16. # define _SETABLE_HXX_
  17. /************************************************************
  18. * Include Headers
  19. ************************************************************/
  20. # include "isapi.hxx"
  21. # include "wamxinfo.hxx"
  22. /************************************************************
  23. * Type Definitions
  24. ************************************************************/
  25. typedef DWORD APIERR; // An error code from a Win32 API.
  26. /*++
  27. class SESD_LIST
  28. Defines the data structure for the list of Server Extensions
  29. Scheduled for Deletion.
  30. Non-cached extensions have to be deleted from a thread different
  31. from the one calling ReleaseExtension(). This is because we can
  32. end up doing ReleaseExtension() while on an ISAPI thread.
  33. This class implements the thread switch using ATQ scheduler
  34. workitem API.
  35. Used inside SE_TABLE.
  36. --*/
  37. class SESD_LIST {
  38. public:
  39. SESD_LIST(VOID);
  40. ~SESD_LIST(VOID);
  41. VOID ScheduleExtensionForDeletion( IN PHSE psExt);
  42. VOID WaitTillFinished(VOID);
  43. private:
  44. CRITICAL_SECTION m_csLock;
  45. DWORD m_idWorkItem; // scheduler workitem
  46. LIST_ENTRY m_Head; // list of extensions scheduled for deletion
  47. VOID Lock(VOID) { EnterCriticalSection( &m_csLock); }
  48. VOID Unlock(VOID) { LeaveCriticalSection( &m_csLock); }
  49. static VOID WINAPI SchedulerCallback( void *);
  50. VOID DeleteScheduledExtensions(VOID);
  51. }; // class SESD_LIST
  52. /*++
  53. class SE_TABLE
  54. Defines the data structure for the Server Extensions table.
  55. The Server extensions table maintains a list of pointers to
  56. the Server Extensions Objects (ISAPI DLLs). It is protected
  57. internally using a lock and a reference count.
  58. Since there can only be one copy of the ISAPI DLL loaded
  59. per process using SE_TABLE, we have an internal reference
  60. count of users of the SE_TABLE. Whenever this internal
  61. ref count hits 0, all the server extensions will be freed up.
  62. Note: The object itself has a longer lifetime than the ref count for WAMs
  63. holding this object in memory. The object might live with cRefWams of 0
  64. so that the global instance can be reused.
  65. NYI: Avoid this long life-time issue, if possible.
  66. --*/
  67. class SE_TABLE {
  68. public:
  69. SE_TABLE(VOID);
  70. ~SE_TABLE(VOID);
  71. LONG AddRefWam(VOID) { return ( InterlockedIncrement( &m_cRefWams));}
  72. inline VOID ReleaseRefWam(VOID);
  73. BOOL UnloadExtensions( VOID);
  74. BOOL GetExtension(IN const CHAR * pchModuleName,
  75. IN HANDLE hImpersonation,
  76. IN BOOL fCacheImpersonation,
  77. IN BOOL fCache,
  78. OUT PHSE * psExt = NULL
  79. );
  80. BOOL RefreshAcl( IN const CHAR * pchDLL);
  81. BOOL RefreshAcl( IN DWORD dwId );
  82. dllexp
  83. BOOL FlushAccessToken( IN HANDLE hAccTok);
  84. dllexp VOID
  85. ReleaseExtension( IN PHSE psExt);
  86. VOID PrintRequestCounts(VOID);
  87. dllexp
  88. VOID Print(VOID);
  89. private:
  90. // NYI: Use a hash table or some such thing here...
  91. LONG m_cRefWams;
  92. LIST_ENTRY m_ExtensionHead; // list of all extensions
  93. CRITICAL_SECTION m_csLock;
  94. SESD_LIST m_sesdExtensions; // extensions scheduled for deletion
  95. inline VOID InsertIntoListWithLock( HSE_BASE * pExt);
  96. inline VOID RemoveFromList( HSE_BASE * pExt);
  97. VOID Lock(VOID) { EnterCriticalSection( &m_csLock); }
  98. VOID Unlock(VOID) { LeaveCriticalSection( &m_csLock); }
  99. }; // class SE_TABLE
  100. inline VOID SE_TABLE::ReleaseRefWam(VOID)
  101. {
  102. if ( (m_cRefWams > 0 ) && !InterlockedDecrement( &m_cRefWams)) {
  103. DBG_REQUIRE( UnloadExtensions());
  104. }
  105. } // SE_TABLE::ReleaseRefWam()
  106. VOID SE_TABLE::InsertIntoListWithLock( HSE_BASE * pExt)
  107. { InsertHeadList( &m_ExtensionHead, &pExt->m_ListEntry); }
  108. inline VOID SE_TABLE::RemoveFromList( HSE_BASE * pExt)
  109. {
  110. Lock();
  111. RemoveEntryList( &pExt->m_ListEntry);
  112. Unlock();
  113. } // SE_TABLE::RemoveFromList()
  114. APIERR
  115. InitializeHseExtensions( VOID );
  116. VOID
  117. CleanupHseExtensions( VOID );
  118. typedef SE_TABLE * PSE_TABLE;
  119. extern PSE_TABLE g_psextensions; // all extensions
  120. # endif // _SETABLE_HXX_
  121. /************************ End of File ***********************/