File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/Servers/IIS/AspNetCoreModuleV2/RequestHandlerLib Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,17 @@ FILE_WATCHER::FILE_WATCHER() :
2626 TRUE , // manual reset event
2727 FALSE , // not set
2828 nullptr ); // name
29+
30+ // Use of TerminateThread for the file watcher thread was eliminated in favor of an event-based
31+ // approach. Out of an abundance of caution, we are temporarily adding an environment variable
32+ // to allow falling back to TerminateThread usage. If all goes well, this will be removed in a
33+ // future release.
34+ m_fRudeThreadTermination = false ;
35+ auto enableThreadTerminationValue = Environment::GetEnvironmentVariableValue (L" ASPNETCORE_FILE_WATCHER_THREAD_TERMINATION" );
36+ if (enableThreadTerminationValue.has_value ())
37+ {
38+ m_fRudeThreadTermination = (enableThreadTerminationValue.value () == L" 1" );
39+ }
2940}
3041
3142FILE_WATCHER::~FILE_WATCHER ()
@@ -61,6 +72,12 @@ void FILE_WATCHER::WaitForMonitor(DWORD dwRetryCounter)
6172 if (!m_fThreadExit)
6273 {
6374 LOG_INFO (L" File watcher thread didn't seem to exit." );
75+
76+ if (m_fRudeThreadTermination)
77+ {
78+ LOG_INFO (L" File watcher thread was terminated." );
79+ TerminateThread (m_hChangeNotificationThread, 1 );
80+ }
6481 }
6582}
6683
Original file line number Diff line number Diff line change @@ -76,4 +76,5 @@ class FILE_WATCHER{
7676 DWORD m_shutdownTimeout;
7777 OVERLAPPED _overlapped;
7878 std::unique_ptr<AppOfflineTrackingApplication, IAPPLICATION_DELETER> _pApplication;
79+ bool m_fRudeThreadTermination;
7980};
You can’t perform that action at this time.
0 commit comments