tong / hxssl

Haxe→C++/Neko OpenSSL bindings
30 stars 45 forks source link

crashes when making requests in multiple threads #55

Closed maxless closed 8 years ago

maxless commented 8 years ago

Test attached. The documentation states that SSL_library_init() is not reentrant and the current implementation does not handle that resulting in random crashes during the reinit.

https://www.openssl.org/docs/manmaster/ssl/SSL_library_init.html

Script.txt

I made a workaround, static flag in the Socket.hx sys/ssl/Socket.hx:

    static var initOnce = false;
    private function initSSL() {
        if (initOnce)
          return;
        initOnce = true;
        SSL_library_init();
        SSL_load_error_strings();
    }

Plus a single google.com request at the start of the application to make sure that the initialization is handled correctly.

The resulting changes work fine except i receive this exception very often:

Custom((1) : An unknown error has occurred.)

This exception is produced by hxssl_SSL_recv() calling SSL_read() but I'm not sure what to do with this.

hexonaut commented 8 years ago

Development on this project is stopping because it's been merged into Haxe core. I would recommend switching over to that version. If the problem persists then file an issue over there.