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.

189 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. soid.hxx
  5. Abstract:
  6. CServerOid objects represent OIDs belonging to processes on the local machine.
  7. A COid's are reference counted by CServerSets which periodically check if the
  8. process is still running.
  9. Author:
  10. Mario Goertzel [MarioGo]
  11. Revision History:
  12. MarioGo 02-22-95 Bits 'n pieces
  13. MarioGo 04-04-95 Split client and server.
  14. --*/
  15. #ifndef __SOID_HXX
  16. #define __SOID_HXX
  17. class CServerOidPList : public CPList
  18. {
  19. public:
  20. CServerOidPList(ORSTATUS &status) :
  21. CPList(status, BaseTimeoutInterval)
  22. {}
  23. CServerOid*
  24. RemoveEligibleOidWithMatchingOxid(CTime &when,
  25. CServerOxid* pOxid);
  26. CServerOid*
  27. RemoveEligibleOid(CTime& when);
  28. void
  29. ResetAllOidTimeouts();
  30. BOOL
  31. AreThereAnyEligibleOidsLyingAround(CTime& when, CServerOxid* pOxid);
  32. };
  33. class CServerOid : public CIdTableElement
  34. /*++
  35. Class Description:
  36. Each instance of this class represents an OID registered
  37. by a server on this machine. If this OID is not pinged
  38. by a client for a timeout period it is rundown.
  39. Members:
  40. _pOxid - A pointer to the OXID which registered this OID.
  41. We own a reference.
  42. _plist - A CPListElement used to manage OID which are not
  43. part of a client set. The worker thread uses this
  44. CPList to manage the rundown on unpinged OIDs.
  45. _list - A CListElement used to track pinned OIDs.
  46. _fRunningDown - Flag used to prevent multiple threads
  47. from trying to rundown the same OID multiple times.
  48. Only 1 bit is required.
  49. _fFreed - Flag used to remember when the owning apartment has
  50. deregistered this oid.
  51. _fPinned -- TRUE if we received a ORS_OID_PINNED status the last
  52. time we tried to rundown this stub.
  53. --*/
  54. {
  55. friend class CServerOidPList;
  56. private :
  57. CServerOxid *_pOxid;
  58. CPListElement _plist;
  59. CListElement _list;
  60. BOOL _fRunningDown:1;
  61. BOOL _fFreed:1;
  62. BOOL _fPinned:1;
  63. public :
  64. CServerOid(CServerOxid *oxid, ID id) :
  65. CIdTableElement(id),
  66. _pOxid(oxid),
  67. _fRunningDown(FALSE),
  68. _fFreed(FALSE),
  69. _fPinned(FALSE)
  70. {
  71. _pOxid->Reference();
  72. }
  73. ~CServerOid();
  74. void KeepAlive();
  75. void SetRundown(BOOL fRunningDown)
  76. {
  77. ASSERT(gpServerLock->HeldExclusive());
  78. ASSERT(_plist.NotInList());
  79. _fRunningDown = fRunningDown;
  80. }
  81. BOOL Match(CServerOid *pOid)
  82. {
  83. return(pOid->_pOxid == _pOxid);
  84. }
  85. BOOL IsRunning()
  86. {
  87. ASSERT(_pOxid);
  88. return(_pOxid->IsRunning());
  89. }
  90. BOOL IsRunningDown()
  91. {
  92. return(_fRunningDown);
  93. }
  94. CServerOxid *GetOxid()
  95. {
  96. return(_pOxid);
  97. }
  98. void Reference();
  99. DWORD Release();
  100. static CServerOid *ContainingRecord(CListElement *ple) {
  101. return CONTAINING_RECORD(ple, CServerOid, _plist);
  102. }
  103. static CServerOid *ContainingRecord2(CListElement *ple) {
  104. return CONTAINING_RECORD(ple, CServerOid, _list);
  105. }
  106. void Insert() {
  107. ASSERT(gpServerLock->HeldExclusive());
  108. ASSERT(IsRunningDown() == FALSE);
  109. ASSERT(_plist.NotInList());
  110. ASSERT(_list.NotInList());
  111. gpServerOidPList->Insert(&_plist);
  112. }
  113. CPListElement *Remove() {
  114. ASSERT(gpServerLock->HeldExclusive());
  115. // We may or may not be in the oid plist, so don't
  116. // assert on that.
  117. ASSERT(_list.NotInList());
  118. return(gpServerOidPList->Remove(&_plist));
  119. }
  120. void Free() {
  121. ASSERT(gpServerLock->HeldExclusive());
  122. _fFreed = TRUE;
  123. // If pinned, unpin.
  124. if (IsPinned())
  125. SetPinned(FALSE);
  126. }
  127. BOOL IsFreed() {
  128. return(_fFreed);
  129. }
  130. void SetPinned(BOOL fPinned);
  131. BOOL IsPinned() {
  132. return (_fPinned);
  133. }
  134. };
  135. #endif // __SOID_HXX