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.

162 lines
6.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2002.
  5. //
  6. // File: idqreg.cxx
  7. //
  8. // Contents: CIdqRegParams class
  9. //
  10. // History: 22 Oct 97 AlanW Created from params.cxx
  11. //
  12. //--------------------------------------------------------------------------
  13. #include <pch.cxx>
  14. #pragma hdrstop
  15. #include <ciregkey.hxx>
  16. #include <regacc.hxx>
  17. #include <params.hxx>
  18. const WCHAR * IS_DEFAULT_CATALOG_DIRECTORY = L"web";
  19. //+-------------------------------------------------------------------------
  20. //
  21. // Member: CIdqRegParams::CIdqRegParams, public
  22. //
  23. // Synopsis: Constructor for registry param object
  24. //
  25. // Arguments: - NONE -
  26. //
  27. // History: 12-Oct-96 dlee Created
  28. //
  29. //--------------------------------------------------------------------------
  30. CIdqRegParams::CIdqRegParams( )
  31. {
  32. SetDefault();
  33. Refresh( );
  34. } //CIdqRegParams
  35. //+-------------------------------------------------------------------------
  36. //
  37. // Member: CIdqRegVars::SetDefault, public
  38. //
  39. // Synopsis: Sets default values for registry params
  40. //
  41. // History: 12-Oct-96 dlee Added header
  42. //
  43. //--------------------------------------------------------------------------
  44. void CIdqRegVars::SetDefault()
  45. {
  46. _maxISRowsInResultSet = IS_MAX_ROWS_IN_RESULT_DEFAULT;
  47. _maxISQueryCache = IS_MAX_ENTRIES_IN_CACHE_DEFAULT;
  48. _ISFirstRowsInResultSet = IS_FIRST_ROWS_IN_RESULT_DEFAULT;
  49. _ISCachePurgeInterval = IS_QUERY_CACHE_PURGE_INTERVAL_DEFAULT;
  50. _ISRequestQueueSize = IS_QUERY_REQUEST_QUEUE_SIZE_DEFAULT;
  51. _ISRequestThresholdFactor = IS_QUERY_REQUEST_THRESHOLD_FACTOR_DEFAULT;
  52. _ISDateTimeFormatting = IS_QUERY_DATETIME_FORMATTING_DEFAULT;
  53. _ISDateTimeLocal = IS_QUERY_DATETIME_LOCAL_DEFAULT;
  54. _maxActiveQueryThreads = CI_MAX_ACTIVE_QUERY_THREADS_DEFAULT;
  55. wcscpy( _awcISDefaultCatalog, IS_DEFAULT_CATALOG_DIRECTORY );
  56. } //SetDefault
  57. //+-------------------------------------------------------------------------
  58. //
  59. // Member: CIdqRegParams::_ReadValues, private
  60. //
  61. // Synopsis: Reads values for variables
  62. //
  63. // History: 12-Oct-96 dlee Added header
  64. //
  65. //--------------------------------------------------------------------------
  66. void CIdqRegParams::_ReadValues(
  67. CRegAccess & reg,
  68. CIdqRegVars & vars )
  69. {
  70. vars._maxISRowsInResultSet = reg.Read(wcsISMaxRecordsInResultSet, IS_MAX_ROWS_IN_RESULT_DEFAULT);
  71. vars._maxISQueryCache = reg.Read(wcsISMaxEntriesInQueryCache, IS_MAX_ENTRIES_IN_CACHE_DEFAULT);
  72. vars._ISFirstRowsInResultSet = reg.Read(wcsISFirstRowsInResultSet, IS_FIRST_ROWS_IN_RESULT_DEFAULT);
  73. vars._ISCachePurgeInterval = reg.Read(wcsISQueryCachePurgeInterval, IS_QUERY_CACHE_PURGE_INTERVAL_DEFAULT);
  74. vars._ISRequestQueueSize = reg.Read(wcsISRequestQueueSize, IS_QUERY_REQUEST_QUEUE_SIZE_DEFAULT);
  75. vars._ISRequestThresholdFactor = reg.Read(wcsISRequestThresholdFactor, IS_QUERY_REQUEST_THRESHOLD_FACTOR_DEFAULT);
  76. vars._ISDateTimeFormatting = reg.Read(wcsISDateTimeFormatting, IS_QUERY_DATETIME_FORMATTING_DEFAULT);
  77. vars._ISDateTimeLocal = reg.Read(wcsISDateTimeLocal, IS_QUERY_DATETIME_LOCAL_DEFAULT);
  78. vars._maxActiveQueryThreads = reg.Read(wcsMaxActiveQueryThreads, CI_MAX_ACTIVE_QUERY_THREADS_DEFAULT);
  79. XPtrST<WCHAR> xwszISDefaultCatalog( reg.Read(wcsISDefaultCatalogDirectory, IS_DEFAULT_CATALOG_DIRECTORY) );
  80. wcsncpy( vars._awcISDefaultCatalog, xwszISDefaultCatalog.GetPointer(), MAX_PATH );
  81. } //_ReadValues
  82. //+-------------------------------------------------------------------------
  83. //
  84. // Member: CIdqRegVars::_StoreNewValues, private
  85. //
  86. // Synopsis: Transfers range-checked values
  87. //
  88. // History: 12-Oct-96 dlee Added header
  89. //
  90. //--------------------------------------------------------------------------
  91. void CIdqRegParams::_StoreNewValues(CIdqRegVars & vars )
  92. {
  93. InterlockedExchange( (long *) &_maxISRowsInResultSet, Range( vars._maxISRowsInResultSet, IS_MAX_ROWS_IN_RESULT_MIN, IS_MAX_ROWS_IN_RESULT_MAX ) );
  94. InterlockedExchange( (long *) &_maxISQueryCache, Range( vars._maxISQueryCache, IS_MAX_ENTRIES_IN_CACHE_MIN, IS_MAX_ENTRIES_IN_CACHE_MAX ) );
  95. InterlockedExchange( (long *) &_ISFirstRowsInResultSet, Range( vars._ISFirstRowsInResultSet, IS_FIRST_ROWS_IN_RESULT_MIN, IS_FIRST_ROWS_IN_RESULT_MAX ) );
  96. InterlockedExchange( (long *) &_ISCachePurgeInterval, Range( vars._ISCachePurgeInterval, IS_QUERY_CACHE_PURGE_INTERVAL_MIN, IS_QUERY_CACHE_PURGE_INTERVAL_MAX ) );
  97. InterlockedExchange( (long *) &_ISRequestQueueSize, Range( vars._ISRequestQueueSize, IS_QUERY_REQUEST_QUEUE_SIZE_MIN, IS_QUERY_REQUEST_QUEUE_SIZE_MAX ) );
  98. InterlockedExchange( (long *) &_ISRequestThresholdFactor, Range( vars._ISRequestThresholdFactor, IS_QUERY_REQUEST_THRESHOLD_FACTOR_MIN, IS_QUERY_REQUEST_THRESHOLD_FACTOR_MAX ) );
  99. InterlockedExchange( (long *) &_ISDateTimeFormatting, Range( vars._ISDateTimeFormatting, IS_QUERY_DATETIME_FORMATTING_MIN, IS_QUERY_DATETIME_FORMATTING_MAX ) );
  100. InterlockedExchange( (long *) &_ISDateTimeLocal, vars._ISDateTimeLocal );
  101. InterlockedExchange( (long *) &_maxActiveQueryThreads, Range( vars._maxActiveQueryThreads, CI_MAX_ACTIVE_QUERY_THREADS_MIN, CI_MAX_ACTIVE_QUERY_THREADS_MAX ) );
  102. wcscpy( _awcISDefaultCatalog, vars._awcISDefaultCatalog );
  103. } //_StoreNewValues
  104. //+-------------------------------------------------------------------------
  105. //
  106. // Member: CIdqRegParams::Refresh, public
  107. //
  108. // Synopsis: Reads the values from the registry
  109. //
  110. // History: 12-Oct-96 dlee Added header, reorganized
  111. //
  112. //--------------------------------------------------------------------------
  113. void CIdqRegParams::Refresh(
  114. BOOL fUseDefaultsOnFailure )
  115. {
  116. // Grab the lock so no other writers try to update at the same time
  117. CIdqRegVars newVals;
  118. CLock lock( _mutex );
  119. TRY
  120. {
  121. // Query the registry.
  122. CRegAccess regAdmin( RTL_REGISTRY_CONTROL, wcsRegAdmin );
  123. _ReadValues( regAdmin, newVals );
  124. _StoreNewValues( newVals );
  125. }
  126. CATCH (CException, e)
  127. {
  128. // Only store defaults when told to do so -- the params
  129. // are still in good shape at this point and are more
  130. // accurate than the default settings.
  131. if ( fUseDefaultsOnFailure )
  132. {
  133. newVals.SetDefault();
  134. _StoreNewValues( newVals );
  135. }
  136. }
  137. END_CATCH
  138. } //Refresh