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.

107 lines
3.2 KiB

  1. //
  2. // MODULE: APGTSPL.H
  3. //
  4. // PURPOSE: Pool Queue shared variables
  5. //
  6. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  9. //
  10. // AUTHOR: Roman Mach
  11. //
  12. // ORIGINAL DATE: 8-2-96
  13. //
  14. // NOTES:
  15. // 1. Based on Print Troubleshooter DLL
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V0.1 - RM Original
  20. // V3.0 9/21/98 JM Pull out of apgts.h to separate header file.
  21. // Working on encapsulation
  22. //
  23. #ifndef _H_APGTSPL
  24. #define _H_APGTSPL
  25. #include <windows.h>
  26. #include <vector>
  27. using namespace std;
  28. // forward references
  29. class CDBLoadConfiguration;
  30. class CHTMLLog;
  31. class CAbstractECB;
  32. //
  33. //
  34. typedef struct _GTS_STATISTIC // for gathering DLL statistics
  35. {
  36. DWORD dwQueueItems;
  37. DWORD dwWorkItems;
  38. DWORD dwRollover; // unique per request while this DLL is loaded
  39. } GTS_STATISTIC;
  40. //
  41. // promoting this from a struct to a class 1/4/99 JM. However, not fully encapsulating it.
  42. class WORK_QUEUE_ITEM
  43. {
  44. WORK_QUEUE_ITEM(); // do not instantiate. No default constructor.
  45. public:
  46. HANDLE hImpersonationToken; // security thread should use while
  47. // processing this work item
  48. CAbstractECB *pECB; // ISAPI uses an EXTENSION_CONTROL_BLOCK
  49. // to wrap CGI data. We have further
  50. // abstracted this.
  51. CDBLoadConfiguration *pConf; // registry, DSC files, all that stuff
  52. CHTMLLog *pLog; // logging
  53. GTS_STATISTIC GTSStat; // for gathering DLL statistics
  54. WORK_QUEUE_ITEM(
  55. HANDLE hImpersonationTokenIn,
  56. CAbstractECB *pECBIn,
  57. CDBLoadConfiguration *pConfIn,
  58. CHTMLLog *pLogIn
  59. ) : hImpersonationToken(hImpersonationTokenIn),
  60. pECB(pECBIn),
  61. pConf(pConfIn),
  62. pLog(pLogIn)
  63. {}
  64. ~WORK_QUEUE_ITEM()
  65. {}
  66. };
  67. class CPoolQueue {
  68. public:
  69. CPoolQueue();
  70. ~CPoolQueue();
  71. DWORD GetStatus();
  72. void Lock();
  73. void Unlock();
  74. void PushBack(WORK_QUEUE_ITEM * pwqi);
  75. WORK_QUEUE_ITEM * GetWorkItem();
  76. void DecrementWorkItems();
  77. DWORD WaitForWork();
  78. DWORD GetTotalWorkItems();
  79. DWORD GetTotalQueueItems();
  80. time_t GetTimeLastAdd();
  81. time_t GetTimeLastRemove();
  82. protected:
  83. CRITICAL_SECTION m_csQueueLock; // must lock to add or delete from either list or to affect
  84. // m_cInProcess or the various time_t variables.
  85. HANDLE m_hWorkSem; // NT Semaphore handle for distributing requests to threads
  86. // Wait on this semaphore for a work item from this queue
  87. DWORD m_dwErr; // NOTE: once this is set nonzero, it can never be cleared.
  88. vector<WORK_QUEUE_ITEM *> m_WorkQueue; // vector of WORK_QUEUE_ITEMs (queued up by
  89. // APGTSExtension::StartRequest for working threads)
  90. DWORD m_cInProcess; // # of items waiting in process (being worked on, vs.
  91. // still in queue). Arbitrary, but acceptable, decision
  92. // to track m_cInProcess in this class. JM 11/30/98
  93. time_t m_timeLastAdd; // time last added an item to the queue
  94. time_t m_timeLastRemove; // time an item was last removed from the queue
  95. };
  96. #endif // _H_APGTSPL