Re: Help with Failure

Giganews Newsgroups
Subject: Re: Help with Failure
Posted by:  Yahia El-Qasem (
Date: Sun, 31 Aug 2003

"Phil Shrimpton" <> schrieb im Newsbeitrag
> So my questions are...
> - What do people think would cause the TidListerner thread to
> 'disappear'

I see such behaviour in multi-threaded apps with and wthout Indy...
Experience up to now is that there is one or more of the following :

a) an app-code related exception occurs within the thread... which is not

b) somewhere in the app-code there is some memory overwrite / overrun...
    the effect shows up later...

Another guess could be that there are perhaps differences in SP level / OS
version / file system / network connection...

> - Ideas for additional error logging and other logging to help track
> down the problem.

Log connections : when, from which IP, what sort of request...
This way you could find out what the last request was before / when the
listener thread ceases...
perhaps there is a client sending malicious request or dying in the middle
of the conversation and thus causing the server to behave strange...

> - How to detect failure, and best way to recover from it.

To detect whether the thread has terminated or not you could go the
following way :

Start up your TidTCPServer from a special thread - this thread should save
the Handle value of TidListerner and do periodically the following :

Call GetExitCodeThread ( see Win32 API ) on the saved Handle value - as long
as you get STILL_ACTIVE back there should be no problem...
when you get something else back you could shutdown the TidTCPServer and
restart it... after restarting you will have to update the old saved value
of Handle with the new one of Handle ( TidListerner )...

BUT if the reason for things you see is somehow memory leak related then the
above perhaps won't help because the restart could fail...

> I am able to post code snippets/units if anyone wishes to have a look,
> but due to the sensitivity of some of the code, I am unable to post the
> complete, compileable system.

For further investigation and suggestions it would help to see some actual
code ( esp. the code executing within the listener thread... )...
It would help to know what the system really does - for example is there a
DB access to serve the client request ? is there file or registry access to
server client request ? etc.



In response to

Help with Failure posted by Phil Shrimpton on Sun, 31 Aug 2003