aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-05-02 18:50:49 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-05-11 19:11:19 -0500
commit71e689fe5179ca253d878480ba34e2e76a540eab (patch)
treedbd197605fdcc2805acc2d971fdc2dbc8bb6d8cb
parent5da97c750ef36518970eb0d3b02655b2eac75a35 (diff)
downloadwix-71e689fe5179ca253d878480ba34e2e76a540eab.tar.gz
wix-71e689fe5179ca253d878480ba34e2e76a540eab.tar.bz2
wix-71e689fe5179ca253d878480ba34e2e76a540eab.zip
Add ability to suppress pfnTraceErrorCallback for the current thread.
Suppress BurnTraceError while logging errors from BurnTraceError. #6378
-rw-r--r--src/burn/stub/stub.cpp2
-rw-r--r--src/libs/dutil/WixToolset.DUtil/dutil.cpp27
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/dutil.h17
3 files changed, 45 insertions, 1 deletions
diff --git a/src/burn/stub/stub.cpp b/src/burn/stub/stub.cpp
index 0cb202e0..090a8dbb 100644
--- a/src/burn/stub/stub.cpp
+++ b/src/burn/stub/stub.cpp
@@ -101,6 +101,8 @@ static void CALLBACK BurnTraceError(
101 101
102 if (fLog) 102 if (fLog)
103 { 103 {
104 DutilSuppressTraceErrorSource();
104 LogErrorStringArgs(hrError, szFormat, args); 105 LogErrorStringArgs(hrError, szFormat, args);
106 DutilUnsuppressTraceErrorSource();
105 } 107 }
106} 108}
diff --git a/src/libs/dutil/WixToolset.DUtil/dutil.cpp b/src/libs/dutil/WixToolset.DUtil/dutil.cpp
index 56b85207..dd4fa8bf 100644
--- a/src/libs/dutil/WixToolset.DUtil/dutil.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/dutil.cpp
@@ -30,6 +30,8 @@ static REPORT_LEVEL Dutil_rlCurrentTrace = REPORT_STANDARD;
30static BOOL Dutil_fTraceFilenames = FALSE; 30static BOOL Dutil_fTraceFilenames = FALSE;
31static DUTIL_CALLBACK_TRACEERROR vpfnTraceErrorCallback = NULL; 31static DUTIL_CALLBACK_TRACEERROR vpfnTraceErrorCallback = NULL;
32 32
33thread_local static DWORD vtdwSuppressTraceErrorSource = 0;
34
33 35
34DAPI_(HRESULT) DutilInitialize( 36DAPI_(HRESULT) DutilInitialize(
35 __in_opt DUTIL_CALLBACK_TRACEERROR pfnTraceErrorCallback 37 __in_opt DUTIL_CALLBACK_TRACEERROR pfnTraceErrorCallback
@@ -48,6 +50,28 @@ DAPI_(void) DutilUninitialize()
48 vpfnTraceErrorCallback = NULL; 50 vpfnTraceErrorCallback = NULL;
49} 51}
50 52
53DAPI_(BOOL) DutilSuppressTraceErrorSource()
54{
55 if (DWORD_MAX == vtdwSuppressTraceErrorSource)
56 {
57 return FALSE;
58 }
59
60 ++vtdwSuppressTraceErrorSource;
61 return TRUE;
62}
63
64DAPI_(BOOL) DutilUnsuppressTraceErrorSource()
65{
66 if (0 == vtdwSuppressTraceErrorSource)
67 {
68 return FALSE;
69 }
70
71 --vtdwSuppressTraceErrorSource;
72 return TRUE;
73}
74
51/******************************************************************* 75/*******************************************************************
52Dutil_SetAssertModule 76Dutil_SetAssertModule
53 77
@@ -427,8 +451,9 @@ DAPIV_(void) Dutil_TraceErrorSource(
427 ... 451 ...
428 ) 452 )
429{ 453{
454 // if this callback is currently suppressed, or
430 // if this is NOT an error report and we're not logging at this level, bail 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)
432 { 457 {
433 return; 458 return;
434 } 459 }
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/dutil.h b/src/libs/dutil/WixToolset.DUtil/inc/dutil.h
index fc9ec0f4..52da066c 100644
--- a/src/libs/dutil/WixToolset.DUtil/inc/dutil.h
+++ b/src/libs/dutil/WixToolset.DUtil/inc/dutil.h
@@ -41,6 +41,23 @@ HRESULT DAPI DutilInitialize(
41*******************************************************************/ 41*******************************************************************/
42void DAPI DutilUninitialize(); 42void DAPI DutilUninitialize();
43 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*******************************************************************/
53BOOL DAPI DutilSuppressTraceErrorSource();
54
55/********************************************************************
56 DutilUnsuppressTraceErrorSource - opposite of DutilSuppressTraceErrorSource.
57
58*******************************************************************/
59BOOL DAPI DutilUnsuppressTraceErrorSource();
60
44void DAPI Dutil_SetAssertModule(__in HMODULE hAssertModule); 61void DAPI Dutil_SetAssertModule(__in HMODULE hAssertModule);
45void DAPI Dutil_SetAssertDisplayFunction(__in DUTIL_ASSERTDISPLAYFUNCTION pfn); 62void DAPI Dutil_SetAssertDisplayFunction(__in DUTIL_ASSERTDISPLAYFUNCTION pfn);
46void DAPI Dutil_Assert(__in_z LPCSTR szFile, __in int iLine); 63void DAPI Dutil_Assert(__in_z LPCSTR szFile, __in int iLine);