Source code of Windows XP (NT5)
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.

176 lines
3.8 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) : CPList(status) {}
  21. CServerOid *
  22. MaybeRemoveMatchingOxid(CTime &when,
  23. CServerOid *pOid);
  24. };
  25. class CServerOid : public CIdTableElement
  26. /*++
  27. Class Description:
  28. Each instance of this class represents an OID registered
  29. by a server on this machine. If this OID is not pinged
  30. by a client for a timeout period it is rundown.
  31. Members:
  32. _pOxid - A pointer to the OXID which registered this OID.
  33. We own a reference.
  34. _plist - A CPListElement used to manage OID which are not
  35. part of a client set. The worker thread uses this
  36. CPList to manage the rundown on unpinged OIDs.
  37. _list - A CListElement used to track pinned OIDs.
  38. _fRunningDown - Flag used to prevent multiple threads
  39. from trying to rundown the same OID multiple times.
  40. Only 1 bit is required.
  41. _fFreed - Flag used to remember when the owning apartment has
  42. deregistered this oid.
  43. _fPinned -- TRUE if we received a ORS_OID_PINNED status the last
  44. time we tried to rundown this stub.
  45. --*/
  46. {
  47. private :
  48. CServerOxid *_pOxid;
  49. CPListElement _plist;
  50. CListElement _list;
  51. BOOL _fRunningDown:1;
  52. BOOL _fFreed:1;
  53. BOOL _fPinned:1;
  54. public :
  55. CServerOid(CServerOxid *oxid) :
  56. CIdTableElement(AllocateId()),
  57. _pOxid(oxid),
  58. _fRunningDown(FALSE),
  59. _fFreed(FALSE),
  60. _fPinned(FALSE)
  61. {
  62. _pOxid->Reference();
  63. }
  64. ~CServerOid();
  65. void KeepAlive();
  66. void SetRundown(BOOL fRunningDown)
  67. {
  68. ASSERT(gpServerLock->HeldExclusive());
  69. ASSERT(_plist.NotInList());
  70. _fRunningDown = fRunningDown;
  71. }
  72. BOOL Match(CServerOid *pOid)
  73. {
  74. return(pOid->_pOxid == _pOxid);
  75. }
  76. BOOL IsRunning()
  77. {
  78. ASSERT(_pOxid);
  79. return(_pOxid->IsRunning());
  80. }
  81. BOOL IsRunningDown()
  82. {
  83. return(_fRunningDown);
  84. }
  85. CServerOxid *GetOxid()
  86. {
  87. return(_pOxid);
  88. }
  89. void Reference();
  90. DWORD Release();
  91. static CServerOid *ContainingRecord(CListElement *ple) {
  92. return CONTAINING_RECORD(ple, CServerOid, _plist);
  93. }
  94. static CServerOid *ContainingRecord2(CListElement *ple) {
  95. return CONTAINING_RECORD(ple, CServerOid, _list);
  96. }
  97. void Insert() {
  98. ASSERT(gpServerLock->HeldExclusive());
  99. ASSERT(IsRunningDown() == FALSE);
  100. ASSERT(_plist.NotInList());
  101. ASSERT(_list.NotInList());
  102. gpServerOidPList->Insert(&_plist);
  103. }
  104. CPListElement *Remove() {
  105. ASSERT(gpServerLock->HeldExclusive());
  106. // We may or may not be in the oid plist, so don't
  107. // assert on that.
  108. ASSERT(_list.NotInList());
  109. return(gpServerOidPList->Remove(&_plist));
  110. }
  111. void Free() {
  112. ASSERT(gpServerLock->HeldExclusive());
  113. _fFreed = TRUE;
  114. // If pinned, unpin.
  115. if (IsPinned())
  116. SetPinned(FALSE);
  117. }
  118. BOOL IsFreed() {
  119. return(_fFreed);
  120. }
  121. void SetPinned(BOOL fPinned);
  122. BOOL IsPinned() {
  123. return (_fPinned);
  124. }
  125. };
  126. #endif // __SOID_HXX