Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disconnected TCPServer thread won't terminate
#5
(04-18-2022, 08:15 PM)rlebeau Wrote: And, what do AdminSessionList, AdminSessionUpdate, PlayerSessionList, SessionUpdate, and LogData look like?  You are accessing a lot of shared data across thread boundaries, so I hope you are adequately and safely synchronizing access to your shared data.

Yes, those lists are TObjects with properties protected by getters, setters, and functions wrapped in TMultiReadExclusiveWriteSynchronizer blocks. I'm pretty confident those are solid as they've been working for years.


Quote:That would be an ideal spot to disconnect, eg:

Code:
if (Key = '') or // invalid websocket header
  ((not Admin) and (not gvar.Running)) then  // offline for players
begin
  AContext.Connection.Disconnect;
  Exit;
end;

That's exactly how it was before when I discovered the un-terminated threads. I only moved the disconnects to OnExecute to see if it would make any difference but it did not.

What would happen if I tried to terminate the thread myself like this:

Code:
AContext.Connection.Disconnect;  // rogue connection
TIdYarnofThread(AContext.Yarn).Thread.Terminate;  // uses IdSchedulerofThread

I saw that in another StackOverFlow post.  I would of course prefer to figure out the real problem.
Reply


Messages In This Thread
RE: Disconnected TCPServer thread won't terminate - by kbriggs - 04-18-2022, 08:58 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)