9690babf3c625f3b1d9c7fb12a66ccd6ca3f0b0f
[platform/upstream/curl.git] / docs / libcurl / libcurl-thread.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2  "http://www.w3.org/TR/html4/loose.dtd">
3 <html><head>
4 <title>libcurl-thread man page</title>
5 <meta name="generator" content="roffit">
6 <STYLE type="text/css">
7 pre {
8   overflow: auto;
9   margin: 0;
10 }
11
12 P.level0, pre.level0 {
13  padding-left: 2em;
14 }
15
16 P.level1, pre.level1 {
17  padding-left: 4em;
18 }
19
20 P.level2, pre.level2 {
21  padding-left: 6em;
22 }
23
24 span.emphasis {
25  font-style: italic;
26 }
27
28 span.bold {
29  font-weight: bold;
30 }
31
32 span.manpage {
33  font-weight: bold;
34 }
35
36 h2.nroffsh {
37  background-color: #e0e0e0;
38 }
39
40 span.nroffip {
41  font-weight: bold;
42  font-size: 120%;
43  font-family: monospace;
44 }
45
46 p.roffit {
47  text-align: center;
48  font-size: 80%;
49 }
50 </STYLE>
51 </head><body>
52
53 <p class="level0"><a name="NAME"></a><h2 class="nroffsh">NAME</h2>
54 <p class="level0">libcurl-thread - libcurl thread safety <a name="Multi-threading"></a><h2 class="nroffsh">Multi-threading with libcurl</h2>
55 <p class="level0">libcurl is thread safe but has no internal thread synchronization. You may have to provide your own locking should you meet any of the thread safety exceptions below. 
56 <p class="level0"><span Class="bold">Handles.</span> You must <span Class="bold">never</span> share the same handle in multiple threads. You can pass the handles around among threads, but you must never use a single handle from more than one thread at any given time. 
57 <p class="level0"><span Class="bold">Shared objects.</span> You can share certain data between multiple handles by using the share interface but you must provide your own locking and set <a Class="emphasis" href="./curl_share_setopt.html">curl_share_setopt</a> CURLSHOPT_LOCKFUNC and CURLSHOPT_UNLOCKFUNC. <a name="TLS"></a><h2 class="nroffsh">TLS</h2>
58 <p class="level0">If you are accessing HTTPS or FTPS URLs in a multi-threaded manner, you are then of course using the underlying SSL library multi-threaded and those libs might have their own requirements on this issue.  You may need to provide one or two functions to allow it to function properly: 
59 <p class="level0"><a name="OpenSSL"></a><span class="nroffip">OpenSSL</span> 
60 <p class="level1"><a href="http://www.openssl.org/docs/crypto/threads.html">http://www.openssl.org/docs/crypto/threads.html</a>&#35;DESCRIPTION 
61 <p class="level1"><a href="http://curl.haxx.se/libcurl/c/opensslthreadlock.html">http://curl.haxx.se/libcurl/c/opensslthreadlock.html</a> 
62 <p class="level0"><a name="GnuTLS"></a><span class="nroffip">GnuTLS</span> 
63 <p class="level1"><a href="http://gnutls.org/manual/html_node/Thread-safety.html">http://gnutls.org/manual/html_node/Thread-safety.html</a> 
64 <p class="level0"><a name="NSS"></a><span class="nroffip">NSS</span> 
65 <p class="level1">thread-safe already without anything required. 
66 <p class="level0"><a name="PolarSSL"></a><span class="nroffip">PolarSSL</span> 
67 <p class="level1">Required actions unknown. 
68 <p class="level0"><a name="yassl"></a><span class="nroffip">yassl</span> 
69 <p class="level1">Required actions unknown. 
70 <p class="level0"><a name="axTLS"></a><span class="nroffip">axTLS</span> 
71 <p class="level1">Required actions unknown. 
72 <p class="level0"><a name="Secure-Transport"></a><span class="nroffip">Secure-Transport</span> 
73 <p class="level1">The engine is used by libcurl in a way that is fully thread-safe. 
74 <p class="level0"><a name="WinSSL"></a><span class="nroffip">WinSSL</span> 
75 <p class="level1">The engine is used by libcurl in a way that is fully thread-safe. 
76 <p class="level0"><a name="wolfSSL"></a><span class="nroffip">wolfSSL</span> 
77 <p class="level1">The engine is used by libcurl in a way that is fully thread-safe. <a name="Other"></a><h2 class="nroffsh">Other areas of caution</h2>
78 <p class="level0">
79 <p class="level0"><a name="Signals"></a><span class="nroffip">Signals</span> 
80 <p class="level1">Signals are used for timing out name resolves (during DNS lookup) - when built without using either the c-ares or threaded resolver backends. When using multiple threads you should set the <span Class="emphasis">CURLOPT_NOSIGNAL(3)</span> option to 1L for all handles. Everything will or might work fine except that timeouts are not honored during the DNS lookup - which you can work around by building libcurl with c-ares support. c-ares is a library that provides asynchronous name resolves. On some platforms, libcurl simply will not function properly multi-threaded unless this option is set. 
81 <p class="level0"><a name="Name"></a><span class="nroffip">Name resolving</span> 
82 <p class="level1"><span Class="bold">gethostby* functions and other system calls.</span> These functions, provided by your operating system, must be thread safe. It is very important that libcurl can find and use thread safe versions of these and other system calls, as otherwise it can't function fully thread safe. Some operating systems are known to have faulty thread implementations. We have previously received problem reports on *BSD (at least in the past, they may be working fine these days).  Some operating systems that are known to have solid and working thread support are Linux, Solaris and Windows. 
83 <p class="level0"><a name="curlglobal"></a><span class="nroffip">curl_global_* functions</span> 
84 <p class="level1">These functions are not thread safe. If you are using libcurl with multiple threads it is especially important that before use you call <a Class="emphasis" href="./curl_global_init.html">curl_global_init</a> or <a Class="emphasis" href="./curl_global_init_mem.html">curl_global_init_mem</a> to explicitly initialize the library and its dependents, rather than rely on the "lazy" fail-safe initialization that takes place the first time <a Class="emphasis" href="./curl_easy_init.html">curl_easy_init</a> is called. For an in-depth explanation refer to <a Class="emphasis" href="./libcurl.html">libcurl</a> section <span Class="bold">GLOBAL CONSTANTS</span>. 
85 <p class="level0"><a name="Memory"></a><span class="nroffip">Memory functions</span> 
86 <p class="level1">These functions, provided either by your operating system or your own replacements, must be thread safe. You can use <a Class="emphasis" href="./curl_global_init_mem.html">curl_global_init_mem</a> to set your own replacement memory functions. 
87 <p class="level0"><a name="Non-safe"></a><span class="nroffip">Non-safe functions</span> 
88 <p class="level1"><span Class="emphasis">CURLOPT_DNS_USE_GLOBAL_CACHE(3)</span> is not thread-safe. <p class="roffit">
89  This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.
90 </body></html>