[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [3074] Fixed a problem with GNUTLS usage in a multi-th
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [3074] Fixed a problem with GNUTLS usage in a multi-threaded environment. |
Date: |
Sun, 03 May 2009 15:36:44 +0000 |
Revision: 3074
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3074
Author: gscrivano
Date: 2009-05-03 15:36:44 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Fixed a problem with GNUTLS usage in a multi-threaded environment.
Modified Paths:
--------------
trunk/myserver/configure.in
trunk/myserver/src/base/ssl/ssl.cpp
Modified: trunk/myserver/configure.in
===================================================================
--- trunk/myserver/configure.in 2009-05-03 15:36:39 UTC (rev 3073)
+++ trunk/myserver/configure.in 2009-05-03 15:36:44 UTC (rev 3074)
@@ -98,6 +98,7 @@
AC_CHECK_FUNCS(getpwnam, AC_DEFINE(GETPWNAM, 1, [Define if the getpwnam
function is present]) )
+AC_CHECK_LIB(gcrypt, gcry_control, AC_DEFINE(GCRY_CONTROL, 1, [Define if the
gcry_control function is present]))
case "${host}" in
*-*-mingw32*)
Modified: trunk/myserver/src/base/ssl/ssl.cpp
===================================================================
--- trunk/myserver/src/base/ssl/ssl.cpp 2009-05-03 15:36:39 UTC (rev 3073)
+++ trunk/myserver/src/base/ssl/ssl.cpp 2009-05-03 15:36:44 UTC (rev 3074)
@@ -20,6 +20,19 @@
#include <string.h>
+extern "C"
+{
+#if GCRY_CONTROL
+
+#include <errno.h>
+#include <gcrypt.h>
+GCRY_THREAD_OPTION_PTHREAD_IMPL;
+
+#endif
+
+#include <pthread.h>
+}
+
SslContext::SslContext()
{
context = 0;
@@ -32,65 +45,69 @@
/*!
*Initialize SSL on the virtual host.
*/
-int SslContext::initialize()
+int SslContext::initialize ()
{
context = 0;
method = 0;
- method = SSLv23_server_method();
- context = SSL_CTX_new(method);
+ method = SSLv23_server_method ();
+ context = SSL_CTX_new (method);
- if(!context)
+ if (!context)
return -1;
/*
*The specified file doesn't exist.
*/
- if(FilesUtility::fileExists(certificateFile.c_str()) == 0)
+ if (FilesUtility::fileExists(certificateFile.c_str()) == 0)
return -1;
- if(SSL_CTX_use_certificate_file (context, certificateFile.c_str
(),SSL_FILETYPE_PEM) != 1)
+ if (SSL_CTX_use_certificate_file (context, certificateFile.c_str
(),SSL_FILETYPE_PEM) != 1)
return -1;
/*
*The specified file doesn't exist.
*/
- if(FilesUtility::fileExists(privateKeyFile) == 0)
+ if (FilesUtility::fileExists(privateKeyFile) == 0)
return -1;
- if(SSL_CTX_use_PrivateKey_file(context, privateKeyFile.c_str(),
- SSL_FILETYPE_PEM) != 1)
+ if (SSL_CTX_use_PrivateKey_file(context, privateKeyFile.c_str(),
+ SSL_FILETYPE_PEM) != 1)
return -1;
return 1;
}
-int SslContext::free()
+int SslContext::free ()
{
int ret = 0;
- if(context)
+ if (context)
{
- SSL_CTX_free(context);
+ SSL_CTX_free (context);
ret = 1;
context = 0;
}
else
ret = 0;
- certificateFile.assign("");
- privateKeyFile.assign("");
+ certificateFile.assign ("");
+ privateKeyFile.assign ("");
return ret;
}
-void initializeSSL()
+void initializeSSL ()
{
static bool initialized = false;
- if(!initialized)
+
+ if (!initialized)
{
- SSL_load_error_strings();
- SSL_library_init();
+#if GCRY_CONTROL
+ gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+ gnutls_global_init ();
+#endif
+
initialized = true;
}
}
-void cleanupSSL()
+void cleanupSSL ()
{
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [3074] Fixed a problem with GNUTLS usage in a multi-threaded environment.,
Giuseppe Scrivano <=