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.

169 lines
4.0 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 2001 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dp8simpools.cpp
  6. *
  7. * Content: DP8SIM pool maintainence functions.
  8. *
  9. * History:
  10. * Date By Reason
  11. * ======== ======== =========
  12. * 06/09/01 VanceO Created.
  13. *
  14. ***************************************************************************/
  15. #include "dp8simi.h"
  16. //=============================================================================
  17. // External globals
  18. //=============================================================================
  19. CFixedPool g_FPOOLSend;
  20. CFixedPool g_FPOOLReceive;
  21. CFixedPool g_FPOOLCommand;
  22. CFixedPool g_FPOOLJob;
  23. CFixedPool g_FPOOLEndpoint;
  24. #define SEND_POOL_INITED 0x00000001
  25. #define RECEIVE_POOL_INITED 0x00000002
  26. #define COMMAND_POOL_INITED 0x00000004
  27. #define JOB_POOL_INITED 0x00000008
  28. #define ENDPOINT_POOL_INITED 0x00000010
  29. DWORD g_dwDP8SimInitFlags = 0;
  30. #undef DPF_MODNAME
  31. #define DPF_MODNAME "InitializePools"
  32. //=============================================================================
  33. // InitializePools
  34. //-----------------------------------------------------------------------------
  35. //
  36. // Description: Initialize pools for items used by the DLL.
  37. //
  38. // Arguments: None.
  39. //
  40. // Returns: TRUE if successful, FALSE if an error occurred.
  41. //=============================================================================
  42. BOOL InitializePools(void)
  43. {
  44. //
  45. // Build send pool.
  46. //
  47. if (!g_FPOOLSend.Initialize(sizeof(CDP8SimSend),CDP8SimSend::FPMAlloc,
  48. CDP8SimSend::FPMInitialize,
  49. CDP8SimSend::FPMRelease,
  50. CDP8SimSend::FPMDealloc))
  51. {
  52. goto Failure;
  53. }
  54. g_dwDP8SimInitFlags |= SEND_POOL_INITED;
  55. //
  56. // Build receive pool.
  57. //
  58. if (!g_FPOOLReceive.Initialize(sizeof(CDP8SimReceive), CDP8SimReceive::FPMAlloc,
  59. CDP8SimReceive::FPMInitialize,
  60. CDP8SimReceive::FPMRelease,
  61. CDP8SimReceive::FPMDealloc))
  62. {
  63. goto Failure;
  64. }
  65. g_dwDP8SimInitFlags |= RECEIVE_POOL_INITED;
  66. //
  67. // Build command pool.
  68. //
  69. if (!g_FPOOLCommand.Initialize(sizeof(CDP8SimCommand), CDP8SimCommand::FPMAlloc,
  70. CDP8SimCommand::FPMInitialize,
  71. CDP8SimCommand::FPMRelease,
  72. CDP8SimCommand::FPMDealloc))
  73. {
  74. goto Failure;
  75. }
  76. g_dwDP8SimInitFlags |= COMMAND_POOL_INITED;
  77. //
  78. // Build job pool.
  79. //
  80. if (!g_FPOOLJob.Initialize(sizeof(CDP8SimJob), CDP8SimJob::FPMAlloc,
  81. CDP8SimJob::FPMInitialize,
  82. CDP8SimJob::FPMRelease,
  83. CDP8SimJob::FPMDealloc))
  84. {
  85. goto Failure;
  86. }
  87. g_dwDP8SimInitFlags |= JOB_POOL_INITED;
  88. //
  89. // Build endpoint pool.
  90. //
  91. if (!g_FPOOLEndpoint.Initialize(sizeof(CDP8SimEndpoint),CDP8SimEndpoint::FPMAlloc,
  92. CDP8SimEndpoint::FPMInitialize,
  93. CDP8SimEndpoint::FPMRelease,
  94. CDP8SimEndpoint::FPMDealloc))
  95. {
  96. goto Failure;
  97. }
  98. g_dwDP8SimInitFlags |= ENDPOINT_POOL_INITED;
  99. return TRUE;
  100. Failure:
  101. CleanupPools();
  102. return FALSE;
  103. } // InitializePools
  104. #undef DPF_MODNAME
  105. #define DPF_MODNAME "CleanupPools"
  106. //=============================================================================
  107. // CleanupPools
  108. //-----------------------------------------------------------------------------
  109. //
  110. // Description: Releases pooled items used by DLL.
  111. //
  112. // Arguments: None.
  113. //
  114. // Returns: None.
  115. //=============================================================================
  116. void CleanupPools(void)
  117. {
  118. if (g_dwDP8SimInitFlags & ENDPOINT_POOL_INITED)
  119. {
  120. g_FPOOLEndpoint.DeInitialize();
  121. }
  122. if (g_dwDP8SimInitFlags & JOB_POOL_INITED)
  123. {
  124. g_FPOOLJob.DeInitialize();
  125. }
  126. if (g_dwDP8SimInitFlags & COMMAND_POOL_INITED)
  127. {
  128. g_FPOOLCommand.DeInitialize();
  129. }
  130. if (g_dwDP8SimInitFlags & RECEIVE_POOL_INITED)
  131. {
  132. g_FPOOLReceive.DeInitialize();
  133. }
  134. if (g_dwDP8SimInitFlags & SEND_POOL_INITED)
  135. {
  136. g_FPOOLSend.DeInitialize();
  137. }
  138. g_dwDP8SimInitFlags = 0;
  139. } // CleanupPools