Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

IIS Crashes when a thread is spawn when the life of the th..

 
   Web Hosting Problem Solving Community! (Home) -> IIS RSS
Next:  IIS 6.0 - how to get it  
Author Message
johnmaly

External


Since: May 10, 2004
Posts: 1



(Msg. 1) Posted: Mon May 10, 2004 9:52 pm
Post subject: IIS Crashes when a thread is spawn when the life of the thread is linked to the
Archived from groups: microsoft>public>inetserver>iis (more info?)

Hi All,
We have a Web application built with ASP Code. The ASP Code in turn calls
VC++ dll through a COM Object. The Com Object spawns a worker thread
(thread-A). Then the worker thread spawns another thread (thread-B). The
code in thread-B contains an infinite looping, so that the life of Thread-B
lasts till IIS is Reset. In other words Thread-B runs as long as IIS runs.
But, after running like 5 or 10 minutes IIS crashes.

IIS crashes because of the infinite loop which is purposely put in to retain
the life of the thread till IIS is reset.
If I dont have the infinite loop, it does not crash...
Would appreciate any help on why IIS is crashing. I have included the IIS
message from Eevet Viewer and the code

Thank you for your time,
- John
==========================================================================
IIS Crash message from the Event Viewer (System) is as follows:
==========================================================================
A process serving application pool 'DefaultAppPool' suffered a fatal
communication error with the World Wide Web Publishing Service. The process
id was '3196'. The data field contains the error number.

==========================================================================
The code in the function which is passed to AfxBeginThread, is as follows.
==========================================================================
UINT WorkerThreadCheckWebReportFile(LPVOID pParam)
{

UINT retval = 0;
CWorkerThreadInfo *pActivityThreadinfo;
pActivityThreadinfo = (CWorkerThreadInfo *)pParam;

if (!pActivityThreadinfo)
return retval;

//Set the authentication info for this new thread to be the same as that of
//the parent thread, to ensure this will work properly with OS
authentication
HANDLE hActivityThread = GetCurrentThread();
BOOL bRet = SetThreadToken( &hActivityThread,
pActivityThreadinfo->hToken );

if (!bRet)
{
// Couldn't set the authentication information for this thread
// Pass it back to the primary thread which will return it to the process
pActivityThreadinfo->m_nResult = ERR_AUTHENTICATION_FAILED;
return retval;
}

// End Code added to fix the NT Authentication Issue
TCHAR szDBPath[255];
TCHAR szAppPath[255];
CFDCProcCtrl* pWebActy = NULL;
CTimeSpan tSpan;

try
{
while (1)
{
if (!pfCloseWebActivityFile || !pfCheckWebActivityFile)
return 1;

for (int iCount = 0; iCount < vpProcCtrlList.size(); iCount++)
{
pWebActy = vpProcCtrlList[iCount];
CString sDBPath = pWebActy->GetDBPath();
_tcscpy(szAppPath, pActivityThreadinfo->m_sAppPath);
strcpy(szDBPath, sDBPath.GetBuffer(sDBPath.GetLength()));
if (pfCheckWebActivityFile(szAppPath, szDBPath) == 1)
{
pWebActy->TimeSpan(&tSpan);
if (tSpan.GetTotalSeconds() >= 30)
{
pfCloseWebActivityFile(szAppPath, szDBPath);
pWebActy->SetClose();
}
}
}
Sleep(6000);
}

}
catch(...)
{
CloseHandle(hActivityThread);
delete pActivityThreadinfo;
pActivityThreadinfo->m_nResult = ERR_CRL_EXCEPT;
}
CloseHandle(hActivityThread);
delete pActivityThreadinfo;
return 1;
}

==========================================================================

 >> Stay informed about: IIS Crashes when a thread is spawn when the life of the th.. 
Back to top
Login to vote
user1580

External


Since: Apr 03, 2004
Posts: 367



(Msg. 2) Posted: Tue May 11, 2004 6:47 am
Post subject: Re: IIS Crashes when a thread is spawn when the life of the thread is linked to [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"John Maly" <johnmaly.DeleteThis@hotmail.com> wrote in message
news:e6ohBGuNEHA.556@TK2MSFTNGP10.phx.gbl...
 > Hi All,
 > We have a Web application built with ASP Code. The ASP Code in turn calls
 > VC++ dll through a COM Object. The Com Object spawns a worker thread
 > (thread-A). Then the worker thread spawns another thread (thread-B). The

There you go!
You never can be sure about the thread state of the parent process within
IIS. If IIS decides that a thread needs to be returned to the pool, you
really have a problem, you cannot get events on that.
Second, you play with your live Smile when you go out of your COM apartment
within a process. It is against good COM programming practices Smile, yes, you
can/could use a free threaded marshaler, but vbscript/IIS and all together,
it's not advised...

 > code in thread-B contains an infinite looping, so that the life of
Thread-B
 > lasts till IIS is Reset. In other words Thread-B runs as long as IIS runs.
 > But, after running like 5 or 10 minutes IIS crashes.
 >
 > IIS crashes because of the infinite loop which is purposely put in to
retain
 > the life of the thread till IIS is reset.
 > If I dont have the infinite loop, it does not crash...
 > Would appreciate any help on why IIS is crashing. I have included the IIS
 > message from Eevet Viewer and the code
 >
 > Thank you for your time,
 > - John
 > ==========================================================================
 > IIS Crash message from the Event Viewer (System) is as follows:
 > ==========================================================================
 > A process serving application pool 'DefaultAppPool' suffered a fatal
 > communication error with the World Wide Web Publishing Service. The
process
 > id was '3196'. The data field contains the error number.
 >
 > ==========================================================================
 > The code in the function which is passed to AfxBeginThread, is as
follows.
 > ==========================================================================
 > UINT WorkerThreadCheckWebReportFile(LPVOID pParam)
 > {
 >
 > UINT retval = 0;
 > CWorkerThreadInfo *pActivityThreadinfo;
 > pActivityThreadinfo = (CWorkerThreadInfo *)pParam;
 >
 > if (!pActivityThreadinfo)
 > return retval;
 >
 > //Set the authentication info for this new thread to be the same as that
of
 > //the parent thread, to ensure this will work properly with OS
 > authentication
 > HANDLE hActivityThread = GetCurrentThread();
 > BOOL bRet = SetThreadToken( &hActivityThread,
 > pActivityThreadinfo->hToken );
 >
 > if (!bRet)
 > {
 > // Couldn't set the authentication information for this thread
 > // Pass it back to the primary thread which will return it to the
process
 > pActivityThreadinfo->m_nResult = ERR_AUTHENTICATION_FAILED;
 > return retval;
 > }
 >
 > // End Code added to fix the NT Authentication Issue
 > TCHAR szDBPath[255];
 > TCHAR szAppPath[255];
 > CFDCProcCtrl* pWebActy = NULL;
 > CTimeSpan tSpan;
 >
 > try
 > {
 > while (1)
 > {
 > if (!pfCloseWebActivityFile || !pfCheckWebActivityFile)
 > return 1;
 >
 > for (int iCount = 0; iCount < vpProcCtrlList.size(); iCount++)
 > {
 > pWebActy = vpProcCtrlList[iCount];
 > CString sDBPath = pWebActy->GetDBPath();
 > _tcscpy(szAppPath, pActivityThreadinfo->m_sAppPath);
 > strcpy(szDBPath, sDBPath.GetBuffer(sDBPath.GetLength()));
 > if (pfCheckWebActivityFile(szAppPath, szDBPath) == 1)
 > {
 > pWebActy->TimeSpan(&tSpan);
 > if (tSpan.GetTotalSeconds() >= 30)
 > {
 > pfCloseWebActivityFile(szAppPath, szDBPath);
 > pWebActy->SetClose();
 > }
 > }
 > }
 > Sleep(6000);
 > }
 >
 > }
 > catch(...)
 > {
 > CloseHandle(hActivityThread);
 > delete pActivityThreadinfo;
 > pActivityThreadinfo->m_nResult = ERR_CRL_EXCEPT;
 > }
 > CloseHandle(hActivityThread);
 > delete pActivityThreadinfo;
 > return 1;
 > }
 >
 > ==========================================================================
 >
 ><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: IIS Crashes when a thread is spawn when the life of the th.. 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> IIS All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]