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.

182 lines
7.2 KiB

  1. // Ruler
  2. // 1 2 3 4 5 6 7 8
  3. //345678901234567890123456789012345678901234567890123456789012345678901234567890
  4. /********************************************************************/
  5. /* */
  6. /* The standard layout. */
  7. /* */
  8. /* The standard layout for 'cpp' files in this code is as */
  9. /* follows: */
  10. /* */
  11. /* 1. Include files. */
  12. /* 2. Constants local to the class. */
  13. /* 3. Data structures local to the class. */
  14. /* 4. Data initializations. */
  15. /* 5. Static functions. */
  16. /* 6. Class functions. */
  17. /* */
  18. /* The constructor is typically the first function, class */
  19. /* member functions appear in alphabetical order with the */
  20. /* destructor appearing at the end of the file. Any section */
  21. /* or function this is not required is simply omitted. */
  22. /* */
  23. /********************************************************************/
  24. #include "HeapPCH.hpp"
  25. #include "Connections.hpp"
  26. #include "Cache.hpp"
  27. #include "Find.hpp"
  28. #include "Heap.hpp"
  29. #include "NewPage.hpp"
  30. /********************************************************************/
  31. /* */
  32. /* Class constructor. */
  33. /* */
  34. /* There are a variety of connections that need to be made */
  35. /* after all the classes are ready for use. However, we */
  36. /* initially zero all these connection pointers until we are */
  37. /* ready to link everything. */
  38. /* */
  39. /********************************************************************/
  40. CONNECTIONS::CONNECTIONS( VOID )
  41. {
  42. Active = False;
  43. Heap = NULL;
  44. NewPage = NULL;
  45. ParentCache = NULL;
  46. PrivateFind = NULL;
  47. PublicFind = NULL;
  48. }
  49. /********************************************************************/
  50. /* */
  51. /* Delete from the find lists. */
  52. /* */
  53. /* When we delete a page we need to remove it from the private */
  54. /* and public find tables as needed. */
  55. /* */
  56. /********************************************************************/
  57. VOID CONNECTIONS::DeleteFromFindList( PAGE *Page )
  58. {
  59. //
  60. // Delete from any active public find table.
  61. //
  62. if ( PublicFind != NULL )
  63. { PublicFind -> DeleteFromFindList( Page ); }
  64. //
  65. // Delete from any active private find table.
  66. //
  67. if ( PrivateFind != NULL )
  68. { PrivateFind -> DeleteFromFindList( Page ); }
  69. }
  70. /********************************************************************/
  71. /* */
  72. /* Add to the find lists. */
  73. /* */
  74. /* When we create a page we need to insert it into the private */
  75. /* and public find tables as needed. */
  76. /* */
  77. /********************************************************************/
  78. VOID CONNECTIONS::InsertInFindList( PAGE *Page )
  79. {
  80. //
  81. // Insert into any active private find table.
  82. //
  83. if ( PrivateFind != NULL )
  84. { PrivateFind -> InsertInFindList( Page ); }
  85. //
  86. // Insert into any active public find table.
  87. //
  88. if ( PublicFind != NULL )
  89. { PublicFind -> InsertInFindList( Page ); }
  90. }
  91. /********************************************************************/
  92. /* */
  93. /* Update the connections. */
  94. /* */
  95. /* When we create an allocator there is some information that */
  96. /* is not available. Here we update the connection information */
  97. /* so we can locate the correct instances of various other */
  98. /* classes. */
  99. /* */
  100. /********************************************************************/
  101. VOID CONNECTIONS::UpdateConnections
  102. (
  103. HEAP *NewHeap,
  104. NEW_PAGE *NewPages,
  105. CACHE *NewParentCache,
  106. FIND *NewPrivateFind,
  107. FIND *NewPublicFind
  108. )
  109. {
  110. //
  111. // We typically only need to update the connections once
  112. // but in some situations multiple updates can occur. If
  113. // this is the case we carefully check the update is
  114. // consistent with the previous update.
  115. //
  116. if ( ! Active )
  117. {
  118. //
  119. // We now have the information we need to update the
  120. // connections.
  121. //
  122. Active = True;
  123. Heap = NewHeap;
  124. NewPage = NewPages;
  125. ParentCache = NewParentCache;
  126. PrivateFind = NewPrivateFind;
  127. PublicFind = NewPublicFind;
  128. }
  129. else
  130. {
  131. //
  132. // Nasty, we have already updated the connections once.
  133. // Since we have been called again we know this node
  134. // must be shared between two heaps. We can deal with
  135. // this as long as selected pointers are the same.
  136. //
  137. if
  138. (
  139. (PublicFind != NewPublicFind)
  140. ||
  141. (NewPage != NewPages)
  142. ||
  143. (ParentCache != NewParentCache)
  144. )
  145. { Failure( "Sharing violation in UpdateConnections" ); }
  146. }
  147. }
  148. /********************************************************************/
  149. /* */
  150. /* Class destructor. */
  151. /* */
  152. /* Destory the connections. */
  153. /* */
  154. /********************************************************************/
  155. CONNECTIONS::~CONNECTIONS( VOID )
  156. {
  157. PublicFind = NULL;
  158. PrivateFind = NULL;
  159. ParentCache = NULL;
  160. NewPage = NULL;
  161. Heap = NULL;
  162. Active = False;
  163. }