summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2014-09-25 16:28:17 +0000
committerOthmar Gsenger <otti@anytun.org>2014-09-25 16:28:17 +0000
commitb855d2ba95a877ed4db7a3833b2416682d308a0e (patch)
tree65d615637b62d2373fba387e2e0593a7cc03e6f4
parentmoved anytun newthread from configure to makefile (diff)
merged gcrypt threading fixesnew-multithreading
-rw-r--r--ChangeLog3
-rw-r--r--src/cryptinit.hpp44
2 files changed, 12 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a89c6e..284ae2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,9 @@
-2014.??.?? -- Version 0.3.5
+2014.08.26 -- Version 0.3.5
* added an exception to the license which allows linking with OpenSSL
* added support for clang
* added libnettle as additional crypto library option
+* fixed mutli-threading support for libgcrypt 1.6.0 and newer
2011.12.30 -- Version 0.3.4
diff --git a/src/cryptinit.hpp b/src/cryptinit.hpp
index 090e9e8..cd11215 100644
--- a/src/cryptinit.hpp
+++ b/src/cryptinit.hpp
@@ -51,48 +51,24 @@
#if defined(USE_GCRYPT)
#include <gcrypt.h>
+#if defined(BOOST_HAS_PTHREADS)
// boost thread callbacks for libgcrypt
-static int boost_mutex_init(void** priv)
-{
- boost::mutex* lock = new boost::mutex();
- if(!lock) {
- return ENOMEM;
- }
- *priv = lock;
- return 0;
-}
-
-static int boost_mutex_destroy(void** lock)
-{
- delete reinterpret_cast<boost::mutex*>(*lock);
- return 0;
-}
-
-static int boost_mutex_lock(void** lock)
-{
- reinterpret_cast<boost::mutex*>(*lock)->lock();
- return 0;
-}
-
-static int boost_mutex_unlock(void** lock)
-{
- reinterpret_cast<boost::mutex*>(*lock)->unlock();
- return 0;
-}
-
-static struct gcry_thread_cbs gcry_threads_boost = {
- GCRY_THREAD_OPTION_USER, NULL,
- boost_mutex_init, boost_mutex_destroy,
- boost_mutex_lock, boost_mutex_unlock
-};
+GCRY_THREAD_OPTION_PTHREAD_IMPL;
+#else
+#error You can not use gcrypt without pthreads - please configure Boost to use pthreads!
+#endif
#define MIN_GCRYPT_VERSION "1.2.0"
bool initLibGCrypt()
{
+#if defined(BOOST_HAS_PTHREADS)
// make libgcrypt thread safe
// this must be called before any other libgcrypt call
- gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_boost);
+ gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+#else
+#error You can not use gcrypt without pthreads - please configure Boost to use pthreads!
+#endif
// this must be called right after the GCRYCTL_SET_THREAD_CBS command
// no other function must be called till now