Open chrsteel opened 8 years ago
According to OpenSSL documentation, we need to set locking functions to use it from multiple threads and currently this is not done.
I'm not sure how is it going to be possible to define C callbacks working with mutexes from Perl6 code...
FWIW #34 contains another example showing that using this module from multiple threads currently doesn't work.
FYI IO::Socket::INET is only thread safe if you read a socket in the thread it was created
It's a pity that going from IO::Socket::Async to something like IO::Socket::Async:SSL seems so hard.
And yes, I was already aware of the limitation that each socket can only be used in one thread.
Thank you for the info though! (I now worked around the problem by serializing all SSL-requests in my application.)
You can write a naive SSL Async wrapper in ~50 LoC https://gist.github.com/ugexe/71d82eb4bb5653125bd8
That's great, this should be a module! Hmm.. but its still not thread safe, I presume? If I cannot do concurrent requests, I might probably just as well use IO::Socket::SSL. :-/
I'm not sure if it's thread safe. All the data is fetched with IO::Socket::Async so that data should be able to cross threads unlike INET. But I'm not sure how/if that changes what happens with OpenSSL accessing that data - it was too slow for what I needed so I didn't test it further
There is now an IO::Socket::Async::SSL, which can work across multiple threads (tests for that included in its test suite).
Awesome!! Thank you jnthn!
The following code fails for me and gives the cryptic error message "Cannot unbox a type object":
Note that there is no error if the lines containing
$p2
are removed.The basic Socket:INET seems already to be thread safe. Is there hope for thread safe SSL-sockets?