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.

150 lines
4.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2000.
  5. //
  6. // File: FRETEST.CXX
  7. //
  8. // Contents: Fresh test object
  9. //
  10. // Classes: CFreshTest
  11. //
  12. // History: 01-Oct-91 BartoszM Created.
  13. // 17-Oct-91 BartoszM Reimplemented using hash table
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <pch.cxx>
  17. #pragma hdrstop
  18. #include "fretest.hxx"
  19. #include "fresh.hxx"
  20. //+---------------------------------------------------------------------------
  21. //
  22. // Member: CFreshTest::CFreshTest, public
  23. //
  24. // Arguments: [size] -- initial # of entries
  25. //
  26. // History: 08-Oct-91 BartoszM Created.
  27. //
  28. //----------------------------------------------------------------------------
  29. CFreshTest::CFreshTest ( unsigned size )
  30. : _refCount(0),
  31. _freshTable(size),
  32. _cDeletes( 0 )
  33. {
  34. }
  35. //+---------------------------------------------------------------------------
  36. //
  37. // Member: CFreshTest::CFreshTest, public
  38. //
  39. // Synopsis: Pseudo copy constructor
  40. // Substitutes old index id's with new iid
  41. //
  42. // Arguments: [freshTest] -- fresh test
  43. // [subst] -- index subst object
  44. //
  45. // History: 15-Oct-91 BartoszM Created.
  46. //
  47. //----------------------------------------------------------------------------
  48. CFreshTest::CFreshTest ( CFreshTest& freshTest, CIdxSubstitution& subst)
  49. : _refCount(0),
  50. _freshTable ( freshTest._freshTable, subst ),
  51. _cDeletes( freshTest._cDeletes )
  52. {
  53. }
  54. //+---------------------------------------------------------------------------
  55. //
  56. // Function: CFreshTest::CFreshTest
  57. //
  58. // Synopsis: Copy ~ctor
  59. //
  60. // History: 7-19-94 srikants Created
  61. //
  62. // Notes: Having a default copy constructor is dangerous for a
  63. // unwindable object because it does not get delinked from
  64. // the exception stack in the absence of an END_CONSTRUCTION
  65. // macro at the end of the constructor.
  66. //
  67. //----------------------------------------------------------------------------
  68. CFreshTest::CFreshTest( CFreshTest& freshTest )
  69. : _refCount(0),
  70. _freshTable(freshTest._freshTable),
  71. _cDeletes( freshTest._cDeletes )
  72. {
  73. }
  74. //+---------------------------------------------------------------------------
  75. //
  76. // Member: CFreshTest::IsCorrectIndex
  77. //
  78. // Synopsis: Checks if the index <-> wid pid association is fresh.
  79. // If entry not found, (wid, pidAll) is tried.
  80. //
  81. // Arguments: [iid] -- index id
  82. // [wid] -- work id
  83. //
  84. // Returns: Shadow if (wid) most recent index is iid
  85. // or Master if (wid) not found (meaning: master index)
  86. // Invalid if (wid) has a more recent iid
  87. // or the the property has been deleted.
  88. //
  89. // History: 16-May-91 BartoszM Created.
  90. //
  91. // Notes: When the document is deleted, the entry
  92. // will contain iidDeleted, wich does not
  93. // match any valid index id.
  94. //
  95. //----------------------------------------------------------------------------
  96. CFreshTest::IndexSource CFreshTest::IsCorrectIndex ( INDEXID iid,
  97. WORKID wid )
  98. {
  99. ciDebugOut (( DEB_FRESH, " -- testing iid %lx <-> wid %ld\n", iid, wid));
  100. CFreshItem* pEntry = _freshTable.Find ( wid );
  101. if ( pEntry == 0 )
  102. {
  103. #if CIDBG == 1
  104. CIndexId indexId(iid);
  105. Win4Assert( indexId.IsPersistent() );
  106. ciDebugOut (( DEB_FRESH, "fresh entry not found\n" ));
  107. #endif // CIDBG == 1
  108. // not found -> must be master index
  109. return CFreshTest::Master;
  110. }
  111. ciDebugOut (( DEB_FRESH, " -- FreshTest found entry\n" ));
  112. INDEXID iidFresh = pEntry->IndexId();
  113. if ( iidFresh == iid )
  114. return CFreshTest::Shadow;
  115. #if CIDBG == 1
  116. //
  117. // If we hit this assert, put this code back in
  118. //
  119. if ( iidFresh == iidInvalid )
  120. {
  121. Win4Assert( !"Unexpected behavior in FreshTest. email searchdv" );
  122. ciDebugOut (( DEB_WARN,
  123. "FreshTest::found invalid index id\n" ));
  124. PatchEntry ( pEntry, iid );
  125. return CFreshTest::Unknown;
  126. }
  127. #endif // CIDBG == 1
  128. ciDebugOut (( DEB_FRESH, " -- FreshTest different iid %lx\n", iidFresh ));
  129. return CFreshTest::Invalid;
  130. } //IsCorrectIndex