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.

158 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. fmvote.c
  5. Abstract:
  6. Cluster FM Global Update processing routines.
  7. Author:
  8. Sunita shrivastava (sunitas) 24-Apr-1996
  9. Revision History:
  10. --*/
  11. #include "fmp.h"
  12. #include "ntrtl.h"
  13. #define LOG_MODULE FMVOTE
  14. /****
  15. @func DWORD | FmpGumVoteHandler| This is invoked by gum when fm requests
  16. a vote for a given context.
  17. @parm IN DWORD | dwContext| The gum update type for which the vote is
  18. being collected.
  19. @parm IN DWORD | dwInputBufLength| The length of the input buffer.
  20. @parm IN PVOID | pInputBuf| A pointer to the input buffer based on
  21. which a vote must be cast.
  22. @parm IN DWORD | dwVoteLength | The length of the buffer pointed to
  23. by pVoteBuf.
  24. @parm OUT POVID | pVoteBuf | A pointer to a buffer of size dwVoteLength
  25. where the vote must be cast.
  26. @comm The votes are collected by gum and returned to the node that is taking
  27. the poll.
  28. @rdesc Returns a result code. ERROR_SUCCESS on success.
  29. @xref <f DmSwitchToNewQuorumLog>
  30. ****/
  31. DWORD
  32. WINAPI
  33. FmpGumVoteHandler(
  34. IN DWORD dwContext,
  35. IN DWORD dwInputBufLength,
  36. IN PVOID pInputBuf,
  37. IN DWORD dwVoteLength,
  38. OUT PVOID pVoteBuf
  39. )
  40. {
  41. DWORD dwStatus = ERROR_SUCCESS;
  42. if ( !FmpFMGroupsInited ||
  43. FmpShutdown )
  44. {
  45. return(ERROR_NOT_READY);
  46. }
  47. switch ( dwContext )
  48. {
  49. case FmUpdatePossibleNodeForResType:
  50. dwStatus = FmpVotePossibleNodeForResType(dwInputBufLength,
  51. (LPCWSTR)pInputBuf, dwVoteLength, pVoteBuf);
  52. break;
  53. default:
  54. dwStatus = ERROR_REQUEST_ABORTED;
  55. }
  56. return(dwStatus);
  57. } // FmpGumVoteHandler
  58. /****
  59. @func DWORD | FmpGumVoteHandler| This is invoked by gum when fm requests
  60. a vote for a given context.
  61. @parm IN DWORD | dwContext| The gum update type for which the vote is
  62. being collected.
  63. @parm IN DWORD | dwInputBufLength| The length of the input buffer.
  64. @parm IN PVOID | pInputBuf| A pointer to the input buffer based on
  65. which a vote must be cast.
  66. @parm IN DWORD | dwVoteLength | The length of the buffer pointed to
  67. by pVoteBuf.
  68. @parm OUT POVID | pVoteBuf | A pointer to a buffer of size dwVoteLength
  69. where the vote must be cast.
  70. @comm The votes are collected by gum and returned to the node that is taking
  71. the poll.
  72. @rdesc Returns a result code. ERROR_SUCCESS on success.
  73. @xref <f DmSwitchToNewQuorumLog>
  74. ****/
  75. DWORD FmpVotePossibleNodeForResType(
  76. IN DWORD dwInputBufLength,
  77. IN LPCWSTR lpszResType,
  78. IN DWORD dwVoteLength,
  79. OUT PVOID pVoteBuf
  80. )
  81. {
  82. DWORD dwStatus = ERROR_SUCCESS;
  83. DWORD dwVoteStatus;
  84. PFMP_VOTE_POSSIBLE_NODE_FOR_RESTYPE pVoteResType;
  85. PFM_RESTYPE pResType=NULL;
  86. if (dwVoteLength != sizeof(FMP_VOTE_POSSIBLE_NODE_FOR_RESTYPE))
  87. return (ERROR_INVALID_PARAMETER);
  88. pVoteResType = (PFMP_VOTE_POSSIBLE_NODE_FOR_RESTYPE)pVoteBuf;
  89. pResType = OmReferenceObjectById(ObjectTypeResType, lpszResType);
  90. if (!pResType)
  91. return (ERROR_INVALID_PARAMETER);
  92. dwVoteStatus = FmpRmLoadResTypeDll(pResType);
  93. pVoteResType->dwNodeId = NmLocalNodeId;
  94. pVoteResType->dwSize = sizeof(FMP_VOTE_POSSIBLE_NODE_FOR_RESTYPE);
  95. if (dwVoteStatus == ERROR_SUCCESS)
  96. pVoteResType->bPossibleNode = TRUE;
  97. else
  98. pVoteResType->bPossibleNode = FALSE;
  99. if (pResType) OmDereferenceObject(pResType);
  100. return(dwStatus);
  101. }