Skip to content

Commit 60fb60b

Browse files
Add env var to fall back to termination.
1 parent ca4fbf7 commit 60fb60b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Servers/IIS/AspNetCoreModuleV2/RequestHandlerLib/filewatcher.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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

3142
FILE_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

src/Servers/IIS/AspNetCoreModuleV2/RequestHandlerLib/filewatcher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
};

0 commit comments

Comments
 (0)