Skip to content

Commit 582d036

Browse files
authored
Update threading.md
1 parent 1a107fa commit 582d036

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

docs/threading.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
Threads in libgit2
1+
Threading in libgit2
22
==================
33

4-
You may safely use any libgit2 object from any thread, though there
5-
may be issues depending on the cryptographic libraries libgit2 or its
4+
Unless otherwise specified, libgit2 objects cannot be safely accessed by
5+
multiple threads.
6+
7+
There are also caveats on the cryptographic libraries libgit2 or its
68
dependencies link to (more on this later). For libgit2 itself,
79
provided you take the following into consideration you won't run into
810
issues:
@@ -26,11 +28,11 @@ The error message is thread-local. The `git_error_last()` call must
2628
happen on the same thread as the error in order to get the
2729
message. Often this will be the case regardless, but if you use
2830
something like the [GCD](http://en.wikipedia.org/wiki/Grand_Central_Dispatch)
29-
on Mac OS X (where code is executed on an arbitrary thread), the code
31+
on macOS (where code is executed on an arbitrary thread), the code
3032
must make sure to retrieve the error code on the thread where the error
3133
happened.
3234

33-
Threads and cryptographic libraries
35+
Threading and cryptographic libraries
3436
=======================================
3537

3638
On Windows
@@ -44,31 +46,20 @@ steps necessary. If you are using a MinGW or similar environment where
4446
libssh2 uses OpenSSL or libgcrypt, then the general case affects
4547
you.
4648

47-
On Mac OS X
49+
On macOS
4850
-----------
4951

50-
By default we use libcurl to perform the encryption. The
51-
system-provided libcurl uses SecureTransport, so no special steps are
52-
necessary. If you link against another libcurl (e.g. from homebrew)
53-
refer to the general case.
54-
55-
If the option to use libcurl was deactivated, the library makes use of
56-
CommonCrypto and SecureTransport for cryptographic support. These are
57-
thread-safe and you do not need to do anything special.
52+
By default we make use of CommonCrypto and SecureTransport for cryptographic
53+
support. These are thread-safe and you do not need to do anything special.
5854

5955
Note that libssh2 may still use OpenSSL itself. In that case, the
6056
general case still affects you if you use ssh.
6157

6258
General Case
6359
------------
6460

65-
If it's available, by default we use libcurl to provide HTTP tunneling support,
66-
which may be linked against a number of cryptographic libraries and has its
67-
own
68-
[recommendations for thread safety](https://curl.haxx.se/libcurl/c/threadsafe.html).
69-
70-
If there are no alternative TLS implementations (currently only
71-
SecureTransport), libgit2 uses OpenSSL in order to use HTTPS as a transport.
61+
If there are no applicable TLS implementations (currently only
62+
SecureTransport and mbedTLS), libgit2 defaults to OpenSSL in order to use HTTPS as a transport.
7263
OpenSSL is thread-safe starting at version 1.1.0. If your copy of libgit2 is
7364
linked against that version, you do not need to take any further steps.
7465

@@ -78,18 +69,18 @@ cannot know what to set as the user of libgit2 may also be using OpenSSL indepen
7869
the locking settings must then live outside the lifetime of libgit2.
7970

8071
Even if libgit2 doesn't use OpenSSL directly, OpenSSL can still be used by
81-
libssh2 or libcurl depending on the configuration. If OpenSSL is used by
72+
libssh2 depending on the configuration. If OpenSSL is used by
8273
more than one library, you only need to set up threading for OpenSSL once.
8374

84-
If libgit2 is linked against OpenSSL, it provides a last-resort convenience function
75+
If libgit2 is linked against OpenSSL < 1.1.0, it provides a last-resort convenience function
8576
`git_openssl_set_locking()` (available in `sys/openssl.h`) to use the
8677
platform-native mutex mechanisms to perform the locking, which you can use
8778
if you do not want to use OpenSSL outside of libgit2, or you
8879
know that libgit2 will outlive the rest of the operations. It is then not
8980
safe to use OpenSSL multi-threaded after libgit2's shutdown function
9081
has been called. Note `git_openssl_set_locking()` only works if
9182
libgit2 uses OpenSSL directly - if OpenSSL is only used as a dependency
92-
of libssh2 or libcurl as described above, `git_openssl_set_locking()` is a no-op.
83+
of libssh2 as described above, `git_openssl_set_locking()` is a no-op.
9384

9485
If your programming language offers a package/bindings for OpenSSL,
9586
you should very strongly prefer to use that in order to set up

0 commit comments

Comments
 (0)