cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl multithreading

From: Török Edvin <edwintorok_at_gmail.com>
Date: Fri, 22 Sep 2006 19:46:28 +0300

On 9/22/06, Jamie Lokier <jamie_at_shareable.org> wrote:
> Török Edvin wrote:
> > However I don't understand why the suggested pthread_getspecific fix
> > can't be used _if_ pthreads is available. 'pthread_getspecific' is
> > part of POSIX Threads extension, and _if_ it is available, then you
> > should add support for it. It is not just adding support for some
> > weird threading system/API/style/whatever, it is an IEEE standard!
> > [http://www.opengroup.org/onlinepubs/009695399/functions/pthread_setspecific.html]
> >
> > The original 'patch' needed the client to use pthread_setspecific, but
> > that can be moved into curl_easy_init.
>
> Beware that pthread_getspecific() is not async-signal-safe on some
> platforms, and in the POSIX standards.
>
> One platform where it is definitely not safe is LinuxThreads when the
> program uses sigaltstack().
>
> Async-signal-safety applies to functions called from the alarm signal.

You are right, combining pthred_getspecific with signals doesn't work.
Libcurl should then use some sort of per-thread alarms as described in:
http://www.cs.umu.se/kurser/TDBC64/VT03/pthreads/pthread-primer.pdf#search=%22per-thread%20alarm%20pthread%22

Since you know more about signals&pthread than I do, could you suggest
such an implementation?

Best regards,
Edwin
Received on 2006-09-22