aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2014-01-08 16:58:49 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2014-01-08 18:57:31 +0100
commit57ef959aa3e785658d68c91a7e7ba78cc5dc75f6 (patch)
tree0ae65b464f3553836e108dd4de9a6696d8553f55 /src
parentb617d7fa29f1dfbd481b32f08c9602bf236c339c (diff)
downloadlibssh-57ef959aa3e785658d68c91a7e7ba78cc5dc75f6.tar.gz
libssh-57ef959aa3e785658d68c91a7e7ba78cc5dc75f6.tar.xz
libssh-57ef959aa3e785658d68c91a7e7ba78cc5dc75f6.zip
threads: support libgcrypt 1.6 hack
Not 100% satisfied of this patch, but the way libgcrypt handles threading in 1.6 is not compatible with custom handlers. The new code basicaly uses pthreads in every case. This will probably not work on windows.
Diffstat (limited to 'src')
-rw-r--r--src/threads.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/threads.c b/src/threads.c
index 107c65d2..7f3a304e 100644
--- a/src/threads.c
+++ b/src/threads.c
@@ -59,8 +59,28 @@ struct ssh_threads_callbacks_struct *ssh_threads_get_noop(void) {
static struct ssh_threads_callbacks_struct *user_callbacks =&ssh_threads_noop;
#ifdef HAVE_LIBGCRYPT
+#if (GCRYPT_VERSION_NUMBER >= 0x010600)
+/* libgcrypt >= 1.6 does not support custom callbacks */
+GCRY_THREAD_OPTION_PTHREAD_IMPL;
-/* Libgcrypt specific way of handling thread callbacks */
+static int libgcrypt_thread_init(void){
+ if(user_callbacks == NULL)
+ return SSH_ERROR;
+ if(user_callbacks == &ssh_threads_noop)
+ return SSH_OK;
+ if (strcmp(user_callbacks->type, "threads_pthread") == 0){
+ gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+ return SSH_OK;
+ } else {
+ /* not supported */
+ SSH_LOG(SSH_LOG_WARN, "Custom thread handlers not supported with libgcrypt >=1.6, using pthreads");
+ gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+ return SSH_OK;
+ }
+}
+
+#else
+/* Libgcrypt < 1.6 specific way of handling thread callbacks */
static struct gcry_thread_cbs gcrypt_threads_callbacks;
@@ -79,7 +99,8 @@ static int libgcrypt_thread_init(void){
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcrypt_threads_callbacks);
return SSH_OK;
}
-#else
+#endif /* GCRYPT_VERSION_NUMBER */
+#else /* HAVE_LIBGCRYPT */
/* Libcrypto specific stuff */