Add ability to suppress pfnTraceErrorCallback for the current thread. Suppress BurnTraceError while logging errors from BurnTraceError.
Add ability to suppress pfnTraceErrorCallback for the current thread. Suppress BurnTraceError while logging errors from BurnTraceError. #6378
Sean Hall committed
May 2, 2021 at 18:50 UTC
71e689fe5179ca253d878480ba34e2e76a540eab
3 files changed
+45
-1
src/burn/stub/stub.cpp
+2
@@ -101,6 +101,8 @@ static void CALLBACK BurnTraceError(
101
102
if (fLog)
103
{
104
+ DutilSuppressTraceErrorSource();
105
LogErrorStringArgs(hrError, szFormat, args);
106
+ DutilUnsuppressTraceErrorSource();
107
}
108
}
src/libs/dutil/WixToolset.DUtil/dutil.cpp
+26
-1
@@ -30,6 +30,8 @@ static REPORT_LEVEL Dutil_rlCurrentTrace = REPORT_STANDARD;
30
static BOOL Dutil_fTraceFilenames = FALSE;
31
static DUTIL_CALLBACK_TRACEERROR vpfnTraceErrorCallback = NULL;
32
33
+thread_local static DWORD vtdwSuppressTraceErrorSource = 0;
34
+
35
36
DAPI_(HRESULT) DutilInitialize(
37
__in_opt DUTIL_CALLBACK_TRACEERROR pfnTraceErrorCallback
@@ -48,6 +50,28 @@ DAPI_(void) DutilUninitialize()
50
vpfnTraceErrorCallback = NULL;
51
}
52
53
+DAPI_(BOOL) DutilSuppressTraceErrorSource()
54
+{
55
+ if (DWORD_MAX == vtdwSuppressTraceErrorSource)
56
+ {
57
+ return FALSE;
58
+ }
59
+
60
+ ++vtdwSuppressTraceErrorSource;
61
+ return TRUE;
62
+}
63
+
64
+DAPI_(BOOL) DutilUnsuppressTraceErrorSource()
65
+{
66
+ if (0 == vtdwSuppressTraceErrorSource)
67
+ {
68
+ return FALSE;
69
+ }
70
+
71
+ --vtdwSuppressTraceErrorSource;
72
+ return TRUE;
73
+}
74
+
75
/*******************************************************************
76
Dutil_SetAssertModule
77
@@ -427,8 +451,9 @@ DAPIV_(void) Dutil_TraceErrorSource(
451
...
452
)
453
{
454
+ // if this callback is currently suppressed, or
455
// if this is NOT an error report and we're not logging at this level, bail
431
- if (REPORT_ERROR != rl && Dutil_rlCurrentTrace < rl)
456
+ if (vtdwSuppressTraceErrorSource || REPORT_ERROR != rl && Dutil_rlCurrentTrace < rl)
457
{
458
return;
459
}
src/libs/dutil/WixToolset.DUtil/inc/dutil.h
+17
@@ -41,6 +41,23 @@ HRESULT DAPI DutilInitialize(
41
*******************************************************************/
42
void DAPI DutilUninitialize();
43
44
+
45
+/********************************************************************
46
+ DutilSuppressTraceErrorSource - tells dutil to skip calling
47
+ pfnTraceErrorCallback for the current thread. This is reference
48
+ counted, so dutil won't start calling it again until there is an
49
+ equal number of calls to DutilUnsuppressTraceErrorSource.
50
+ Returns whether the count was incremented.
51
+
52
+*******************************************************************/
53
+BOOL DAPI DutilSuppressTraceErrorSource();
54
+
55
+/********************************************************************
56
+ DutilUnsuppressTraceErrorSource - opposite of DutilSuppressTraceErrorSource.
57
+
58
+*******************************************************************/
59
+BOOL DAPI DutilUnsuppressTraceErrorSource();
60
+
61
void DAPI Dutil_SetAssertModule(__in HMODULE hAssertModule);
62
void DAPI Dutil_SetAssertDisplayFunction(__in DUTIL_ASSERTDISPLAYFUNCTION pfn);
63
void DAPI Dutil_Assert(__in_z LPCSTR szFile, __in int iLine);