Source code of Windows XP (NT5)
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.

246 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. gump.h
  5. Abstract:
  6. Private header file for the Global Update Manager (GUM) component
  7. of the NT Cluster Service
  8. Author:
  9. John Vert (jvert) 17-Apr-1996
  10. Revision History:
  11. --*/
  12. #include "service.h"
  13. #define LOG_CURRENT_MODULE LOG_MODULE_GUM
  14. //
  15. //
  16. // Structures and type definitions local to the GUM
  17. //
  18. typedef struct _GUM_RECEIVER {
  19. struct _GUM_RECEIVER *Next;
  20. PGUM_UPDATE_ROUTINE UpdateRoutine;
  21. PGUM_LOG_ROUTINE LogRoutine;
  22. DWORD DispatchCount;
  23. PGUM_DISPATCH_ENTRY DispatchTable;
  24. PGUM_VOTE_ROUTINE VoteRoutine;
  25. } GUM_RECEIVER, *PGUM_RECEIVER;
  26. typedef struct _GUM_INFO {
  27. PGUM_RECEIVER Receivers;
  28. BOOL Joined;
  29. BOOL ActiveNode[ClusterMinNodeId + ClusterDefaultMaxNodes];
  30. } GUM_INFO, *PGUM_INFO;
  31. extern GUM_INFO GumTable[GumUpdateMaximum];
  32. extern CRITICAL_SECTION GumpLock;
  33. extern DWORD GumpSequence;
  34. extern CRITICAL_SECTION GumpUpdateLock;
  35. extern CRITICAL_SECTION GumpSendUpdateLock;
  36. extern CRITICAL_SECTION GumpRpcLock;
  37. extern PVOID GumpLastBuffer;
  38. extern DWORD GumpLastContext;
  39. extern DWORD GumpLastBufferLength;
  40. extern DWORD GumpLastUpdateType;
  41. extern LIST_ENTRY GumpLockQueue;
  42. extern DWORD GumpLockingNode;
  43. extern DWORD GumpLockerNode;
  44. extern BOOL GumpLastBufferValid;
  45. extern RPC_BINDING_HANDLE GumpRpcBindings[
  46. ClusterMinNodeId + ClusterDefaultMaxNodes
  47. ];
  48. extern RPC_BINDING_HANDLE GumpReplayRpcBindings[
  49. ClusterMinNodeId + ClusterDefaultMaxNodes
  50. ];
  51. //
  52. // structure used to allow GUM clients to wait for
  53. // a node to transition from active to inactive.
  54. // Waited on by GumpCommFailure.
  55. // Set by GumpEventHandler.
  56. // All access to WaiterCount should be serialized by
  57. // GumpLock
  58. //
  59. typedef struct _GUM_NODE_WAIT {
  60. DWORD WaiterCount;
  61. HANDLE hSemaphore;
  62. } GUM_NODE_WAIT, *PGUM_NODE_WAIT;
  63. extern GUM_NODE_WAIT GumNodeWait[ClusterMinNodeId + ClusterDefaultMaxNodes];
  64. //
  65. // Define structure used for enqueuing waiters for the GUM lock.
  66. //
  67. #define GUM_WAIT_SYNC 0
  68. #define GUM_WAIT_ASYNC 1
  69. typedef struct _GUM_WAITER {
  70. LIST_ENTRY ListEntry;
  71. DWORD WaitType;
  72. DWORD NodeId;
  73. union {
  74. struct {
  75. HANDLE WakeEvent;
  76. } Sync;
  77. struct {
  78. DWORD Context;
  79. DWORD BufferLength;
  80. DWORD BufferPtr;
  81. PUCHAR Buffer;
  82. } Async;
  83. };
  84. } GUM_WAITER, *PGUM_WAITER;
  85. //
  86. // Private GUM routines
  87. //
  88. DWORD
  89. WINAPI
  90. GumpSyncEventHandler(
  91. IN CLUSTER_EVENT Event,
  92. IN PVOID Context
  93. );
  94. DWORD
  95. WINAPI
  96. GumpEventHandler(
  97. IN CLUSTER_EVENT Event,
  98. IN PVOID Context
  99. );
  100. DWORD
  101. WINAPI
  102. GumpDispatchUpdate(
  103. IN GUM_UPDATE_TYPE Type,
  104. IN DWORD Context,
  105. IN BOOL IsLocker,
  106. IN BOOL SourceNode,
  107. IN DWORD BufferLength,
  108. IN PUCHAR Buffer
  109. );
  110. //
  111. // Node Generation Numbers
  112. //
  113. DWORD
  114. GumpGetNodeGenNum(PGUM_INFO GumInfo, DWORD NodeId);
  115. void
  116. GumpWaitNodeDown(DWORD NodeId, DWORD gennum);
  117. BOOL
  118. GumpDispatchStart(DWORD NodeId, DWORD gennum);
  119. void
  120. GumpDispatchEnd(DWORD NodeId, DWORD gennum);
  121. void
  122. GumpDispatchAbort();
  123. //
  124. // Macros to serialize usage of RPC handles. We don't use one lock per node
  125. // because a new sender might grap the RPC to new locker and previous sender
  126. // wants handle to send update. But previous sender owns updatelock and we
  127. // will deadlock. So, we just keep things simple for now and use one lock
  128. // to serialize all RPC calls.
  129. //
  130. #define GumpStartRpc(nodeid) EnterCriticalSection(&GumpRpcLock)
  131. #define GumpEndRpc(nodeid) LeaveCriticalSection(&GumpRpcLock)
  132. //
  133. // Locker interface
  134. //
  135. VOID
  136. GumpPromoteToLocker(
  137. VOID
  138. );
  139. DWORD
  140. GumpDoLockingUpdate(
  141. IN GUM_UPDATE_TYPE Type,
  142. IN DWORD NodeId,
  143. OUT LPDWORD Sequence
  144. );
  145. DWORD
  146. GumpDoLockingPost(
  147. IN GUM_UPDATE_TYPE Type,
  148. IN DWORD NodeId,
  149. OUT LPDWORD Sequence,
  150. IN DWORD Context,
  151. IN DWORD BufferLength,
  152. IN DWORD BufferPtr,
  153. IN UCHAR Buffer[]
  154. );
  155. VOID
  156. GumpDeliverPosts(
  157. IN DWORD FirstNodeId,
  158. IN GUM_UPDATE_TYPE UpdateType,
  159. IN DWORD Sequence,
  160. IN DWORD Context,
  161. IN DWORD BufferLength,
  162. IN PVOID Buffer // THIS WILL BE FREED
  163. );
  164. VOID
  165. GumpDoUnlockingUpdate(
  166. IN GUM_UPDATE_TYPE Type,
  167. IN DWORD Sequence
  168. );
  169. BOOL
  170. GumpTryLockingUpdate(
  171. IN GUM_UPDATE_TYPE Type,
  172. IN DWORD NodeId,
  173. IN DWORD Sequence
  174. );
  175. VOID
  176. GumpReUpdate(
  177. IN GUM_UPDATE_TYPE UpdateType,
  178. IN DWORD EndId
  179. );
  180. VOID
  181. GumpCommFailure(
  182. IN PGUM_INFO GumInfo,
  183. IN DWORD NodeId,
  184. IN DWORD ErrorCode,
  185. IN BOOL Wait
  186. );
  187. //internal routines for dispatching collection of votes
  188. DWORD GumpCollectVotes(
  189. IN PGUM_VOTE_DECISION_CONTEXT pVoteContext,
  190. IN DWORD dwVoteBufSize,
  191. OUT PBYTE pVoteBuffer,
  192. OUT LPDWORD pdwNumVotes,
  193. OUT BOOL *pbDidAllActiveNodesVote
  194. );
  195. DWORD
  196. WINAPI
  197. GumpDispatchVote(
  198. IN GUM_UPDATE_TYPE Type,
  199. IN DWORD Context,
  200. IN DWORD dwInputBufLength,
  201. IN PUCHAR pInputBuf,
  202. IN DWORD dwVoteLength,
  203. OUT PUCHAR pVoteBuf
  204. );
  205.