[Help-gnutls] Re: Strange error in multi-threads

Simon Josefsson jas at extundo.com
Tue Oct 10 14:53:07 CEST 2006


Unknown <prog1 at yobinario.com> writes:

> Hello,
> How to synchronize to run only one TLS session?  How to wait for another
> trhead?
>
> I use  gnutls_global_init () in thread.

You'll need to use a mutex from the thread package you use on each
gnutls_session variable before (at least) each call to
gnutls_record_send and gnutls_record_recv.

All functions that modify some internal state in a gnutls_session
variable that affects the TLS record protocol need to be protected.

E.g., pthread:

pthread_mutex_lock (&sessionlock);
gnutls_record_send (&session, buf, buflen);
pthread_mutex_unlock (&sessionlock);

You'll need to keep one mutex variable per session variable.  And
check error codes etc...

Hm.  Perhaps there should be an API to tell GnuTLS to call a
particular callback function before/after each use of a function that
modify the gnutls_session state.

/Simon

>
>
>
> El dom, 01-10-2006 a las 16:50 +0200, Eric Leblond escribió:
>> Oups, 
>> 
>> Le dimanche 01 octobre 2006 à 16:45 +0200, Eric Leblond a écrit :
>> > Le dimanche 01 octobre 2006 à 15:51 +0200, Unknown a écrit :
>> > > Hello,
>> > > Have any problem gnutls with threads? Need special parameters?
>> > > Need special conditions?
>> > 
>> > Yes, the main thing to know is that you can use a single session
>> > simultaneously in different threads.
>> 
>> That was :
>> "You can't use a TLS session simultaneously in different threads"
>> 
>> Sorry for the mistake...
>> --
>> Eric
>> 
>> > 
>> > BR,
>> > 
>> > > 
>> > > Any suggestion are wellcome.
>> > > 
>> > > 
>> > > _______________________________________________
>> > > Help-gnutls mailing list
>> > > Help-gnutls at gnu.org
>> > > http://lists.gnu.org/mailman/listinfo/help-gnutls
>> > 
>> > 
>> > 
>> > _______________________________________________
>> > Help-gnutls mailing list
>> > Help-gnutls at gnu.org
>> > http://lists.gnu.org/mailman/listinfo/help-gnutls
>> 





More information about the Gnutls-help mailing list