Note that there are some explanatory texts on larger screens.

plurals
  1. POAnother TIdTCPServer deadlock situation
    text
    copied!<p>I'm having the known issue: IdTCPServer hangs while trying to deactivate it. I've read lots of articles concerning such problem and I'm aware of the deadlock happening. But it's difficult for me to understand which code exactly causes the problem. My app doesn't have even a window so the synchronized call to VCL component isn't the reason. Got 2 event handlers OnConnect and OnExecute. The problem appears in OnConnect. The code:<br /></p> <pre><code>TMyServer = class ... private FServer: TIdTCPServer; ... end; TMyServer.ServerConnect(AContext...); //onconnect begin try if not Condition then begin ... AContext.Connection.Disconnect; Stop; end else Start; except on E: Exception do if E is EIdException then raise; ... end; TMyServer.Start; begin ... FServer.active := true; FServer.StartListening; ... end; TMyServer.Stop; begin ... FServer.StopListening; FServer.Active := false; ... end; TMyServer.ServerExecute(AContext...); //onexecute begin LLine := AContext.Connection.IOHandler.ReadLn; case (LLine) of ... end; end; </code></pre> <p>The code of ServerExecute is quite huge so I won't post it here. Besides I suppose the problem isn't in it.<br /> When the client connects to the server and Condition is false the server tries to disconnect this client and hangs on the line <code>FServer.Active := false;</code><br /> I've already excluded all the logging from the code (I thought the problem was in the threads access to log file). So in the event handlers there are only calculations and nothing which can cause the deadlock). I've read about re-raising of Indy exceptions but that didn't help me too.<br /> I would appreciate any help and explanation cause I think I don't fully understand the purpose of this situation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload