[svn] dirmngr - r246 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Fri Jul 20 17:28:19 CEST 2007
Author: marcus
Date: 2007-07-20 17:27:48 +0200 (Fri, 20 Jul 2007)
New Revision: 246
Modified:
trunk/src/ChangeLog
trunk/src/certcache.c
Log:
2007-07-20 Marcus Brinkmann <marcus at g10code.de>
* certcache.c (cert_cache_lock): Do not initialize statically.
(init_cache_lock): New function.
(cert_cache_init): Call init_cache_lock.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-07-20 01:04:38 UTC (rev 245)
+++ trunk/src/ChangeLog 2007-07-20 15:27:48 UTC (rev 246)
@@ -1,5 +1,9 @@
2007-07-20 Marcus Brinkmann <marcus at g10code.de>
+ * certcache.c (cert_cache_lock): Do not initialize statically.
+ (init_cache_lock): New function.
+ (cert_cache_init): Call init_cache_lock.
+
* estream.h, estream.c, estream-printf.h, estream-printf.c: New
files.
* Makefile.am (dirmngr_SOURCES): Add estream.c, estream.h,
Modified: trunk/src/certcache.c
===================================================================
--- trunk/src/certcache.c 2007-07-20 01:04:38 UTC (rev 245)
+++ trunk/src/certcache.c 2007-07-20 15:27:48 UTC (rev 246)
@@ -1,5 +1,5 @@
/* certcache.c - Certificate caching
- * Copyright (C) 2004, 2005 g10 Code GmbH
+ * Copyright (C) 2004, 2005, 2007 g10 Code GmbH
*
* This file is part of DirMngr.
*
@@ -66,9 +66,10 @@
/* This is the global cache_lock variable. In general looking is not
needed but it would take extra efforts to make sure that no
- indirect use of pth functions is done, so we simply lock it
- always. */
-static pth_rwlock_t cert_cache_lock = PTH_RWLOCK_INIT;
+ indirect use of pth functions is done, so we simply lock it always.
+ Note: We can't use static initialization, as that is not available
+ through w32-pth. */
+static pth_rwlock_t cert_cache_lock;
/* Flag to track whether the cache has been initialized. */
static int initialization_done;
@@ -80,8 +81,16 @@
-/* Helper to do the cahce locking. */
+/* Helper to do the cache locking. */
static void
+init_cache_lock (void)
+{
+ if (!pth_rwlock_init (&cert_cache_lock))
+ log_fatal (_("can't initialize certificate cache lock: %s\n"),
+ strerror (errno));
+}
+
+static void
acquire_cache_read_lock (void)
{
if (!pth_rwlock_acquire (&cert_cache_lock, PTH_RWLOCK_RD, FALSE, NULL))
@@ -404,6 +413,7 @@
if (initialization_done)
return;
+ init_cache_lock ();
acquire_cache_write_lock ();
dname = make_filename (opt.homedir, "trusted-certs", NULL);
More information about the Gnupg-commits
mailing list