Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Nov : TIdTcpServer closing problem

www.cryer.info
Managed Newsgroup Archive

TIdTcpServer closing problem

Subject:TIdTcpServer closing problem
Posted by:"Krzysztof Kozłowski" (kozlo..@poczta.onet.pl)
Date:Thu, 2 Nov 2006 22:13:02

Hello there!

I have a problem while closing down the TIdTcpServer - it hangs up when
I set the Active property to false. I assume that some deadlock occurs
then. A have looked at the call stack of my application, and here is the
scenario which causes the server to stop:

1. I get the ServerExecute event - I receive some information
2. I parse the information and decide to store something in the database
3. At this particular moment the database connection has just been broken
4. In case of a broken database connection my program shuts everything
down, the server connections are amongst the other things to become shut.

It seems, that I indirectly set the TIdTcpServer.Active to false within
the ServerExecute event; and I guess that can be the reason of a
deadlock. However the scenario above should remain unchanged. I have
tried the following, but neither did help:

1. Instead of setting the TIdTcpServer.Active to false directly after I
find out the DB connection is broken, I post a message to my app window
(PostMessage), and it's the message handler which sets the
TIdTcpServer.Active to false.
2. After I find out the DB connection is broken I start a timer, which
sets TIdTcpServer.Active to false after a second.

Does anyone have any other idea for implementation of such scenario?

Regards,

Krzysztof

Replies:

www.cryer.info
Managed Newsgroup Archive