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.

125 lines
3.5 KiB

  1. /************************************************************************
  2. * *
  3. * INTEL CORPORATION PROPRIETARY INFORMATION *
  4. * *
  5. * This software is supplied under the terms of a license *
  6. * agreement or non-disclosure agreement with Intel Corporation *
  7. * and may not be copied or disclosed except in accordance *
  8. * with the terms of that agreement. *
  9. * *
  10. * Copyright (C) 1997 Intel Corp. All Rights Reserved *
  11. * *
  12. * $Archive: S:\sturgeon\src\gki\vcs\retry.cpv $
  13. * *
  14. * $Revision: 1.11 $
  15. * $Date: 12 Feb 1997 01:10:26 $
  16. * *
  17. * $Author: CHULME $
  18. * *
  19. * $Log: S:\sturgeon\src\gki\vcs\retry.cpv $
  20. //
  21. // Rev 1.11 12 Feb 1997 01:10:26 CHULME
  22. // Redid thread synchronization to use Gatekeeper.Lock
  23. //
  24. // Rev 1.10 08 Feb 1997 13:05:10 CHULME
  25. // Added debug message for thread termination
  26. //
  27. // Rev 1.9 08 Feb 1997 12:18:08 CHULME
  28. // Added Check for semaphore signalling to exit the retry thread
  29. //
  30. // Rev 1.8 24 Jan 1997 18:29:44 CHULME
  31. // Reverted to rev 1.6
  32. //
  33. // Rev 1.6 22 Jan 1997 20:45:38 EHOWARDX
  34. // Work-around for race condition that may result in
  35. // GKI_RegistrationRequest returning GKI_ALREADY_REG.
  36. //
  37. // Rev 1.5 17 Jan 1997 09:02:34 CHULME
  38. // Changed reg.h to gkreg.h to avoid name conflict with inc directory
  39. //
  40. // Rev 1.4 10 Jan 1997 16:16:04 CHULME
  41. // Removed MFC dependency
  42. //
  43. // Rev 1.3 20 Dec 1996 01:28:00 CHULME
  44. // Fixed memory leak on GK_REG_BYPASS
  45. //
  46. // Rev 1.2 22 Nov 1996 15:21:12 CHULME
  47. // Added VCS log to the header
  48. *************************************************************************/
  49. // retry.cpp : Provides a background retry thread
  50. //
  51. #include "precomp.h"
  52. #include "gkicom.h"
  53. #include "dspider.h"
  54. #include "dgkilit.h"
  55. #include "DGKIPROT.H"
  56. #include "gksocket.h"
  57. #include "GKREG.H"
  58. #include "GATEKPR.H"
  59. #include "h225asn.h"
  60. #include "coder.hpp"
  61. #include "dgkiext.h"
  62. #ifdef _DEBUG
  63. #undef THIS_FILE
  64. static char THIS_FILE[] = __FILE__;
  65. #endif
  66. #if (0)
  67. void
  68. Retry(void *pv)
  69. {
  70. // ABSTRACT: This function is invoked in a separate thread to
  71. // periodically check for outstanding PDUs. If a configurable
  72. // timeout period has expired, the PDU will be reissued. If
  73. // the maximum number of retries has been exhausted, this thread
  74. // will clean-up the appropriate memory.
  75. // AUTHOR: Colin Hulme
  76. DWORD dwTime, dwErrorCode;
  77. #ifdef _DEBUG
  78. char szGKDebug[80];
  79. #endif
  80. HRESULT hResult = GKI_OK;
  81. HANDLE hRetrySemaphore;
  82. SPIDER_TRACE(SP_FUNC, "Retry(pv)\n", 0);
  83. ASSERT(g_pGatekeeper);
  84. if(g_pGatekeeper == NULL)
  85. return;
  86. dwTime = g_pGatekeeper->GetRetryMS();
  87. g_pGatekeeper->Lock();
  88. while (hResult == GKI_OK)
  89. {
  90. hRetrySemaphore = g_pReg->m_hRetrySemaphore;
  91. g_pGatekeeper->Unlock();
  92. dwErrorCode = WaitForSingleObject(hRetrySemaphore, dwTime);
  93. if(dwErrorCode != WAIT_TIMEOUT)
  94. {
  95. SPIDER_TRACE(SP_THREAD, "Retry thread exiting\n", 0);
  96. return; // Exit thread
  97. }
  98. g_pGatekeeper->Lock();
  99. if (g_pReg == 0)
  100. {
  101. SPIDER_TRACE(SP_THREAD, "Retry thread exiting\n", 0);
  102. g_pGatekeeper->Unlock();
  103. return; // Exit thread
  104. }
  105. hResult = g_pReg->Retry();
  106. }
  107. SPIDER_TRACE(SP_NEWDEL, "del g_pReg = %X\n", g_pReg);
  108. delete g_pReg;
  109. g_pReg = 0;
  110. SPIDER_TRACE(SP_THREAD, "Retry thread exiting\n", 0);
  111. g_pGatekeeper->Unlock();
  112. }
  113. #endif