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.

245 lines
8.5 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: aqreg.h
  5. //
  6. // Description: Header file containing aq's registry constants
  7. //
  8. // Author: Mike Swafford (MikeSwa)
  9. //
  10. // History:
  11. // 1/4/2000 - MikeSwa Created
  12. //
  13. // Copyright (C) 2000 Microsoft Corporation
  14. //
  15. //-----------------------------------------------------------------------------
  16. #ifndef __AQREG_H__
  17. #define __AQREG_H__
  18. //---[ Registry Paths ]--------------------------------------------------------
  19. //
  20. //
  21. // Description:
  22. // These are the registry keys used by AQ for configuration
  23. //
  24. //-----------------------------------------------------------------------------
  25. #define AQREG_KEY_CONFIGURATION "System\\CurrentControlSet\\Services\\SMTPSVC\\Queuing"
  26. #define AQREG_KEY_CONFIGURATION_TESTSETTINGS "System\\CurrentControlSet\\Services\\SMTPSVC\\Queuing\\TestSettings"
  27. //---[ Global Registry Variables ]---------------------------------------------
  28. //
  29. //
  30. // Description:
  31. // The following are the global configuration variables that can be
  32. // affected by registry settings.
  33. //
  34. //-----------------------------------------------------------------------------
  35. //
  36. // Handle management values. When the number of mailmsgs in the system hits
  37. // this threshold, we will start closing handles.
  38. //
  39. _declspec(selectany) DWORD g_cMaxIMsgHandlesThreshold = 1000;
  40. _declspec(selectany) DWORD g_cMaxIMsgHandlesAsyncThreshold = 1000;
  41. //
  42. // Used to generate a range of handle thresholds that we will
  43. // use in conjunction with the length of the queue to determine
  44. // if we actually need to close handles.
  45. //
  46. _declspec(selectany) DWORD g_cMaxIMsgHandlesThresholdRangePercent = 20;
  47. _declspec(selectany) DWORD g_cMaxIMsgHandlesLowThreshold = g_cMaxIMsgHandlesThreshold;
  48. _declspec(selectany) DWORD g_cMaxHandleReserve = 200;
  49. //
  50. // The following is a for optimizing DSN generation. After generating
  51. // a certain number of DSNs, we will quit and go and restart at a later time
  52. //
  53. _declspec(selectany) DWORD g_cMaxSecondsPerDSNsGenerationPass = 10;
  54. //
  55. // The following is the amount of time to wait before retry a reset
  56. // routes after a routing failure
  57. //
  58. _declspec(selectany) DWORD g_cResetRoutesRetryMinutes = 10;
  59. //
  60. // Async Queue retry intervals that can be modified by registry settings
  61. //
  62. _declspec(selectany) DWORD g_cLocalRetryMinutes = 5;
  63. _declspec(selectany) DWORD g_cCatRetryMinutes = 60;
  64. _declspec(selectany) DWORD g_cRoutingRetryMinutes = 10;
  65. _declspec(selectany) DWORD g_cSubmissionRetryMinutes = 60;
  66. //
  67. // Async Queue Adjustment values. We will increase the max number
  68. // of threads per proc by this value
  69. //
  70. _declspec(selectany) DWORD g_cPerProcMaxThreadPoolModifier = 6;
  71. //
  72. // Async Queue Adjustment value. We will request up to this % of
  73. // max ATQ threads *per async queue*. This % is post our modifcation
  74. // as per g_cPerProcMaxThreadPoolModifier.
  75. //
  76. _declspec(selectany) DWORD g_cMaxATQPercent = 90;
  77. //
  78. // Async Queue Thread Timeout value. After we process each item in
  79. // a queue we will check to see if we have been processing longer than
  80. // this number of milliseconds and if we have we will drop the thread.
  81. // This is intended to keep thread times short and the system responsive.
  82. //
  83. _declspec(selectany) DWORD g_cMaxTicksPerATQThread = 10000;
  84. //
  85. // Reset Message status. If this is non-zero, we will reset the
  86. // message status of every message submitted to MP_STATUS_SUBMITTED.
  87. //
  88. _declspec(selectany) DWORD g_fResetMessageStatus = 0;
  89. //
  90. // retry a glitch failures quicker than "normal" failures
  91. //
  92. _declspec(selectany) DWORD g_dwGlitchRetrySeconds = 60;
  93. //
  94. // the maximum number of outstanding CAT or LD operations
  95. //
  96. _declspec(selectany) DWORD g_cMaxPendingCat = 1000;
  97. _declspec(selectany) DWORD g_cMaxPendingLocal = 1000;
  98. //
  99. // Internal AsyncQueue tuning parameters
  100. // - NOTE - Some are not registry configurable, because non-zero
  101. // values can cause a deadlock.
  102. _declspec(selectany) DWORD g_cMaxSyncCatQThreads = 5;
  103. _declspec(selectany) DWORD g_cItemsPerCatQSyncThread = 10;
  104. _declspec(selectany) DWORD g_cItemsPerCatQAsyncThread = 10;
  105. _declspec(selectany) DWORD g_cMaxSyncLocalQThreads = 0;
  106. _declspec(selectany) DWORD g_cItemsPerLocalQSyncThread = 10;
  107. _declspec(selectany) DWORD g_cItemsPerLocalQAsyncThread = 10;
  108. // Cannot config g_cMaxSyncPostDSNQThreads
  109. // It must be zero to avoid a deadlock (same thread cannot enqueue and dequeue)
  110. const DWORD g_cMaxSyncPostDSNQThreads = 0;
  111. const DWORD g_cItemsPerPostDSNQSyncThread = 100;
  112. _declspec(selectany) DWORD g_cItemsPerPostDSNQAsyncThread = 100;
  113. // Cannot config g_cMaxSyncRoutingThreads
  114. // It must be zero to avoid a deadlock (same thread cannot enqueue and dequeue)
  115. const DWORD g_cMaxSyncRoutingQThreads = 0;
  116. const DWORD g_cItemsPerRoutingQSyncThread = 10;
  117. _declspec(selectany) DWORD g_cItemsPerRoutingQAsyncThread = 10;
  118. // Cannot configure g_cMaxSyncSubmitQThreads
  119. // It must be zero to avoid a deadlock (same thread cannot enqueue and dequeue)
  120. const DWORD g_cMaxSyncSubmitQThreads = 0;
  121. const DWORD g_cItemsPerSubmitQSyncThread = 10;
  122. _declspec(selectany) DWORD g_cItemsPerSubmitQAsyncThread = 10;
  123. // Used to determine the number of threads that will be requested by
  124. // the async workq
  125. _declspec(selectany) DWORD g_cItemsPerWorkQAsyncThread = 10;
  126. //
  127. // Flag to enable registry "Test Settings" values - this must be enabled
  128. // for any of the below testing values to have any effect.
  129. //
  130. _declspec(selectany) DWORD g_fEnableTestSettings = FALSE;
  131. //
  132. // Percentage of failures to cause processing local queues
  133. //
  134. _declspec(selectany) DWORD g_cPreSubmitQueueFailurePercent = 0;
  135. _declspec(selectany) DWORD g_cPreRoutingQueueFailurePercent = 0;
  136. _declspec(selectany) DWORD g_cPreCatQueueFailurePercent = 0;
  137. //
  138. // Sleep times used for performance analysis.
  139. //
  140. _declspec(selectany) DWORD g_dwSubmitQueueSleepMilliseconds = 0;
  141. _declspec(selectany) DWORD g_dwCatQueueSleepMilliseconds = 0;
  142. _declspec(selectany) DWORD g_dwRoutingQueueSleepMilliseconds= 0;
  143. _declspec(selectany) DWORD g_dwLocalQueueSleepMilliseconds = 0;
  144. // Flag to allow us to delay link removal to repro bug where a queue
  145. // may be added to a removed link if timing is just right
  146. _declspec(selectany) DWORD g_cDelayLinkRemovalSeconds = 0;
  147. // DSNs for message larger than this size will contain only the headers
  148. _declspec(selectany) DWORD g_dwMaxDSNSize = 0xFFFFFFFF; // No limit
  149. //
  150. // Number of *message* failures to allow before marking a message as
  151. // problem and queuing differently
  152. //
  153. _declspec(selectany) DWORD g_cMsgFailuresBeforeMarkingMsgAsProblem = 2;
  154. // Test key to enable "retail asserts" - special asserts which will AV
  155. // in RTL if this key is enabled
  156. _declspec(selectany) DWORD g_fEnableRetailAsserts = FALSE;
  157. //
  158. // Max message objects. This key is slightly special in that it is read
  159. // from a mailmsg configuration key.
  160. //
  161. #define MAILMSG_KEY_CONFIGURATION "Software\\Microsoft\\Exchange\\MailMsg"
  162. _declspec(selectany) DWORD g_cMaxMsgObjects = 100000;
  163. //
  164. // Inline function that sleeps as appropriate
  165. //
  166. inline void SleepForPerfAnalysis(DWORD dwSleepMilliseconds)
  167. {
  168. if (g_fEnableTestSettings && dwSleepMilliseconds)
  169. Sleep(dwSleepMilliseconds);
  170. }
  171. //
  172. // Inline function to control test failures
  173. //
  174. inline BOOL fShouldFail(DWORD dwPercent)
  175. {
  176. if (g_fEnableTestSettings && dwPercent)
  177. return (((DWORD)(rand() % 100)) < dwPercent);
  178. else
  179. return FALSE;
  180. }
  181. //
  182. // Implementation of _ASSERTRTL. This will cause an _ASSERT in
  183. // DEBUG and an AV in RTL if the EnableRetailAsserts reg value is set
  184. //
  185. #ifdef DEBUG
  186. #define _ASSERTRTL _ASSERT
  187. #else // RETAIL
  188. inline void _ASSERTRTL(BOOL fExpression)
  189. {
  190. if (g_fEnableTestSettings && g_fEnableRetailAsserts)
  191. {
  192. if (!fExpression)
  193. {
  194. *((int*)0) = 0; // _ASSERTRTL : Trigger an AV here
  195. }
  196. }
  197. }
  198. #endif // DEBUG / RETAIL
  199. //
  200. //Reads config information from the registry and modifies the appropriate globals.
  201. //
  202. VOID ReadGlobalRegistryConfiguration();
  203. #endif //__AQREG_H__