[gnutls-help] pthread safety

Nikos Mavrogiannopoulos nmav at gnutls.org
Wed Jul 26 16:04:50 CEST 2017

On Sun, Jul 23, 2017 at 5:47 PM, Wei Cheng <chengwei.clx at gmail.com> wrote:
> i want to use to child pthread to handshake with remote peer.
> in my child pthead , i just use gnutls_handshake().
> quetion one:
> can i use pthread_cancel()  to cancel the child pthread regardless of the
> current handshake state ?

gnutls functions were never designed as pthread cancellation points. I
have not thought that much, but I believe your main concern is memory
leaks right? It may be that if you deallocate the session in another
thread it may just work; though you may have to create a stress test
for that to verify that this is possible.

> question two:
> if i have registered the pull/pull_timeout/push funciton with
> pthread_cleanup_push/pthread_cleanup_pop,
> can i cancel the child process?

I assume that you are describing threads (you can always terminate a
process). The answer is as above.


More information about the Gnutls-help mailing list