gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] branch master updated: simplify init for gn


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated: simplify init for gnutls-less lib
Date: Sun, 18 Feb 2018 12:41:46 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new aa12189a simplify init for gnutls-less lib
aa12189a is described below

commit aa12189a4b26393302b800dc2e5374d108cc34a9
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Feb 18 12:41:39 2018 +0100

    simplify init for gnutls-less lib
---
 src/{lib => gnutls}/init.c |   0
 src/{lib => gnutls}/init.h |  11 +----
 src/lib/init.c             | 107 ++++++---------------------------------------
 src/lib/init.h             |  11 +----
 4 files changed, 16 insertions(+), 113 deletions(-)

diff --git a/src/lib/init.c b/src/gnutls/init.c
similarity index 100%
copy from src/lib/init.c
copy to src/gnutls/init.c
diff --git a/src/lib/init.h b/src/gnutls/init.h
similarity index 95%
copy from src/lib/init.h
copy to src/gnutls/init.h
index f64f9b51..fae96159 100644
--- a/src/lib/init.h
+++ b/src/gnutls/init.h
@@ -16,24 +16,15 @@
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
 */
-
 /**
  * @file lib/init.h
  * @brief functions to initialize library
  * @author Christian Grothoff
  */
-#include "internal.h"
-
-
 #ifndef INIT_H
 #define INIT_H
 
-/**
- * Globally initialise library.
- */
-void
-MHD_init(void);
-
+#include "internal.h"
 
 #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED
 /**
diff --git a/src/lib/init.c b/src/lib/init.c
index 8ca5cd28..d3965763 100644
--- a/src/lib/init.c
+++ b/src/lib/init.c
@@ -21,78 +21,17 @@
  * @file lib/init.c
  * @brief initialization routines
  * @author Christian Grothoff
- *
- * TODO: most of this is only required for gcrypt/GNUtls,
- * should probably be moved to TLS plugin!
  */
 #include "internal.h"
 #include "init.h"
 
 
-#ifdef MHD_HTTPS_REQUIRE_GRYPT
-#if defined(HTTPS_SUPPORT) && GCRYPT_VERSION_NUMBER < 0x010600
-#if defined(MHD_USE_POSIX_THREADS)
-GCRY_THREAD_OPTION_PTHREAD_IMPL;
-#elif defined(MHD_W32_MUTEX_)
-
-static int
-gcry_w32_mutex_init (void **ppmtx)
-{
-  *ppmtx = malloc (sizeof (MHD_mutex_));
-
-  if (NULL == *ppmtx)
-    return ENOMEM;
-  if (!MHD_mutex_init_ ((MHD_mutex_*)*ppmtx))
-    {
-      free (*ppmtx);
-      *ppmtx = NULL;
-      return EPERM;
-    }
-
-  return 0;
-}
-
-
-static int
-gcry_w32_mutex_destroy (void **ppmtx)
-{
-  int res = (MHD_mutex_destroy_ ((MHD_mutex_*)*ppmtx)) ? 0 : EINVAL;
-  free (*ppmtx);
-  return res;
-}
-
-
-static int
-gcry_w32_mutex_lock (void **ppmtx)
-{
-  return MHD_mutex_lock_ ((MHD_mutex_*)*ppmtx) ? 0 : EINVAL;
-}
-
-
-static int
-gcry_w32_mutex_unlock (void **ppmtx)
-{
-  return MHD_mutex_unlock_ ((MHD_mutex_*)*ppmtx) ? 0 : EINVAL;
-}
-
-
-static struct gcry_thread_cbs gcry_threads_w32 = {
-  (GCRY_THREAD_OPTION_USER | (GCRY_THREAD_OPTION_VERSION << 8)),
-  NULL, gcry_w32_mutex_init, gcry_w32_mutex_destroy,
-  gcry_w32_mutex_lock, gcry_w32_mutex_unlock,
-  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
-
-#endif /* defined(MHD_W32_MUTEX_) */
-#endif /* HTTPS_SUPPORT && GCRYPT_VERSION_NUMBER < 0x010600 */
-#endif /* MHD_HTTPS_REQUIRE_GRYPT */
-
-
 #ifndef _AUTOINIT_FUNCS_ARE_SUPPORTED
-
 /**
  * Track global initialisation
  */
-volatile int global_init_count = 0;
+volatile unsigned int global_init_count = 0;
+
 #ifdef MHD_MUTEX_STATIC_DEFN_INIT_
 /**
  * Global initialisation mutex
@@ -153,10 +92,10 @@ mhd_panic_std (void *cls,
 
 
 /**
- * Initialize do setup work.
+ * Globally initialize library.
  */
 void
-MHD_init(void)
+MHD_init (void)
 {
 #if defined(_WIN32) && ! defined(__CYGWIN__)
   WSADATA wsd;
@@ -166,50 +105,32 @@ MHD_init(void)
     mhd_panic = &mhd_panic_std;
 
 #if defined(_WIN32) && ! defined(__CYGWIN__)
-  if (0 != WSAStartup(MAKEWORD(2, 2), &wsd))
+  if (0 != WSAStartup (MAKEWORD(2, 2),
+                      &wsd))
     MHD_PANIC (_("Failed to initialize winsock\n"));
   mhd_winsock_inited_ = 1;
-  if (2 != LOBYTE(wsd.wVersion) && 2 != HIBYTE(wsd.wVersion))
+  if ( (2 != LOBYTE(wsd.wVersion)) &&
+       (2 != HIBYTE(wsd.wVersion)) )
     MHD_PANIC (_("Winsock version 2.2 is not available\n"));
 #endif
-#ifdef HTTPS_SUPPORT
-#ifdef MHD_HTTPS_REQUIRE_GRYPT
-#if GCRYPT_VERSION_NUMBER < 0x010600
-#if defined(MHD_USE_POSIX_THREADS)
-  if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS,
-                         &gcry_threads_pthread))
-    MHD_PANIC (_("Failed to initialise multithreading in libgcrypt\n"));
-#elif defined(MHD_W32_MUTEX_)
-  if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS,
-                         &gcry_threads_w32))
-    MHD_PANIC (_("Failed to initialise multithreading in libgcrypt\n"));
-#endif /* defined(MHD_W32_MUTEX_) */
-  gcry_check_version (NULL);
-#else
-  if (NULL == gcry_check_version ("1.6.0"))
-    MHD_PANIC (_("libgcrypt is too old. MHD was compiled for libgcrypt 1.6.0 
or newer\n"));
-#endif
-#endif /* MHD_HTTPS_REQUIRE_GRYPT */
-  gnutls_global_init ();
-#endif /* HTTPS_SUPPORT */
-  MHD_monotonic_sec_counter_init();
+  MHD_monotonic_sec_counter_init ();
 #ifdef HAVE_FREEBSD_SENDFILE
   MHD_conn_init_static_ ();
 #endif /* HAVE_FREEBSD_SENDFILE */
 }
 
 
+/**
+ * Global teardown work.
+ */
 void
-MHD_fini(void)
+MHD_fini (void)
 {
-#ifdef HTTPS_SUPPORT
-  gnutls_global_deinit ();
-#endif /* HTTPS_SUPPORT */
 #if defined(_WIN32) && ! defined(__CYGWIN__)
   if (mhd_winsock_inited_)
     WSACleanup();
 #endif
-  MHD_monotonic_sec_counter_finish();
+  MHD_monotonic_sec_counter_finish ();
 }
 
 #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED
diff --git a/src/lib/init.h b/src/lib/init.h
index f64f9b51..fae96159 100644
--- a/src/lib/init.h
+++ b/src/lib/init.h
@@ -16,24 +16,15 @@
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
 */
-
 /**
  * @file lib/init.h
  * @brief functions to initialize library
  * @author Christian Grothoff
  */
-#include "internal.h"
-
-
 #ifndef INIT_H
 #define INIT_H
 
-/**
- * Globally initialise library.
- */
-void
-MHD_init(void);
-
+#include "internal.h"
 
 #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED
 /**

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]