Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OpenSSL and concurrent read/write
#3
While I'm waiting for a reply I had another thought. This whole thing could be simplified if there was an TEvent type of feature built into the Indy ReadTimeout system. Then I could set ReadTimeout to a large number like 1000 (or even Indefinite) and remove the Sleep. Then leave the outbound write check where it is now and the first ReadByte below it, waiting up to 1 second (or forever) for the next incoming packet. But when another thread was adding something to the outbound queue it would call the equivalent of TEvent.SetEvent to break the ReadByte out of its wait period. Is something like possible? What if another thread set ReadTimeout to 0 (or another small number), would that work? I could then reset ReadTimeout back to 1000 and run the next loop.

Sorry, your reply didn't show until after I posted again but my new question still stands. The memory is not an issue, it's the constant thread switching that slows the whole game when the login capacity is high. I'm trying to maximize that while staying with an Indy thread based system rather than rewriting the whole thing in Node.js. Going with a blocking read only works if I can safely do writes in another thread OR break out of the read timeout when I need to. It appears that the SSL issue eliminates that first option.

If I delete the original Sleep(10) and do this instead:

Code:
if IO.InputBufferIsEmpty then
begin
  IO.CheckForDataOnSource;
  IO.CheckForDisconnect;
  if IO.InputBufferIsEmpty then
  begin
    Sleep(0);
    Exit;
  end;
end;

Wouldn't I still get a 100% CPU spike when nothing much else was going on?
Reply


Messages In This Thread
OpenSSL and concurrent read/write - by kbriggs - 07-04-2026, 12:35 AM
RE: OpenSSL and concurrent read/write - by kbriggs - 07-04-2026, 03:30 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)