diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-22 19:50:10 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-22 20:04:58 +0200 |
commit | 9d7f9a1b9120cb40b668a06847181eb9ddb164e2 (patch) | |
tree | fc217e97fe3463d5038602bb9d91bff1b861a6c9 /include/git2/sys | |
parent | 2540487fcd06544fbdcda37944bde344df877e47 (diff) | |
download | libgit2-cmn/lock-io.tar.gz |
Lock around encrypted I/Ocmn/lock-io
OpenSSL and often whatever libssh2 is using require their own set-up for
concurrent operations to be safe. This means that by default, using both
of these libraries in a threaded context is unsafe.
Lock by default, and allow the user to tell us that they've set up
threading for the underlying libraries.
Diffstat (limited to 'include/git2/sys')
-rw-r--r-- | include/git2/sys/libssh2.h | 29 | ||||
-rw-r--r-- | include/git2/sys/openssl.h | 16 |
2 files changed, 45 insertions, 0 deletions
diff --git a/include/git2/sys/libssh2.h b/include/git2/sys/libssh2.h new file mode 100644 index 000000000..ca1dec9fb --- /dev/null +++ b/include/git2/sys/libssh2.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_libssh2_h__ +#define INCLUDE_git_libssh2_h__ + +#include "git2/common.h" + +GIT_BEGIN_DECL + +/** + * Mark the libssh2 code as thread-safe + * + * By default we take a lock around libssh2 operations, as the + * thread-safety depends on the caller setting up the threading for + * the crytographic library it uses. If you have set up its threading, + * you may call this function to disable the lock, which would enable + * concurrent work. + * + * These locks are only used if the library was built with threading + * support. + */ +GIT_EXTERN(void) git_libssh2_set_threadsafe(void); + +GIT_END_DECL +#endif diff --git a/include/git2/sys/openssl.h b/include/git2/sys/openssl.h index b41c55c6d..5a5fc8f03 100644 --- a/include/git2/sys/openssl.h +++ b/include/git2/sys/openssl.h @@ -28,11 +28,27 @@ GIT_BEGIN_DECL * likely sets up locking. You should very strongly prefer that over * this function. * + * This calls `git_openssl_set_threadsafe()` enabling concurrent + * OpenSSL operations. + * * @return 0 on success, -1 if there are errors or if libgit2 was not * built with OpenSSL and threading support. */ GIT_EXTERN(int) git_openssl_set_locking(void); +/** + * Mark the OpenSSL code as thread-safe + * + * By default we take a lock around OpenSSL operations. If you have + * set up OpenSSL threading in your application, you may call this + * function to avoid taking these locks, which would enable concurrent + * work. + * + * These locks are only used if the library was built with threading + * support. + */ +GIT_EXTERN(void) git_openssl_set_threadsafe(void); + GIT_END_DECL #endif |