04-10-2021, 12:41 AM
(04-09-2021, 06:47 PM)fpctuxe Wrote: After 100000 – 200000 connects, the Server crashes with a memory access error. I found the access error in “IdSSLOpenSSL.pas” in “function TidSSLIOHandlerSocketOpenSSL.Readable”. The SocketClass “fSSLSocket” was nil. Why? I don’t know.
Likely related to this issue:
https://github.com/IndySockets/Indy/issues/218
When TIdSSLIOHandlerSocketOpenSSL is closed, it destroys its fSSLSocket object, rather than just closing the underlying socket connection but leaving fSSLSocket alive.
(04-09-2021, 06:47 PM)fpctuxe Wrote: I changed the source and it works.
I don't fully agree with that "fix", as it is just a workaround, which introduces a new race condition, and does not really address the root issue. But without a better fix, I have accepted and checked it in for now, thanks.
Another workaround I have considered before, but haven't implemented yet, is to have TIdSSLIOHandlerSocketOpenSSL override the virtual SourceIsAvailable() method to return False when fSSLSocket is nil. TIdIOHandler.ReadFromSource() checks SourceIsAvailable() before and after calling Readable(). But this is also causes a subtle race condition, too.