Skip to content

Commit cc0c516

Browse files
Tomasz JanczukTomasz Janczuk
Tomasz Janczuk
authored and
Tomasz Janczuk
committed
fix #212: add iisnode-debug header feature
1 parent c953d5b commit cc0c516

28 files changed

+238
-2
lines changed

Diff for: src/config/iisnode_dev_x64.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/config/iisnode_dev_x86_on_x64.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/config/iisnode_dev_x86_on_x86.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/config/iisnode_express_schema.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/config/iisnode_express_schema_x64.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/config/iisnode_schema.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/config/iisnode_schema_x64.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/config/iisnode_schema_x64_wow.xml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Details at http://learn.iis.net/page.aspx/241/configuration-extensibility/
4343
<attribute name="gracefulShutdownTimeout" type="uint" defaultValue="60000"/>
4444
<attribute name="logDirectory" type="string" expanded="true" defaultValue="iisnode"/>
4545
<attribute name="debuggingEnabled" type="bool" defaultValue="true"/>
46+
<attribute name="debugHeaderEnabled" type="bool" defaultValue="false"/>
4647
<attribute name="debuggerPathSegment" type="string" expanded="true" defaultValue="debug"/>
4748
<attribute name="debuggerPortRange" type="string" expanded="true" defaultValue="5058-6058"/>
4849
<attribute name="maxLogFileSizeInKB" type="uint" defaultValue="128"/>

Diff for: src/iisnode/cactiverequestpool.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ CActiveRequestPool::~CActiveRequestPool()
1111
DeleteCriticalSection(&this->syncRoot);
1212
}
1313

14+
DWORD CActiveRequestPool::GetRequestCount()
15+
{
16+
return this->requestCount;
17+
}
18+
1419
HRESULT CActiveRequestPool::Add(CNodeHttpStoredContext* context)
1520
{
1621
HRESULT hr;

Diff for: src/iisnode/cactiverequestpool.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class CActiveRequestPool
1919
HRESULT Add(CNodeHttpStoredContext* context);
2020
HRESULT Remove();
2121
void SignalWhenDrained(HANDLE drainHandle);
22+
DWORD GetRequestCount();
2223
};
2324

2425
#endif

Diff for: src/iisnode/cmoduleconfiguration.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CModuleConfiguration::CModuleConfiguration()
1010
: nodeProcessCommandLine(NULL), logDirectory(NULL), debuggerPathSegment(NULL),
1111
debugPortRange(NULL), debugPortStart(0), debugPortEnd(0), node_env(NULL), watchedFiles(NULL),
1212
enableXFF(FALSE), promoteServerVars(NULL), promoteServerVarsRaw(NULL), configOverridesFileName(NULL),
13-
configOverrides(NULL), interceptor(NULL)
13+
configOverrides(NULL), interceptor(NULL), debugHeaderEnabled(FALSE)
1414
{
1515
InitializeSRWLock(&this->srwlock);
1616
}
@@ -659,6 +659,10 @@ HRESULT CModuleConfiguration::ApplyConfigOverrideKeyValue(IHttpContext* context,
659659
{
660660
CheckError(GetBOOL(valueStart, &config->debuggingEnabled));
661661
}
662+
else if (0 == strcmpi(keyStart, "debugHeaderEnabled"))
663+
{
664+
CheckError(GetBOOL(valueStart, &config->debugHeaderEnabled));
665+
}
662666
else if (0 == strcmpi(keyStart, "enableXFF"))
663667
{
664668
CheckError(GetBOOL(valueStart, &config->enableXFF));
@@ -1200,6 +1204,12 @@ BOOL CModuleConfiguration::GetDebuggingEnabled(IHttpContext* ctx)
12001204
GETCONFIG(debuggingEnabled)
12011205
}
12021206

1207+
BOOL CModuleConfiguration::GetDebugHeaderEnabled(IHttpContext* ctx)
1208+
{
1209+
GETCONFIG(debugHeaderEnabled)
1210+
}
1211+
1212+
12031213
LPWSTR CModuleConfiguration::GetNodeEnv(IHttpContext* ctx)
12041214
{
12051215
GETCONFIG(node_env)

Diff for: src/iisnode/cmoduleconfiguration.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class CModuleConfiguration : public IHttpStoredContext
2626
DWORD maxLogFiles;
2727
BOOL loggingEnabled;
2828
BOOL debuggingEnabled;
29+
BOOL debugHeaderEnabled;
2930
LPWSTR debugPortRange;
3031
DWORD debugPortStart;
3132
DWORD debugPortEnd;
@@ -87,6 +88,7 @@ class CModuleConfiguration : public IHttpStoredContext
8788
static DWORD GetMaxLogFiles(IHttpContext* ctx);
8889
static BOOL GetLoggingEnabled(IHttpContext* ctx);
8990
static BOOL GetDebuggingEnabled(IHttpContext* ctx);
91+
static BOOL GetDebugHeaderEnabled(IHttpContext* ctx);
9092
static HRESULT GetDebugPortRange(IHttpContext* ctx, DWORD* start, DWORD* end);
9193
static LPWSTR GetNodeEnv(IHttpContext* ctx);
9294
static BOOL GetDevErrorsEnabled(IHttpContext* ctx);

Diff for: src/iisnode/cnodeapplication.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,13 @@ DWORD CNodeApplication::GetDebugPort()
136136
{
137137
return this->debugPort;
138138
}
139+
140+
DWORD CNodeApplication::GetActiveRequestCount()
141+
{
142+
return this->processManager->GetActiveRequestCount();
143+
}
144+
145+
DWORD CNodeApplication::GetProcessCount()
146+
{
147+
return this->processManager->GetProcessCount();
148+
}

Diff for: src/iisnode/cnodeapplication.h

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class CNodeApplication
3737
NodeDebugCommand GetDebugCommand();
3838
HRESULT Recycle();
3939
DWORD GetDebugPort();
40+
DWORD GetActiveRequestCount();
41+
DWORD GetProcessCount();
4042
};
4143

4244
#endif

Diff for: src/iisnode/cnodeapplicationmanager.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
CNodeApplicationManager::CNodeApplicationManager(IHttpServer* server, HTTP_MODULE_ID moduleId)
44
: server(server), moduleId(moduleId), applications(NULL), asyncManager(NULL), jobObject(NULL),
55
breakAwayFromJobObject(FALSE), fileWatcher(NULL), initialized(FALSE), eventProvider(NULL),
6-
currentDebugPort(0), inspector(NULL)
6+
currentDebugPort(0), inspector(NULL), totalRequests(0)
77
{
88
InitializeSRWLock(&this->srwlock);
99
}
@@ -32,6 +32,11 @@ HRESULT CNodeApplicationManager::Initialize(IHttpContext* context)
3232
return hr;
3333
}
3434

35+
LONG CNodeApplicationManager::GetTotalRequests()
36+
{
37+
return this->totalRequests;
38+
}
39+
3540
HRESULT CNodeApplicationManager::InitializeCore(IHttpContext* context)
3641
{
3742
HRESULT hr;
@@ -177,6 +182,8 @@ HRESULT CNodeApplicationManager::Dispatch(IHttpContext* context, IHttpEventProvi
177182
CheckNull(ctx);
178183
*ctx = NULL;
179184

185+
InterlockedIncrement(&this->totalRequests);
186+
180187
CheckError(CNodeDebugger::GetDebugCommand(context, this->GetEventProvider(), &debugCommand));
181188

182189
switch (debugCommand)

Diff for: src/iisnode/cnodeapplicationmanager.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CNodeApplicationManager
3636
BOOL initialized;
3737
DWORD currentDebugPort;
3838
HMODULE inspector;
39+
LONG totalRequests;
3940

4041
HRESULT DebugRedirect(IHttpContext* context, CNodeHttpStoredContext** ctx);
4142
HRESULT EnsureDebuggedApplicationKilled(IHttpContext* context, CNodeHttpStoredContext** ctx);
@@ -70,6 +71,7 @@ class CNodeApplicationManager
7071
HRESULT Initialize(IHttpContext* context);
7172
HRESULT Dispatch(IHttpContext* context, IHttpEventProvider* pProvider, CNodeHttpStoredContext** ctx);
7273
HRESULT RecycleApplication(CNodeApplication* app);
74+
LONG GetTotalRequests();
7375
};
7476

7577
#endif

Diff for: src/iisnode/cnodehttpstoredcontext.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,8 @@ BOOL CNodeHttpStoredContext::GetRequestPumpStarted()
402402
{
403403
return this->requestPumpStarted;
404404
}
405+
406+
FILETIME* CNodeHttpStoredContext::GetStartTime()
407+
{
408+
return &this->startTime;
409+
}

Diff for: src/iisnode/cnodehttpstoredcontext.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CNodeHttpStoredContext : public IHttpStoredContext
3636
CNodeHttpStoredContext* upgradeContext;
3737
BOOL opaqueFlagSet;
3838
BOOL requestPumpStarted;
39+
FILETIME startTime;
3940

4041
public:
4142

@@ -102,6 +103,7 @@ class CNodeHttpStoredContext : public IHttpStoredContext
102103
BOOL GetOpaqueFlagSet();
103104
void SetRequestPumpStarted();
104105
BOOL GetRequestPumpStarted();
106+
FILETIME* GetStartTime();
105107

106108
static CNodeHttpStoredContext* Get(LPOVERLAPPED overlapped);
107109

Diff for: src/iisnode/cnodeprocess.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,21 @@ CNodeProcessManager* CNodeProcess::GetProcessManager()
332332
return this->processManager;
333333
}
334334

335+
HANDLE CNodeProcess::GetProcess()
336+
{
337+
return this->process;
338+
}
339+
340+
DWORD CNodeProcess::GetPID()
341+
{
342+
return this->pid;
343+
}
344+
345+
DWORD CNodeProcess::GetActiveRequestCount()
346+
{
347+
return this->activeRequestPool.GetRequestCount();
348+
}
349+
335350
HRESULT CNodeProcess::AcceptRequest(CNodeHttpStoredContext* context)
336351
{
337352
HRESULT hr;

Diff for: src/iisnode/cnodeprocess.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ class CNodeProcess
3434

3535
HRESULT Initialize(IHttpContext* context);
3636
CNodeProcessManager* GetProcessManager();
37+
HANDLE GetProcess();
38+
DWORD GetPID();
3739
LPCTSTR GetNamedPipeName();
3840
CConnectionPool* GetConnectionPool();
3941
HRESULT AcceptRequest(CNodeHttpStoredContext* context);
4042
void OnRequestCompleted(CNodeHttpStoredContext* context);
4143
void SignalWhenDrained(HANDLE handle);
4244
char* TryGetLog(IHttpContext* context, DWORD* size);
4345
BOOL HasProcessExited();
46+
DWORD GetActiveRequestCount();
4447
};
4548

4649
#endif

Diff for: src/iisnode/cnodeprocessmanager.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,24 @@ CNodeEventProvider* CNodeProcessManager::GetEventProvider()
390390
{
391391
return this->eventProvider;
392392
}
393+
394+
DWORD CNodeProcessManager::GetActiveRequestCount()
395+
{
396+
DWORD result = 0;
397+
398+
ENTER_SRW_SHARED(this->srwlock)
399+
400+
for (DWORD i = 0; i < this->processCount; i++)
401+
{
402+
result += this->processes[i]->GetActiveRequestCount();
403+
}
404+
405+
LEAVE_SRW_SHARED(this->srwlock)
406+
407+
return result;
408+
}
409+
410+
DWORD CNodeProcessManager::GetProcessCount()
411+
{
412+
return this->processCount;
413+
}

Diff for: src/iisnode/cnodeprocessmanager.h

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class CNodeProcessManager
4646
CNodeEventProvider* GetEventProvider();
4747
long AddRef();
4848
long DecRef();
49+
DWORD GetActiveRequestCount();
50+
DWORD GetProcessCount();
4951
};
5052

5153
#endif

0 commit comments

Comments
 (0)