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.

196 lines
5.9 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1998-2001 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: CmdData.cpp
  6. * Content: Class representing a command
  7. *
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 04/07/1999 jtk Derived from SPData.h
  13. * 01/19/2000 jtk Derived from CommandData.h
  14. * 10/10/2001 vanceo Add multicast receive endpoint
  15. ***************************************************************************/
  16. #include "dnwsocki.h"
  17. //**********************************************************************
  18. // Constant definitions
  19. //**********************************************************************
  20. //**********************************************************************
  21. // Macro definitions
  22. //**********************************************************************
  23. //**********************************************************************
  24. // Structure definitions
  25. //**********************************************************************
  26. //**********************************************************************
  27. // Variable definitions
  28. //**********************************************************************
  29. //**********************************************************************
  30. // Function prototypes
  31. //**********************************************************************
  32. //**********************************************************************
  33. // Class definitions
  34. //**********************************************************************
  35. //**********************************************************************
  36. // ------------------------------
  37. // CCommandData::Reset - reset this object
  38. //
  39. // Entry: Nothing
  40. //
  41. // Exit: Nothing
  42. // ------------------------------
  43. #undef DPF_MODNAME
  44. #define DPF_MODNAME "CCommandData::Reset"
  45. void CCommandData::Reset( void )
  46. {
  47. SetState( COMMAND_STATE_UNKNOWN );
  48. m_dwDescriptor = NULL_DESCRIPTOR;
  49. SetType( COMMAND_TYPE_UNKNOWN );
  50. SetEndpoint( NULL );
  51. SetUserContext( NULL );
  52. }
  53. //**********************************************************************
  54. //**********************************************************************
  55. // ------------------------------
  56. // CCommandData::PoolAllocFunction - called when a pool item is allocated
  57. //
  58. // Entry: Nothing
  59. //
  60. // Exit: Boolean indicating success
  61. // TRUE = success
  62. // FALSE = failure
  63. // ------------------------------
  64. #undef DPF_MODNAME
  65. #define DPF_MODNAME "CCommandData::PoolAllocFunction"
  66. BOOL CCommandData::PoolAllocFunction( void* pvItem, void* pvContext )
  67. {
  68. BOOL fReturn;
  69. CCommandData* pCmdData = (CCommandData*)pvItem;
  70. //
  71. // initialize
  72. //
  73. fReturn = TRUE;
  74. pCmdData->m_State = COMMAND_STATE_UNKNOWN;
  75. pCmdData->m_dwDescriptor = NULL_DESCRIPTOR;
  76. pCmdData->m_dwNextDescriptor = NULL_DESCRIPTOR + 1;
  77. pCmdData->m_Type = COMMAND_TYPE_UNKNOWN;
  78. pCmdData->m_pEndpoint = NULL;
  79. pCmdData->m_pUserContext = NULL;
  80. pCmdData->m_lRefCount = 0;
  81. //
  82. // initialize critical section and set recursin depth to 0
  83. //
  84. if ( DNInitializeCriticalSection( &pCmdData->m_Lock ) == FALSE )
  85. {
  86. fReturn = FALSE;
  87. goto Failure;
  88. }
  89. DebugSetCriticalSectionRecursionCount( &pCmdData->m_Lock, 0 );
  90. DebugSetCriticalSectionGroup( &pCmdData->m_Lock, &g_blDPNWSockCritSecsHeld ); // separate dpnwsock CSes from the rest of DPlay's CSes
  91. Exit:
  92. return fReturn;
  93. Failure:
  94. goto Exit;
  95. }
  96. //**********************************************************************
  97. //**********************************************************************
  98. // ------------------------------
  99. // CCommandData::PoolInitFunction - called when a pool item is allocated
  100. //
  101. // Entry: Nothing
  102. //
  103. // Exit: Boolean indicating success
  104. // TRUE = success
  105. // FALSE = failure
  106. // ------------------------------
  107. #undef DPF_MODNAME
  108. #define DPF_MODNAME "CCommandData::PoolInitFunction"
  109. void CCommandData::PoolInitFunction( void* pvItem, void* pvContext )
  110. {
  111. CCommandData* pCmdData = (CCommandData*)pvItem;
  112. DNASSERT( pCmdData->m_State == COMMAND_STATE_UNKNOWN );
  113. DNASSERT( pCmdData->m_dwDescriptor == NULL_DESCRIPTOR );
  114. DNASSERT( pCmdData->m_Type == COMMAND_TYPE_UNKNOWN );
  115. DNASSERT( pCmdData->m_pEndpoint == NULL );
  116. DNASSERT( pCmdData->m_pUserContext == NULL );
  117. DNASSERT( pCmdData->m_lRefCount == 0 );
  118. pCmdData->SetDescriptor();
  119. pCmdData->m_lRefCount = 1;
  120. }
  121. //**********************************************************************
  122. //**********************************************************************
  123. // ------------------------------
  124. // CCommandData::PoolReleaseFunction - called when item is returned to the pool
  125. //
  126. // Entry: Nothing
  127. //
  128. // Exit: Nothing
  129. // ------------------------------
  130. #undef DPF_MODNAME
  131. #define DPF_MODNAME "CCommandData::PoolReleaseFunction"
  132. void CCommandData::PoolReleaseFunction( void* pvItem )
  133. {
  134. CCommandData* pCmdData = (CCommandData*)pvItem;
  135. DNASSERT( pCmdData->m_lRefCount == 0 );
  136. pCmdData->m_State = COMMAND_STATE_UNKNOWN;
  137. pCmdData->m_dwDescriptor = NULL_DESCRIPTOR;
  138. pCmdData->m_Type = COMMAND_TYPE_UNKNOWN;
  139. pCmdData->m_pEndpoint = NULL;
  140. pCmdData->m_pUserContext = NULL;
  141. }
  142. //**********************************************************************
  143. //**********************************************************************
  144. // ------------------------------
  145. // CCommandData::Denitialize - deinitialization function for command data
  146. //
  147. // Entry: Nothing
  148. //
  149. // Exit: Nothing
  150. // ------------------------------
  151. #undef DPF_MODNAME
  152. #define DPF_MODNAME "CCommandData::PoolDeallocFunction"
  153. void CCommandData::PoolDeallocFunction( void* pvItem )
  154. {
  155. CCommandData* pCmdData = (CCommandData*)pvItem;
  156. DNASSERT( pCmdData->m_lRefCount == 0 );
  157. DNDeleteCriticalSection( &pCmdData->m_Lock );
  158. pCmdData->m_State = COMMAND_STATE_UNKNOWN;
  159. }
  160. //**********************************************************************