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.

220 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. global.h
  5. Abstract:
  6. Global flags and parameters for the NT File Replication Service.
  7. Author:
  8. David Orbits (davidor) - 4-Mar-1997
  9. Revision History:
  10. --*/
  11. //
  12. // Limit the amount of staging area used (in Kilobytes). This is
  13. // a soft limit, the actual usage may be higher.
  14. //
  15. extern DWORD StagingLimitInKb;
  16. //
  17. // Default staging limit in kb to be assigned to a new staging area.
  18. //
  19. extern DWORD DefaultStagingLimitInKb;
  20. //
  21. // Running as service or as exe
  22. //
  23. extern BOOL RunningAsAService;
  24. //
  25. // Running with or without the DS
  26. //
  27. extern BOOL NoDs;
  28. #if DBG
  29. //
  30. // Allow multiple servers on one machine
  31. //
  32. extern PWCHAR ServerName;
  33. extern PWCHAR IniFileName;
  34. extern GUID *ServerGuid;
  35. #endif DBG
  36. //
  37. // Working directory
  38. //
  39. extern PWCHAR WorkingPath;
  40. //
  41. // Server Principle Name
  42. //
  43. extern PWCHAR ServerPrincName;
  44. //
  45. // Running as a server in a domain
  46. //
  47. extern BOOL IsAMember;
  48. //
  49. // Running as a DC
  50. //
  51. extern BOOL IsADc;
  52. extern BOOL IsAPrimaryDc;
  53. //
  54. // Handle to the DC.
  55. //
  56. extern HANDLE DsHandle;
  57. //
  58. // The NtFrs Service is shutting down. Set TRUE when the ShutDownEvent is set.
  59. //
  60. extern BOOL FrsIsShuttingDown;
  61. //
  62. // Set TRUE if the shutdown request came from Service Control Manager rather
  63. // than from an internally triggered shutdown. e.g. insufficient resources.
  64. //
  65. extern BOOL FrsScmRequestedShutdown;
  66. //
  67. // Global set to TRUE when FRS asserts.
  68. //
  69. extern BOOL FrsIsAsserting;
  70. //
  71. // Location of Jet Database (UNICODE and ASCII)
  72. //
  73. extern PWCHAR JetPath;
  74. extern PWCHAR JetFile;
  75. extern PWCHAR JetSys;
  76. extern PWCHAR JetTemp;
  77. extern PWCHAR JetLog;
  78. extern PCHAR JetPathA;
  79. extern PCHAR JetFileA;
  80. extern PCHAR JetSysA;
  81. extern PCHAR JetTempA;
  82. extern PCHAR JetLogA;
  83. extern PWCHAR ServiceLongName;
  84. //
  85. // Shared between the journal, database, and replica command servers
  86. //
  87. extern FRS_QUEUE ReplicaListHead;
  88. extern FRS_QUEUE ReplicaFaultListHead;
  89. extern BOOL DBSEmptyDatabase;
  90. extern COMMAND_SERVER DBServiceCmdServer;
  91. extern COMMAND_SERVER ReplicaCmdServer;
  92. extern COMMAND_SERVER InitSyncCs;
  93. #define bugbug(_text_)
  94. #define bugmor(_text_)
  95. //
  96. // The Change Order Lock table is used to synchronize access to change orders.
  97. // The lock index is based on a hash of the change order FileGuid. This ensures
  98. // that when a duplicate change order (from another inbound partner) is trying
  99. // to issue we will interlock against the retire operation on the same change
  100. // order with the same Guid. The FileGuid is used because checks are also needed
  101. // against other change orders on the same file and to check for conflicting
  102. // activity on the parent change order.
  103. //
  104. // The lock array reduces contention and it also avoids the allocating and
  105. // freeing the crit sec resource if it lived in the change order itself
  106. // (which doesn't work anyway because of the race between issue check and
  107. // retire of duplicate change orders).
  108. // *** The array size must be pwr of 2.
  109. //
  110. #define NUMBER_CHANGE_ORDER_LOCKS 16
  111. CRITICAL_SECTION ChangeOrderLockTable[NUMBER_CHANGE_ORDER_LOCKS];
  112. // FidHashValue = (HighPart >> 12) + LowPart + (HighPart << (32-12));
  113. #define HASH_FID(_pUL_, _TABLE_SIZE_) \
  114. (( (_pUL_[1] >> 12) + _pUL_[0] + (_pUL_[1] << (32-12))) & ((_TABLE_SIZE_)-1))
  115. #define HASH_GUID(_pUL_, _TABLE_SIZE_) \
  116. ((_pUL_[0] ^ _pUL_[1] ^ _pUL_[2] ^ _pUL_[3]) & ((_TABLE_SIZE_)-1))
  117. //#define ChgOrdAcquireLockGuid(_coe_) { \
  118. // PULONG pUL = (PULONG) &((_coe_)->Cmd.FileGuid); \
  119. // EnterCriticalSection( \
  120. // &ChangeOrderLockTable[HASH_GUID(pUL, NUMBER_CHANGE_ORDER_LOCKS)] ); \
  121. //}
  122. //
  123. //#define ChgOrdReleaseLockGuid(_coe_) { \
  124. // PULONG pUL = (PULONG) &((_coe_)->Cmd.FileGuid); \
  125. // LeaveCriticalSection( \
  126. // &ChangeOrderLockTable[HASH_GUID(pUL, NUMBER_CHANGE_ORDER_LOCKS)] ); \
  127. //}
  128. #define UNDEFINED_LOCK_SLOT (0xFFFFFFFF)
  129. #define ChgOrdGuidLock(_pGuid_) \
  130. HASH_GUID(((PULONG)(_pGuid_)), NUMBER_CHANGE_ORDER_LOCKS)
  131. //
  132. // Get/Release the change order lock based on the lock slot.
  133. //
  134. #define ChgOrdAcquireLock(_slot_) \
  135. FRS_ASSERT((_slot_) != UNDEFINED_LOCK_SLOT); \
  136. EnterCriticalSection(&ChangeOrderLockTable[(_slot_)])
  137. #define ChgOrdReleaseLock(_slot_) \
  138. FRS_ASSERT((_slot_) != UNDEFINED_LOCK_SLOT); \
  139. LeaveCriticalSection(&ChangeOrderLockTable[(_slot_)])
  140. //
  141. // Get/Release the change order lock based on the File Guid
  142. //
  143. #define ChgOrdAcquireLockGuid(_coe_) { \
  144. ULONG __Slot = ChgOrdGuidLock( &((_coe_)->Cmd.FileGuid)); \
  145. ChgOrdAcquireLock(__Slot); \
  146. }
  147. #define ChgOrdReleaseLockGuid(_coe_) { \
  148. ULONG __Slot = ChgOrdGuidLock( &((_coe_)->Cmd.FileGuid)); \
  149. ChgOrdReleaseLock(__Slot); \
  150. }
  151. //
  152. // Process Handle
  153. //
  154. extern HANDLE ProcessHandle;
  155. //
  156. // if TRUE then preserve existing file GUIDs whenever possible.
  157. //
  158. extern BOOL PreserveFileOID;
  159. #define QUADZERO ((ULONGLONG)0)
  160. //
  161. // Some Time Conversions.
  162. //
  163. #define CONVERT_FILETIME_TO_HOURS ((ULONGLONG)60L * 60L * 1000L * 1000L * 10L)
  164. #define CONVERT_FILETIME_TO_MINUTES ((ULONGLONG)60L * 1000L * 1000L * 10L)
  165. #define CONVERT_FILETIME_TO_DAYS ((ULONGLONG)24L * 60L * 60L * 1000L * 1000L * 10L)
  166. #define ONEDAY ((ULONGLONG)1L * 24L * 60L * 60L * 1000L * 1000L * 10L)
  167. #define WSTR_EQ(_a_, _b_) (_wcsicmp(_a_, _b_) == 0)
  168. #define WSTR_NE(_a_, _b_) (_wcsicmp(_a_, _b_) != 0)
  169. #define ASTR_EQ(_a_, _b_) (_stricmp(_a_, _b_) == 0)
  170. #define ASTR_NE(_a_, _b_) (_stricmp(_a_, _b_) != 0)