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.

360 lines
9.3 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: Main
  6. File: perfdata.h
  7. Owner: DmitryR
  8. PERFMON related data in asp.dll -- header file
  9. ===================================================================*/
  10. #ifndef _ASP_PERFDATA_H
  11. #define _ASP_PERFDATA_H
  12. #ifndef PERF_DISABLE
  13. #include "perfdef.h"
  14. #include "denali.h"
  15. // Counter offsets in the array
  16. #define ID_DEBUGDOCREQ 0
  17. #define ID_REQERRRUNTIME 1
  18. #define ID_REQERRPREPROC 2
  19. #define ID_REQERRCOMPILE 3
  20. #define ID_REQERRORPERSEC 4
  21. #define ID_REQTOTALBYTEIN 5
  22. #define ID_REQTOTALBYTEOUT 6
  23. #define ID_REQEXECTIME 7
  24. #define ID_REQWAITTIME 8
  25. #define ID_REQCOMFAILED 9
  26. #define ID_REQBROWSEREXEC 10
  27. #define ID_REQFAILED 11
  28. #define ID_REQNOTAUTH 12
  29. #define ID_REQNOTFOUND 13
  30. #define ID_REQCURRENT 14
  31. #define ID_REQREJECTED 15
  32. #define ID_REQSUCCEEDED 16
  33. #define ID_REQTIMEOUT 17
  34. #define ID_REQTOTAL 18
  35. #define ID_REQPERSEC 19
  36. #define ID_SCRIPTFREEENG 20
  37. #define ID_SESSIONLIFETIME 21
  38. #define ID_SESSIONCURRENT 22
  39. #define ID_SESSIONTIMEOUT 23
  40. #define ID_SESSIONSTOTAL 24
  41. #define ID_TEMPLCACHE 25
  42. #define ID_TEMPLCACHEHITS 26
  43. #define ID_TEMPLCACHETRYS 27
  44. #define ID_TEMPLFLUSHES 28
  45. #define ID_TRANSABORTED 29
  46. #define ID_TRANSCOMMIT 30
  47. #define ID_TRANSPENDING 31
  48. #define ID_TRANSTOTAL 32
  49. #define ID_TRANSPERSEC 33
  50. #define ID_MEMORYTEMPLCACHE 34
  51. #define ID_MEMORYTEMPLCACHEHITS 35
  52. #define ID_MEMORYTEMPLCACHETRYS 36
  53. /*===================================================================
  54. CPerfData -- PERFMON data for ASP
  55. CPerfProcBlock
  56. + macros to update counters
  57. + clsid to remember
  58. + place to update counters before perfmon inited
  59. ===================================================================*/
  60. class CPerfData : public CPerfProcBlock
  61. {
  62. private:
  63. // Initial counter values (gathered when uninit)
  64. DWORD m_rgdwInitCounters[C_PERF_PROC_COUNTERS];
  65. // CLSID
  66. DWORD m_fValid : 1;
  67. CLSID m_ClsId;
  68. public:
  69. inline CPerfData()
  70. : m_fValid(FALSE)
  71. {
  72. memset(m_rgdwInitCounters, 0, CB_COUNTERS);
  73. }
  74. inline ~CPerfData()
  75. {
  76. }
  77. inline HRESULT Init(const CLSID &ClsId)
  78. {
  79. HRESULT hr = InitForThisProcess(ClsId, m_rgdwInitCounters);
  80. if (SUCCEEDED(hr))
  81. {
  82. m_ClsId = ClsId;
  83. m_fValid = TRUE;
  84. }
  85. return hr;
  86. }
  87. inline HRESULT UnInit()
  88. {
  89. m_fValid = FALSE;
  90. return CPerfProcBlock::UnInit();
  91. }
  92. inline BOOL FValid()
  93. {
  94. return m_fValid;
  95. }
  96. inline const CLSID & ClsId()
  97. {
  98. return m_ClsId;
  99. }
  100. // helper inline to get counter address as DWORD *
  101. inline DWORD *PDWCounter(int i)
  102. {
  103. return m_fInited ? &(m_pData->m_rgdwCounters[i])
  104. : &(m_rgdwInitCounters[i]);
  105. }
  106. // helper inline to get counter address as LPLONG
  107. inline LPLONG PLCounter(int i)
  108. {
  109. return (LPLONG)PDWCounter(i);
  110. }
  111. // Inlines to change individual counters --------------
  112. inline void Incr_DEBUGDOCREQ()
  113. {
  114. InterlockedIncrement(PLCounter(ID_DEBUGDOCREQ));
  115. }
  116. inline void Incr_REQERRRUNTIME()
  117. {
  118. InterlockedIncrement(PLCounter(ID_REQERRRUNTIME));
  119. }
  120. inline void Incr_REQERRPREPROC()
  121. {
  122. InterlockedIncrement(PLCounter(ID_REQERRPREPROC));
  123. }
  124. inline void Incr_REQERRCOMPILE()
  125. {
  126. InterlockedIncrement(PLCounter(ID_REQERRCOMPILE));
  127. }
  128. inline void Incr_REQERRORPERSEC()
  129. {
  130. InterlockedIncrement(PLCounter(ID_REQERRORPERSEC));
  131. }
  132. inline void Add_REQTOTALBYTEIN(DWORD dw)
  133. {
  134. EnterCriticalSection(&m_csReqLock);
  135. *PDWCounter(ID_REQTOTALBYTEIN) += dw;
  136. LeaveCriticalSection(&m_csReqLock);
  137. }
  138. inline void Add_REQTOTALBYTEOUT(DWORD dw)
  139. {
  140. EnterCriticalSection(&m_csReqLock);
  141. *PDWCounter(ID_REQTOTALBYTEOUT) += dw;
  142. LeaveCriticalSection(&m_csReqLock);
  143. }
  144. inline void Set_REQEXECTIME(DWORD dw)
  145. {
  146. InterlockedExchange(PLCounter(ID_REQEXECTIME), (LONG)dw);
  147. }
  148. inline void Set_REQWAITTIME(DWORD dw)
  149. {
  150. InterlockedExchange(PLCounter(ID_REQWAITTIME), (LONG)dw);
  151. }
  152. inline void Incr_REQCOMFAILED()
  153. {
  154. InterlockedIncrement(PLCounter(ID_REQCOMFAILED));
  155. }
  156. inline void Incr_REQBROWSEREXEC()
  157. {
  158. InterlockedIncrement(PLCounter(ID_REQBROWSEREXEC));
  159. }
  160. inline void Decr_REQBROWSEREXEC()
  161. {
  162. InterlockedDecrement(PLCounter(ID_REQBROWSEREXEC));
  163. }
  164. inline void Incr_REQFAILED()
  165. {
  166. InterlockedIncrement(PLCounter(ID_REQFAILED));
  167. }
  168. inline void Incr_REQNOTAUTH()
  169. {
  170. InterlockedIncrement(PLCounter(ID_REQNOTAUTH));
  171. }
  172. inline void Incr_REQNOTFOUND()
  173. {
  174. InterlockedIncrement(PLCounter(ID_REQNOTFOUND));
  175. }
  176. inline DWORD Incr_REQCURRENT()
  177. {
  178. return InterlockedIncrement(PLCounter(ID_REQCURRENT));
  179. }
  180. inline void Decr_REQCURRENT()
  181. {
  182. InterlockedDecrement(PLCounter(ID_REQCURRENT));
  183. }
  184. inline void Incr_REQREJECTED()
  185. {
  186. InterlockedIncrement(PLCounter(ID_REQREJECTED));
  187. }
  188. inline void Incr_REQSUCCEEDED()
  189. {
  190. InterlockedIncrement(PLCounter(ID_REQSUCCEEDED));
  191. }
  192. inline void Incr_REQTIMEOUT()
  193. {
  194. InterlockedIncrement(PLCounter(ID_REQTIMEOUT));
  195. }
  196. inline void Incr_REQTOTAL()
  197. {
  198. InterlockedIncrement(PLCounter(ID_REQTOTAL));
  199. }
  200. inline void Incr_REQPERSEC()
  201. {
  202. InterlockedIncrement(PLCounter(ID_REQPERSEC));
  203. }
  204. inline void Incr_SCRIPTFREEENG()
  205. {
  206. InterlockedIncrement(PLCounter(ID_SCRIPTFREEENG));
  207. }
  208. inline void Decr_SCRIPTFREEENG()
  209. {
  210. InterlockedDecrement(PLCounter(ID_SCRIPTFREEENG));
  211. }
  212. inline void Set_SESSIONLIFETIME(DWORD dw)
  213. {
  214. InterlockedExchange(PLCounter(ID_SESSIONLIFETIME), (LONG)dw);
  215. }
  216. inline void Incr_SESSIONCURRENT()
  217. {
  218. InterlockedIncrement(PLCounter(ID_SESSIONCURRENT));
  219. }
  220. inline void Decr_SESSIONCURRENT()
  221. {
  222. InterlockedDecrement(PLCounter(ID_SESSIONCURRENT));
  223. }
  224. inline void Incr_SESSIONTIMEOUT()
  225. {
  226. InterlockedIncrement(PLCounter(ID_SESSIONTIMEOUT));
  227. }
  228. inline void Incr_SESSIONSTOTAL()
  229. {
  230. InterlockedIncrement(PLCounter(ID_SESSIONSTOTAL));
  231. }
  232. inline void Incr_TEMPLCACHE()
  233. {
  234. InterlockedIncrement(PLCounter(ID_TEMPLCACHE));
  235. }
  236. inline void Decr_TEMPLCACHE()
  237. {
  238. InterlockedDecrement(PLCounter(ID_TEMPLCACHE));
  239. }
  240. inline void Zero_TEMPLCACHE()
  241. {
  242. InterlockedExchange(PLCounter(ID_TEMPLCACHE), 0);
  243. }
  244. inline void Incr_TEMPLCACHEHITS()
  245. {
  246. InterlockedIncrement(PLCounter(ID_TEMPLCACHEHITS));
  247. }
  248. inline void Incr_TEMPLCACHETRYS()
  249. {
  250. InterlockedIncrement(PLCounter(ID_TEMPLCACHETRYS));
  251. }
  252. inline void Incr_MEMORYTEMPLCACHE()
  253. {
  254. InterlockedIncrement(PLCounter(ID_MEMORYTEMPLCACHE));
  255. }
  256. inline void Decr_MEMORYTEMPLCACHE()
  257. {
  258. InterlockedDecrement(PLCounter(ID_MEMORYTEMPLCACHE));
  259. }
  260. inline void Zero_MEMORYTEMPLCACHE()
  261. {
  262. InterlockedExchange(PLCounter(ID_MEMORYTEMPLCACHE), 0);
  263. }
  264. inline void Incr_MEMORYTEMPLCACHEHITS()
  265. {
  266. InterlockedIncrement(PLCounter(ID_MEMORYTEMPLCACHEHITS));
  267. }
  268. inline void Incr_MEMORYTEMPLCACHETRYS()
  269. {
  270. InterlockedIncrement(PLCounter(ID_MEMORYTEMPLCACHETRYS));
  271. }
  272. inline void Incr_TEMPLFLUSHES()
  273. {
  274. InterlockedIncrement(PLCounter(ID_TEMPLFLUSHES));
  275. }
  276. inline void Incr_TRANSABORTED()
  277. {
  278. InterlockedIncrement(PLCounter(ID_TRANSABORTED));
  279. }
  280. inline void Incr_TRANSCOMMIT()
  281. {
  282. InterlockedIncrement(PLCounter(ID_TRANSCOMMIT));
  283. }
  284. inline void Incr_TRANSPENDING()
  285. {
  286. InterlockedIncrement(PLCounter(ID_TRANSPENDING));
  287. }
  288. inline void Decr_TRANSPENDING()
  289. {
  290. InterlockedDecrement(PLCounter(ID_TRANSPENDING));
  291. }
  292. inline void Incr_TRANSTOTAL()
  293. {
  294. InterlockedIncrement(PLCounter(ID_TRANSTOTAL));
  295. }
  296. inline void Incr_TRANSPERSEC()
  297. {
  298. InterlockedIncrement(PLCounter(ID_TRANSPERSEC));
  299. }
  300. };
  301. // We init PERFMON data on first request
  302. extern BOOL g_fPerfInited;
  303. // Object to access main shared PERFMON memory
  304. extern CPerfMainBlock g_PerfMain;
  305. // Object to access shared memory (incl. counters) for this process
  306. extern CPerfData g_PerfData;
  307. HRESULT PreInitPerfData();
  308. HRESULT InitPerfDataOnFirstRequest(CIsapiReqInfo *pIReq);
  309. HRESULT UnInitPerfData();
  310. #else
  311. inline HRESULT PreInitPerfData()
  312. {
  313. return S_OK;
  314. }
  315. inline HRESULT InitPerfDataOnFirstRequest(CIsapiReqInfo *pIReq)
  316. {
  317. return S_OK;
  318. }
  319. inline HRESULT UnInitPerfData()
  320. {
  321. return S_OK;
  322. }
  323. #endif // PERF_DISABLE
  324. #endif // _ASP_PERFDATA_H