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.

120 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. timer.c
  5. Abstract:
  6. Cluster FM callback routines to be invoked on a timer
  7. Author:
  8. Sunita shrivastava (sunitas) 24-Sep-1998
  9. Revision History:
  10. --*/
  11. #include "fmp.h"
  12. #include "ntrtl.h"
  13. #define LOG_MODULE TIMER
  14. /****
  15. @func DWORD | FmpQueueTimerActivity| This is invoked by gum when fm requests
  16. a vote for a given context.
  17. @parm IN DWORD | dwInterval| The time in msec to wait.
  18. @parm IN PFN_TIMER_CALLBACK | pfnTimerCb | The callback funtion
  19. to be invoked when the given time elapses.
  20. @parm IN PVOID | pContext| A pointer to a context structure that is
  21. passed back to the callback function.
  22. @comm It is assumed that FM wants to use one shot timers.
  23. @rdesc Returns a result code. ERROR_SUCCESS on success.
  24. @xref <f AddTimerActivity>
  25. ****/
  26. DWORD
  27. FmpQueueTimerActivity(
  28. IN DWORD dwInterval,
  29. IN PFN_TIMER_CALLBACK pfnTimerCb,
  30. IN PVOID pContext
  31. )
  32. {
  33. HANDLE hTimer = NULL;
  34. DWORD dwStatus;
  35. hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
  36. if (!hTimer)
  37. {
  38. dwStatus = GetLastError();
  39. CL_LOGFAILURE(dwStatus);
  40. goto FnExit;
  41. }
  42. //register the timer for this log with the activity timer thread
  43. dwStatus = AddTimerActivity(hTimer, dwInterval, 0, pfnTimerCb, pContext);
  44. if (dwStatus != ERROR_SUCCESS)
  45. {
  46. CloseHandle(hTimer);
  47. goto FnExit;
  48. }
  49. FnExit:
  50. return(dwStatus);
  51. } // FmpQueueTimerActivity
  52. /****
  53. @func DWORD | FmpReslistOnlineRetryCb| This is invoked by timer
  54. activity thread to bring a resource list online again.
  55. @parm IN VOID | pContext| a pointer to PFM_RESLIST_ONLINE_RETRY_INFO
  56. structure containing information about the group and
  57. resources to bring online.
  58. @comm We dont do the work here since the timer lock is held and we
  59. want to avoid acquiring the group lock while the timer lock
  60. is held.
  61. @rdesc Returns a result code. ERROR_SUCCESS on success.
  62. @xref <f FmpWorkerThread> <f FmpOnlineResourceList>
  63. ****/
  64. void
  65. WINAPI
  66. FmpReslistOnlineRetryCb(
  67. IN HANDLE hTimer,
  68. IN PVOID pContext
  69. )
  70. {
  71. ClRtlLogPrint(LOG_NOISE,
  72. "[FM] FmpResListOnlineRetryCb: Called to retry bringing the group online\r\n");
  73. //post a work item, since we dont wont to acquire group locks
  74. //while the timer lock is acquired
  75. //pass hTimer as second Context value to be used by RemoveTimerActivity
  76. FmpPostWorkItem(FM_EVENT_INTERNAL_RETRY_ONLINE, pContext,
  77. (ULONG_PTR)hTimer);
  78. return;
  79. }