When it's best to use a TSslDynamicLock or TSslStaticLock  ?

Paul


----- Original Message ----- From: "Arno Garrels" <arno.garr...@gmx.de>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Saturday, March 31, 2012 12:01 PM
Subject: Re: [twsocket] DomainKeys/DKIM signature


Max Terentiev wrote:

One more question: looks like OpenSSL contains all necessary
functions (RSA and SHA-256 ciphers).

But can I use this functions inside my sending threads ?
It's thread safe ?

OpenSSL is not thread-safe unless you provide callbacks for the required
locking. The components TSslDynamicLock and TSslStaticLock are made for this purpose. Read the comments in OverbyteIcsThrdLock.pas.
Create _one_ of those components in your main thread and set property
Enabled to True before any other call to OpenSSL, that's it.
In order to avoid memory leaks use this code at the end of TThread's
Execute method:
         //* thread-local cleanup */
           if @f_ERR_remove_thread_state <> nil then
               f_ERR_remove_thread_state(nil) // OSSL v1.0.0+
           else
               f_ERR_remove_state(0); // deprecated

For debugging you should define "OPENSSL_USE_DELPHI_MM" in the project
options. If defined OpenSSL will use current Delphi memory manager which
makes detection of OpenSSL memory leaks possible. You will however notice that there's always one (or two?) small leak(s) in OpenSSL on shutting down the application, this can be safely ignored.

--
Arno



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to