diff options
Diffstat (limited to 'src/gnutls/init.c')
-rw-r--r-- | src/gnutls/init.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/gnutls/init.c b/src/gnutls/init.c index 3dd656b1..321e7e6a 100644 --- a/src/gnutls/init.c +++ b/src/gnutls/init.c | |||
@@ -40,12 +40,12 @@ gcry_w32_mutex_init (void **ppmtx) | |||
40 | 40 | ||
41 | if (NULL == *ppmtx) | 41 | if (NULL == *ppmtx) |
42 | return ENOMEM; | 42 | return ENOMEM; |
43 | if (! MHD_mutex_init_ ((MHD_mutex_*)*ppmtx)) | 43 | if (! MHD_mutex_init_ ((MHD_mutex_*) *ppmtx)) |
44 | { | 44 | { |
45 | free (*ppmtx); | 45 | free (*ppmtx); |
46 | *ppmtx = NULL; | 46 | *ppmtx = NULL; |
47 | return EPERM; | 47 | return EPERM; |
48 | } | 48 | } |
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | 51 | ||
@@ -53,7 +53,7 @@ gcry_w32_mutex_init (void **ppmtx) | |||
53 | static int | 53 | static int |
54 | gcry_w32_mutex_destroy (void **ppmtx) | 54 | gcry_w32_mutex_destroy (void **ppmtx) |
55 | { | 55 | { |
56 | int res = (MHD_mutex_destroy_ ((MHD_mutex_*)*ppmtx)) ? 0 : EINVAL; | 56 | int res = (MHD_mutex_destroy_ ((MHD_mutex_*) *ppmtx)) ? 0 : EINVAL; |
57 | free (*ppmtx); | 57 | free (*ppmtx); |
58 | return res; | 58 | return res; |
59 | } | 59 | } |
@@ -62,14 +62,14 @@ gcry_w32_mutex_destroy (void **ppmtx) | |||
62 | static int | 62 | static int |
63 | gcry_w32_mutex_lock (void **ppmtx) | 63 | gcry_w32_mutex_lock (void **ppmtx) |
64 | { | 64 | { |
65 | return MHD_mutex_lock_ ((MHD_mutex_*)*ppmtx) ? 0 : EINVAL; | 65 | return MHD_mutex_lock_ ((MHD_mutex_*) *ppmtx) ? 0 : EINVAL; |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | static int | 69 | static int |
70 | gcry_w32_mutex_unlock (void **ppmtx) | 70 | gcry_w32_mutex_unlock (void **ppmtx) |
71 | { | 71 | { |
72 | return MHD_mutex_unlock_ ((MHD_mutex_*)*ppmtx) ? 0 : EINVAL; | 72 | return MHD_mutex_unlock_ ((MHD_mutex_*) *ppmtx) ? 0 : EINVAL; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
@@ -77,7 +77,8 @@ static struct gcry_thread_cbs gcry_threads_w32 = { | |||
77 | (GCRY_THREAD_OPTION_USER | (GCRY_THREAD_OPTION_VERSION << 8)), | 77 | (GCRY_THREAD_OPTION_USER | (GCRY_THREAD_OPTION_VERSION << 8)), |
78 | NULL, gcry_w32_mutex_init, gcry_w32_mutex_destroy, | 78 | NULL, gcry_w32_mutex_init, gcry_w32_mutex_destroy, |
79 | gcry_w32_mutex_lock, gcry_w32_mutex_unlock, | 79 | gcry_w32_mutex_lock, gcry_w32_mutex_unlock, |
80 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; | 80 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL |
81 | }; | ||
81 | 82 | ||
82 | #endif /* defined(MHD_W32_MUTEX_) */ | 83 | #endif /* defined(MHD_W32_MUTEX_) */ |
83 | #endif /* HTTPS_SUPPORT && GCRYPT_VERSION_NUMBER < 0x010600 */ | 84 | #endif /* HTTPS_SUPPORT && GCRYPT_VERSION_NUMBER < 0x010600 */ |
@@ -94,7 +95,7 @@ volatile int global_init_count = 0; | |||
94 | /** | 95 | /** |
95 | * Global initialisation mutex | 96 | * Global initialisation mutex |
96 | */ | 97 | */ |
97 | MHD_MUTEX_STATIC_DEFN_INIT_(global_init_mutex_); | 98 | MHD_MUTEX_STATIC_DEFN_INIT_ (global_init_mutex_); |
98 | #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ | 99 | #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ |
99 | 100 | ||
100 | #endif | 101 | #endif |
@@ -108,12 +109,12 @@ void | |||
108 | MHD_TLS_check_global_init_ (void) | 109 | MHD_TLS_check_global_init_ (void) |
109 | { | 110 | { |
110 | #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ | 111 | #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ |
111 | MHD_mutex_lock_chk_(&global_init_mutex_); | 112 | MHD_mutex_lock_chk_ (&global_init_mutex_); |
112 | #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ | 113 | #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ |
113 | if (0 == global_init_count++) | 114 | if (0 == global_init_count++) |
114 | MHD_init (); | 115 | MHD_init (); |
115 | #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ | 116 | #ifdef MHD_MUTEX_STATIC_DEFN_INIT_ |
116 | MHD_mutex_unlock_chk_(&global_init_mutex_); | 117 | MHD_mutex_unlock_chk_ (&global_init_mutex_); |
117 | #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ | 118 | #endif /* MHD_MUTEX_STATIC_DEFN_INIT_ */ |
118 | } | 119 | } |
119 | 120 | ||
@@ -133,16 +134,17 @@ MHD_TLS_init (void) | |||
133 | #if defined(MHD_USE_POSIX_THREADS) | 134 | #if defined(MHD_USE_POSIX_THREADS) |
134 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, | 135 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, |
135 | &gcry_threads_pthread)) | 136 | &gcry_threads_pthread)) |
136 | MHD_PANIC (_("Failed to initialise multithreading in libgcrypt\n")); | 137 | MHD_PANIC (_ ("Failed to initialise multithreading in libgcrypt\n")); |
137 | #elif defined(MHD_W32_MUTEX_) | 138 | #elif defined(MHD_W32_MUTEX_) |
138 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, | 139 | if (0 != gcry_control (GCRYCTL_SET_THREAD_CBS, |
139 | &gcry_threads_w32)) | 140 | &gcry_threads_w32)) |
140 | MHD_PANIC (_("Failed to initialise multithreading in libgcrypt\n")); | 141 | MHD_PANIC (_ ("Failed to initialise multithreading in libgcrypt\n")); |
141 | #endif /* defined(MHD_W32_MUTEX_) */ | 142 | #endif /* defined(MHD_W32_MUTEX_) */ |
142 | gcry_check_version (NULL); | 143 | gcry_check_version (NULL); |
143 | #else | 144 | #else |
144 | if (NULL == gcry_check_version ("1.6.0")) | 145 | if (NULL == gcry_check_version ("1.6.0")) |
145 | MHD_PANIC (_("libgcrypt is too old. MHD was compiled for libgcrypt 1.6.0 or newer\n")); | 146 | MHD_PANIC (_ ( |
147 | "libgcrypt is too old. MHD was compiled for libgcrypt 1.6.0 or newer\n")); | ||
146 | #endif | 148 | #endif |
147 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ | 149 | #endif /* MHD_HTTPS_REQUIRE_GRYPT */ |
148 | gnutls_global_init (); | 150 | gnutls_global_init (); |
@@ -150,11 +152,11 @@ MHD_TLS_init (void) | |||
150 | 152 | ||
151 | 153 | ||
152 | void | 154 | void |
153 | MHD_TLS_fini(void) | 155 | MHD_TLS_fini (void) |
154 | { | 156 | { |
155 | gnutls_global_deinit (); | 157 | gnutls_global_deinit (); |
156 | } | 158 | } |
157 | 159 | ||
158 | #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED | 160 | #ifdef _AUTOINIT_FUNCS_ARE_SUPPORTED |
159 | _SET_INIT_AND_DEINIT_FUNCS(MHD_TLS_init, MHD_TLS_fini); | 161 | _SET_INIT_AND_DEINIT_FUNCS (MHD_TLS_init, MHD_TLS_fini); |
160 | #endif /* _AUTOINIT_FUNCS_ARE_SUPPORTED */ | 162 | #endif /* _AUTOINIT_FUNCS_ARE_SUPPORTED */ |