summaryrefslogtreecommitdiff
path: root/random/random-daemon.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2014-01-09 19:14:09 +0100
committerWerner Koch <wk@gnupg.org>2014-01-16 17:23:21 +0100
commitcfc151ba637200e4fc05d9481a8df2071b2f9a47 (patch)
treef1a1c3e1fc81663d622dd5189462a249bd01eac3 /random/random-daemon.c
parent49edeebb43174865cf4fa2c170a42a8e4274c4f0 (diff)
downloadlibgcrypt-cfc151ba637200e4fc05d9481a8df2071b2f9a47.tar.gz
Replace ath based mutexes by gpgrt based locks.
* configure.ac (NEED_GPG_ERROR_VERSION): Require 1.13. (gl_LOCK): Remove. * src/ath.c, src/ath.h: Remove. Remove from all files. Replace all mutexes by gpgrt based statically initialized locks. * src/global.c (global_init): Remove ath_init. (_gcry_vcontrol): Make ath install a dummy function. (print_config): Remove threads info line. * doc/gcrypt.texi: Simplify the multi-thread related documentation. -- The current code does only work on ELF systems with weak symbol support. In particular no locks were used under Windows. With the new gpgrt_lock functions from the soon to be released libgpg-error 1.13 we have a better portable scheme which also allows for static initialized mutexes. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'random/random-daemon.c')
-rw-r--r--random/random-daemon.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/random/random-daemon.c b/random/random-daemon.c
index 98a01536..8ea4df28 100644
--- a/random/random-daemon.c
+++ b/random/random-daemon.c
@@ -28,8 +28,6 @@
sensitive data.
*/
-#error This dameon needs to be fixed due to the ath changes
-
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@@ -42,7 +40,6 @@
#include "g10lib.h"
#include "random.h"
-#include "ath.h"
@@ -51,7 +48,7 @@
#define RANDOM_DAEMON_SOCKET "/var/run/libgcrypt/S.gcryptrnd"
/* The lock serializing access to the daemon. */
-static ath_mutex_t daemon_lock = ATH_MUTEX_INITIALIZER;
+GPGRT_LOCK_DEFINE (daemon_lock);
/* The socket connected to the daemon. */
static int daemon_socket = -1;
@@ -129,16 +126,7 @@ connect_to_socket (const char *socketname, int *sock)
void
_gcry_daemon_initialize_basics (void)
{
- static int initialized;
- int err;
-
- if (!initialized)
- {
- initialized = 1;
- err = ath_mutex_init (&daemon_lock);
- if (err)
- log_fatal ("failed to create the daemon lock: %s\n", strerror (err) );
- }
+ /* Not anymore required. */
}
@@ -213,7 +201,7 @@ call_daemon (const char *socketname,
if (!req_nbytes)
return 0;
- ath_mutex_lock (&daemon_lock);
+ gpgrt_lock_lock (&daemon_lock);
/* Open the socket if that has not been done. */
if (!initialized)
@@ -225,7 +213,7 @@ call_daemon (const char *socketname,
{
daemon_socket = -1;
log_info ("not using random daemon\n");
- ath_mutex_unlock (&daemon_lock);
+ gpgrt_lock_unlock (&daemon_lock);
return err;
}
}
@@ -233,7 +221,7 @@ call_daemon (const char *socketname,
/* Check that we have a valid socket descriptor. */
if ( daemon_socket == -1 )
{
- ath_mutex_unlock (&daemon_lock);
+ gpgrt_lock_unlock (&daemon_lock);
return gcry_error (GPG_ERR_INTERNAL);
}
@@ -325,7 +313,7 @@ call_daemon (const char *socketname,
}
while (req_nbytes);
- ath_mutex_unlock (&daemon_lock);
+ gpgrt_lock_unlock (&daemon_lock);
return err;
}