mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-30 19:48:38 -05:00 
			
		
		
		
	sys: DEBUGRANDTEST()
This commit is contained in:
		| @@ -690,7 +690,7 @@ static NTSTATUS FspFsvolCreateTryOpen(PIRP Irp, const FSP_FSCTL_TRANSACT_RSP *Re | ||||
|     FSP_FSCTL_TRANSACT_REQ *Request = FspIrpRequest(Irp); | ||||
|     BOOLEAN Success; | ||||
|  | ||||
|     Success = FspFileNodeTryAcquireExclusive(FileNode, Both); | ||||
|     Success = DEBUGRANDTEST(90, TRUE) && FspFileNodeTryAcquireExclusive(FileNode, Both); | ||||
|     if (!Success) | ||||
|     { | ||||
|         /* repost the IRP to retry later */ | ||||
|   | ||||
| @@ -261,4 +261,22 @@ const char *FsInformationClassSym(FS_INFORMATION_CLASS FsInformationClass) | ||||
|         return "FS_INFORMATION_CLASS:Unknown"; | ||||
|     } | ||||
| } | ||||
|  | ||||
| ULONG DebugRandom(VOID) | ||||
| { | ||||
|     static KSPIN_LOCK SpinLock = 0; | ||||
|     static ULONG Seed = 1; | ||||
|     KIRQL Irql; | ||||
|     ULONG Result; | ||||
|  | ||||
|     KeAcquireSpinLock(&SpinLock, &Irql); | ||||
|  | ||||
|     /* see ucrt sources */ | ||||
|     Seed = Seed * 214013 + 2531011; | ||||
|     Result = (Seed >> 16) & 0x7fff; | ||||
|  | ||||
|     KeReleaseSpinLock(&SpinLock, Irql); | ||||
|  | ||||
|     return Result; | ||||
| } | ||||
| #endif | ||||
|   | ||||
| @@ -56,7 +56,7 @@ extern __declspec(selectany) int fsp_bp = 1; | ||||
| #define DEBUGBREAK()                    \ | ||||
|     do                                  \ | ||||
|     {                                   \ | ||||
|         static int bp = 1;          \ | ||||
|         static int bp = 1;              \ | ||||
|         if (bp && fsp_bp && !KD_DEBUGGER_NOT_PRESENT)\ | ||||
|             DbgBreakPoint();            \ | ||||
|     } while (0,0) | ||||
| @@ -64,6 +64,13 @@ extern __declspec(selectany) int fsp_bp = 1; | ||||
| #define DEBUGBREAK()                    do {} while (0,0) | ||||
| #endif | ||||
|  | ||||
| /* DEBUGRANDTEST */ | ||||
| #if DBG | ||||
| #define DEBUGRANDTEST(Percent, Default) (DebugRandom() <= (Percent) * 0x7fff / 100 ? (Default) : !(Default)) | ||||
| #else | ||||
| #define DEBUGRANDTEST(Percent, Default) (Default) | ||||
| #endif | ||||
|  | ||||
| /* FSP_ENTER/FSP_LEAVE */ | ||||
| #if DBG | ||||
| #define FSP_DEBUGLOG_(fmt, rfmt, ...)   \ | ||||
| @@ -632,6 +639,7 @@ const char *IrpMinorFunctionSym(UCHAR MajorFunction, UCHAR MinorFunction); | ||||
| const char *IoctlCodeSym(ULONG ControlCode); | ||||
| const char *FileInformationClassSym(FILE_INFORMATION_CLASS FileInformationClass); | ||||
| const char *FsInformationClassSym(FS_INFORMATION_CLASS FsInformationClass); | ||||
| ULONG DebugRandom(VOID); | ||||
| static inline | ||||
| VOID FspDebugLogIrp(const char *func, PIRP Irp, NTSTATUS Result) | ||||
| { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user