curl-library
Problem sharing one instance of openssl between curl and pjsip
Date: Tue, 19 Apr 2016 14:00:39 +0000
Hi
I have a .so for Android that encapsulates both pjsip and curl. In turn, both of them depend on openssl so all of them exist as static libs inside the final .so.
The problem is that the sharing of openssl breaks something and I am not yet able to figure out what.
Basically I do something like:
* Start the pjsip stack, a ssl handshake is performed without any problems and we now have a working TLS socket with the sip server.
* Do any http activity with curl
* Break the sip connection, for instance by changing from wifi to 3g. This forces pjsip to try and re-register to the server using a new TLS connection.
The problem is that after curl has been initialised, pjsip is never able to establish a new socket, ever again. The failure is very brief:
!TLS connect() error: Unknown error 494241 [code=494241]
I have tried to figure out what error 494241 means without success.
My current assumption is that the error comes from inside openssl and that by initiating libcurl something shared is destroyed for pjsip. Curl keeps working fine but pjsip is never able to recover, not even after restarting the whole stack (including shutting down curl, which is strange).
If I instead of having pjsip and curl reside in the same .so, split them into two .so files each with their own libssl.a and libcrypto.a it works fine. So the problem appears to be them sharing a context of some kind.
I am not sure if its actually related but OkHttp seems to have had a similar issue at some point:
https://github.com/square/okhttp/issues/184
It might be completely unrelated (fortunately my app does not crash at least) but I wanted to mention it.
So, I do have a solution in the dual .so approach but this increases quite a lot the .apk size of the Android app so I would be really interested in if someone can help me explain the root cause of the issue. It is easy to reproduce so I am happy to provide more info.
Thanks in advance
Johan
________________________________
Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.
Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-04-19