mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 08:53:01 -05:00
sys: DEBUGRANDTEST()
This commit is contained in:
parent
f491d6015f
commit
dde82a1081
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user