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.

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