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.

284 lines
6.2 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 GumNodeGeneration[ClusterMinNodeId + ClusterDefaultMaxNodes];
  34. extern DWORD GumpSequence;
  35. extern CRITICAL_SECTION GumpUpdateLock;
  36. extern CRITICAL_SECTION GumpSendUpdateLock;
  37. extern CRITICAL_SECTION GumpRpcLock;
  38. extern PVOID GumpLastBuffer;
  39. extern DWORD GumpLastContext;
  40. extern DWORD GumpLastBufferLength;
  41. extern DWORD GumpLastUpdateType;
  42. extern LIST_ENTRY GumpLockQueue;
  43. extern DWORD GumpLockingNode;
  44. extern DWORD GumpLockerNode;
  45. extern BOOL GumpLastBufferValid;
  46. extern RPC_BINDING_HANDLE GumpRpcBindings[
  47. ClusterMinNodeId + ClusterDefaultMaxNodes
  48. ];
  49. extern RPC_BINDING_HANDLE GumpReplayRpcBindings[
  50. ClusterMinNodeId + ClusterDefaultMaxNodes
  51. ];
  52. //
  53. // structure used to allow GUM clients to wait for
  54. // a node to transition from active to inactive.
  55. // Waited on by GumpCommFailure.
  56. // Set by GumpEventHandler.
  57. // All access to WaiterCount should be serialized by
  58. // GumpLock
  59. //
  60. typedef struct _GUM_NODE_WAIT {
  61. DWORD WaiterCount;
  62. HANDLE hSemaphore;
  63. } GUM_NODE_WAIT, *PGUM_NODE_WAIT;
  64. extern GUM_NODE_WAIT GumNodeWait[ClusterMinNodeId + ClusterDefaultMaxNodes];
  65. //
  66. // Define structure used for enqueuing waiters for the GUM lock.
  67. //
  68. #define GUM_WAIT_SYNC 0
  69. #define GUM_WAIT_ASYNC 1
  70. typedef struct _GUM_WAITER {
  71. LIST_ENTRY ListEntry;
  72. DWORD WaitType;
  73. DWORD NodeId;
  74. DWORD GenerationNum;
  75. union {
  76. struct {
  77. HANDLE WakeEvent;
  78. } Sync;
  79. struct {
  80. DWORD Context;
  81. DWORD BufferLength;
  82. DWORD BufferPtr;
  83. PUCHAR Buffer;
  84. } Async;
  85. };
  86. } GUM_WAITER, *PGUM_WAITER;
  87. //
  88. // Private GUM routines
  89. //
  90. DWORD
  91. WINAPI
  92. GumpSyncEventHandler(
  93. IN CLUSTER_EVENT Event,
  94. IN PVOID Context
  95. );
  96. DWORD
  97. WINAPI
  98. GumpEventHandler(
  99. IN CLUSTER_EVENT Event,
  100. IN PVOID Context
  101. );
  102. DWORD
  103. WINAPI
  104. GumpDispatchUpdate(
  105. IN GUM_UPDATE_TYPE Type,
  106. IN DWORD Context,
  107. IN BOOL IsLocker,
  108. IN BOOL SourceNode,
  109. IN DWORD BufferLength,
  110. IN PUCHAR Buffer
  111. );
  112. DWORD
  113. GumpUpdateRemoteNode(
  114. IN PRPC_ASYNC_STATE AsyncState,
  115. IN DWORD RemoteNodeId,
  116. IN DWORD UpdateType,
  117. IN DWORD Context,
  118. IN DWORD Sequence,
  119. IN DWORD BufferLength,
  120. IN UCHAR Buffer[]
  121. );
  122. //
  123. // Node Generation Numbers
  124. //
  125. DWORD
  126. GumpGetNodeGenNum(PGUM_INFO GumInfo, DWORD NodeId);
  127. void
  128. GumpWaitNodeDown(DWORD NodeId, DWORD gennum);
  129. BOOL
  130. GumpDispatchStart(DWORD NodeId, DWORD gennum);
  131. void
  132. GumpDispatchEnd(DWORD NodeId, DWORD gennum);
  133. void
  134. GumpDispatchAbort();
  135. //
  136. // Macros to serialize usage of RPC handles. We don't use one lock per node
  137. // because a new sender might grap the RPC to new locker and previous sender
  138. // wants handle to send update. But previous sender owns updatelock and we
  139. // will deadlock. So, we just keep things simple for now and use one lock
  140. // to serialize all RPC calls.
  141. //
  142. #define GumpStartRpc(nodeid) EnterCriticalSection(&GumpRpcLock)
  143. #define GumpEndRpc(nodeid) LeaveCriticalSection(&GumpRpcLock)
  144. //
  145. // Locker interface
  146. //
  147. VOID
  148. GumpPromoteToLocker(
  149. VOID
  150. );
  151. DWORD
  152. GumpDoLockingUpdate(
  153. IN GUM_UPDATE_TYPE Type,
  154. IN DWORD NodeId,
  155. OUT LPDWORD Sequence,
  156. OUT LPDWORD pGeneratioNum
  157. );
  158. DWORD
  159. GumpDoLockingPost(
  160. IN GUM_UPDATE_TYPE Type,
  161. IN DWORD NodeId,
  162. OUT LPDWORD Sequence,
  163. IN DWORD Context,
  164. IN DWORD BufferLength,
  165. IN DWORD BufferPtr,
  166. IN UCHAR Buffer[]
  167. );
  168. VOID
  169. GumpDeliverPosts(
  170. IN DWORD FirstNodeId,
  171. IN GUM_UPDATE_TYPE UpdateType,
  172. IN DWORD Sequence,
  173. IN DWORD Context,
  174. IN DWORD BufferLength,
  175. IN PVOID Buffer // THIS WILL BE FREED
  176. );
  177. VOID
  178. GumpDoUnlockingUpdate(
  179. IN GUM_UPDATE_TYPE Type,
  180. IN DWORD Sequence,
  181. IN DWORD NodeId,
  182. IN DWORD GenerationNum
  183. );
  184. BOOL
  185. GumpTryLockingUpdate(
  186. IN GUM_UPDATE_TYPE Type,
  187. IN DWORD NodeId,
  188. IN DWORD Sequence,
  189. OUT LPDWORD pdwGenerationNum
  190. );
  191. error_status_t
  192. GumpAttemptLockingUpdate(
  193. IN DWORD NodeId,
  194. IN DWORD Type,
  195. IN DWORD Context,
  196. IN DWORD Sequence,
  197. IN DWORD BufferLength,
  198. IN UCHAR Buffer[],
  199. OUT LPDWORD pdwGenerationNum
  200. );
  201. VOID
  202. GumpReUpdate(
  203. VOID
  204. );
  205. VOID
  206. GumpCommFailure(
  207. IN PGUM_INFO GumInfo,
  208. IN DWORD NodeId,
  209. IN DWORD ErrorCode,
  210. IN BOOL Wait
  211. );
  212. //internal routines for dispatching collection of votes
  213. DWORD GumpCollectVotes(
  214. IN PGUM_VOTE_DECISION_CONTEXT pVoteContext,
  215. IN DWORD dwVoteBufSize,
  216. OUT PBYTE pVoteBuffer,
  217. OUT LPDWORD pdwNumVotes,
  218. OUT BOOL *pbDidAllActiveNodesVote
  219. );
  220. DWORD
  221. WINAPI
  222. GumpDispatchVote(
  223. IN GUM_UPDATE_TYPE Type,
  224. IN DWORD Context,
  225. IN DWORD dwInputBufLength,
  226. IN PUCHAR pInputBuf,
  227. IN DWORD dwVoteLength,
  228. OUT PUCHAR pVoteBuf
  229. );
  230. //join interfaces
  231. error_status_t
  232. GumpAttemptJoinUpdate(
  233. IN DWORD JoiningId,
  234. IN DWORD Type,
  235. IN DWORD Context,
  236. IN DWORD Sequence,
  237. IN DWORD BufferLength,
  238. IN UCHAR Buffer[],
  239. IN LPDWORD pdwGenerationNum
  240. );
  241.