Skip to content

Commit b4ea78a

Browse files
committed
Removing copy on shutdown
1 parent c3cba6d commit b4ea78a

File tree

13 files changed

+37
-39
lines changed

13 files changed

+37
-39
lines changed

src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/applicationinfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ APPLICATION_INFO::CreateApplication(IHttpContext& pHttpContext)
9393
errorContext.statusCode = 500i16;
9494
errorContext.subStatusCode = 0i16;
9595

96-
9796
const auto hr = TryCreateApplication(pHttpContext, options, errorContext);
9897

9998
if (FAILED_LOG(hr))

src/Servers/IIS/AspNetCoreModuleV2/CommonLibTests/inprocess_application_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace InprocessTests
3939
{"InProcessExeLocation", exePath.data()}
4040
};
4141

42-
IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, application, std::move(requestHandlerConfig), parameters.data(), 1);
42+
IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, application, std::move(requestHandlerConfig), parameters.data(), 1, std::wstring());
4343

4444
ASSERT_STREQ(app->QueryExeLocation().c_str(), L"hello");
4545
}
@@ -59,7 +59,7 @@ namespace InprocessTests
5959
.WillByDefault(testing::Return(L""));
6060

6161
auto requestHandlerConfig = std::unique_ptr<InProcessOptions>(MockInProcessOptions::CreateConfig());
62-
IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, application, std::move(requestHandlerConfig), nullptr, 0);
62+
IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, application, std::move(requestHandlerConfig), nullptr, 0, std::wstring());
6363

6464
ASSERT_STREQ(app->QueryApplicationVirtualPath().c_str(), L"/SECTION5");
6565
}
@@ -79,7 +79,7 @@ namespace InprocessTests
7979
.WillByDefault(testing::Return(L""));
8080

8181
auto requestHandlerConfig = std::unique_ptr<InProcessOptions>(MockInProcessOptions::CreateConfig());
82-
IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, application, std::move(requestHandlerConfig), nullptr, 0);
82+
IN_PROCESS_APPLICATION *app = new IN_PROCESS_APPLICATION(server, application, std::move(requestHandlerConfig), nullptr, 0, std::wstring());
8383

8484
ASSERT_STREQ(app->QueryApplicationVirtualPath().c_str(), L"/");
8585
}

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/ShuttingDownApplication.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class ShuttingDownHandler : public REQUEST_HANDLER
3131
class ShuttingDownApplication : public InProcessApplicationBase
3232
{
3333
public:
34-
ShuttingDownApplication(IHttpServer& pHttpServer, IHttpApplication& pHttpApplication)
35-
: InProcessApplicationBase(pHttpServer, pHttpApplication, std::wstring())
34+
ShuttingDownApplication(IHttpServer& pHttpServer, IHttpApplication& pHttpApplication, std::wstring shadowCopy)
35+
: InProcessApplicationBase(pHttpServer, pHttpApplication, shadowCopy)
3636
{
3737
}
3838

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/StartupExceptionApplication.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ class StartupExceptionApplication : public InProcessApplicationBase
1818
const std::string& errorPageContent,
1919
USHORT statusCode,
2020
USHORT subStatusCode,
21-
const std::string& statusText)
21+
const std::string& statusText,
22+
std::wstring shadowCopy)
2223
: m_disableLogs(disableLogs),
2324
m_HR(hr),
2425
m_error(errorPageContent),
2526
m_statusCode(statusCode),
2627
m_subStatusCode(subStatusCode),
2728
m_statusText(std::move(statusText)),
28-
InProcessApplicationBase(pServer, pApplication, std::wstring())
29+
InProcessApplicationBase(pServer, pApplication, shadowCopy)
2930
{
3031
}
3132

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ CreateApplication(
103103
{
104104
TraceContextScope traceScope(FindParameter<IHttpTraceContext*>("TraceContext", pParameters, nParameters));
105105
const auto pSite = FindParameter<IHttpSite*>("Site", pParameters, nParameters);
106+
const auto shadowCopyPtr = FindParameter<PCWSTR>("ShadowCopyDirectory", pParameters, nParameters);
106107

107108
try
108109
{
@@ -113,7 +114,7 @@ CreateApplication(
113114
// means that server is shutting does and request arrived in the meantime
114115
if (g_fInProcessApplicationCreated)
115116
{
116-
*ppApplication = new ShuttingDownApplication(*pServer, *pHttpApplication);
117+
*ppApplication = new ShuttingDownApplication(*pServer, *pHttpApplication, shadowCopyPtr);
117118
return S_OK;
118119
}
119120

@@ -128,7 +129,7 @@ CreateApplication(
128129
errorContext.generalErrorType = "ASP.NET Core app failed to start";
129130
errorContext.errorReason = "<ul><li>The app failed to start</li><li>The app started but then stopped</li><li>The app started but threw an exception during startup</li></ul>";
130131

131-
if (!FAILED_LOG(hr = IN_PROCESS_APPLICATION::Start(*pServer, pSite, *pHttpApplication, pParameters, nParameters, inProcessApplication, errorContext)))
132+
if (!FAILED_LOG(hr = IN_PROCESS_APPLICATION::Start(*pServer, pSite, *pHttpApplication, pParameters, nParameters, inProcessApplication, errorContext, shadowCopyPtr)))
132133
{
133134
*ppApplication = inProcessApplication.release();
134135
}
@@ -154,7 +155,8 @@ CreateApplication(
154155
content,
155156
errorContext.statusCode,
156157
errorContext.subStatusCode,
157-
"Internal Server Error");
158+
"Internal Server Error",
159+
shadowCopyPtr);
158160

159161
RETURN_IF_FAILED(pErrorApplication->StartMonitoringAppOffline());
160162
*ppApplication = pErrorApplication.release();

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ IN_PROCESS_APPLICATION::IN_PROCESS_APPLICATION(
2121
IHttpApplication& pApplication,
2222
std::unique_ptr<InProcessOptions> pConfig,
2323
APPLICATION_PARAMETER* pParameters,
24-
DWORD nParameters) :
25-
InProcessApplicationBase(pHttpServer,
26-
pApplication,
27-
FindParameter<PCWSTR>("ShadowCopyDirectory", pParameters, nParameters)),
24+
DWORD nParameters,
25+
std::wstring shadowCopy) :
26+
InProcessApplicationBase(pHttpServer, pApplication, shadowCopy),
2827
m_Initialized(false),
2928
m_blockManagedCallbacks(true),
3029
m_waitForShutdown(true),
@@ -250,7 +249,7 @@ IN_PROCESS_APPLICATION::ExecuteApplication()
250249
LOG_INFOF(L"Setting dll directory to %s", currentDirectory.c_str());
251250
}
252251

253-
// I think I still want this to be the current directory
252+
// Keep as original directory
254253
LOG_LAST_ERROR_IF(!SetCurrentDirectory(this->QueryApplicationPhysicalPath().c_str()));
255254

256255
LOG_INFOF(L"Setting current directory to %s", this->QueryApplicationPhysicalPath().c_str());
@@ -414,14 +413,15 @@ HRESULT IN_PROCESS_APPLICATION::Start(
414413
APPLICATION_PARAMETER* pParameters,
415414
DWORD nParameters,
416415
std::unique_ptr<IN_PROCESS_APPLICATION, IAPPLICATION_DELETER>& application,
417-
ErrorContext& errorContext)
416+
ErrorContext& errorContext,
417+
std::wstring shadowCopy)
418418
{
419419
try
420420
{
421421
std::unique_ptr<InProcessOptions> options;
422422
THROW_IF_FAILED(InProcessOptions::Create(pServer, pSite, pHttpApplication, options));
423423
application = std::unique_ptr<IN_PROCESS_APPLICATION, IAPPLICATION_DELETER>(
424-
new IN_PROCESS_APPLICATION(pServer, pHttpApplication, std::move(options), pParameters, nParameters));
424+
new IN_PROCESS_APPLICATION(pServer, pHttpApplication, std::move(options), pParameters, nParameters, shadowCopy));
425425
THROW_IF_FAILED(application->LoadManagedApplication(errorContext));
426426
return S_OK;
427427
}

src/Servers/IIS/AspNetCoreModuleV2/InProcessRequestHandler/inprocessapplication.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class IN_PROCESS_APPLICATION : public InProcessApplicationBase
2323
IHttpApplication& pApplication,
2424
std::unique_ptr<InProcessOptions> pConfig,
2525
APPLICATION_PARAMETER *pParameters,
26-
DWORD nParameters);
26+
DWORD nParameters,
27+
std::wstring shadowCopy);
2728

2829
~IN_PROCESS_APPLICATION();
2930

@@ -114,7 +115,8 @@ class IN_PROCESS_APPLICATION : public InProcessApplicationBase
114115
APPLICATION_PARAMETER* pParameters,
115116
DWORD nParameters,
116117
std::unique_ptr<IN_PROCESS_APPLICATION, IAPPLICATION_DELETER>& application,
117-
ErrorContext& errorContext);
118+
ErrorContext& errorContext,
119+
std::wstring shadowCopy);
118120

119121
private:
120122
struct ExecuteClrContext: std::enable_shared_from_this<ExecuteClrContext>
@@ -178,7 +180,6 @@ class IN_PROCESS_APPLICATION : public InProcessApplicationBase
178180

179181
inline static const LPCSTR s_exeLocationParameterName = "InProcessExeLocation";
180182

181-
182183
VOID
183184
UnexpectedThreadExit(const ExecuteClrContext& context) const;
184185

src/Servers/IIS/AspNetCoreModuleV2/OutOfProcessRequestHandler/dllmain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ CreateApplication(
252252
{
253253
TraceContextScope traceScope(FindParameter<IHttpTraceContext*>("TraceContext", pParameters, nParameters));
254254
auto pSite = FindParameter<IHttpSite*>("Site", pParameters, nParameters);
255+
auto shadowCopy = FindParameter<PCWSTR> ("ShadowCopyDirectory", pParameters, nParameters);
255256

256257
InitializeGlobalConfiguration(pServer);
257258

@@ -261,7 +262,7 @@ CreateApplication(
261262

262263
RETURN_IF_FAILED(EnsureOutOfProcessInitializtion(pHttpApplication));
263264

264-
std::unique_ptr<OUT_OF_PROCESS_APPLICATION> pApplication = std::make_unique<OUT_OF_PROCESS_APPLICATION>(*pHttpApplication, std::move(pRequestHandlerConfig));
265+
std::unique_ptr<OUT_OF_PROCESS_APPLICATION> pApplication = std::make_unique<OUT_OF_PROCESS_APPLICATION>(*pHttpApplication, std::move(pRequestHandlerConfig), shadowCopy);
265266

266267
RETURN_IF_FAILED(pApplication->Initialize());
267268
RETURN_IF_FAILED(pApplication->StartMonitoringAppOffline());

src/Servers/IIS/AspNetCoreModuleV2/OutOfProcessRequestHandler/outprocessapplication.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
OUT_OF_PROCESS_APPLICATION::OUT_OF_PROCESS_APPLICATION(
99
IHttpApplication& pApplication,
10-
std::unique_ptr<REQUESTHANDLER_CONFIG> pConfig) :
11-
AppOfflineTrackingApplication(pApplication, std::wstring()),
10+
std::unique_ptr<REQUESTHANDLER_CONFIG> pConfig,
11+
std::wstring shadowCopy) :
12+
AppOfflineTrackingApplication(pApplication, shadowCopy),
1213
m_fWebSocketSupported(WEBSOCKET_STATUS::WEBSOCKET_UNKNOWN),
1314
m_pConfig(std::move(pConfig))
1415
{

src/Servers/IIS/AspNetCoreModuleV2/OutOfProcessRequestHandler/outprocessapplication.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class OUT_OF_PROCESS_APPLICATION : public AppOfflineTrackingApplication
1717
public:
1818
OUT_OF_PROCESS_APPLICATION(
1919
IHttpApplication& pApplication,
20-
std::unique_ptr<REQUESTHANDLER_CONFIG> pConfig);
20+
std::unique_ptr<REQUESTHANDLER_CONFIG> pConfig,
21+
std::wstring shadowCopy);
2122

2223
__override
2324
~OUT_OF_PROCESS_APPLICATION() override;

0 commit comments

Comments
 (0)