mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Tweaks for gpgconf.
Fixed dirmngr bug 1010.
This commit is contained in:
parent
43a7cb7fd4
commit
5fd7ff3488
9 changed files with 103 additions and 19 deletions
|
@ -1,5 +1,12 @@
|
|||
2010-12-14 Werner Koch <wk@g10code.com>
|
||||
|
||||
* cdb.h (struct cdb) [W32]: Add field CDB_MAPPING.
|
||||
* cdblib.c (cdb_init) [W32]: Save mapping handle.
|
||||
(cdb_free) [W32]: Don't leak the mapping handle from cdb_init by
|
||||
using the saved one.
|
||||
|
||||
* crlcache.c (crl_cache_insert): Close unused matching files.
|
||||
|
||||
* dirmngr.c (main) [W32CE]: Change homedir in daemon mode to /gnupg.
|
||||
|
||||
2010-12-07 Werner Koch <wk@g10code.com>
|
||||
|
|
|
@ -20,6 +20,9 @@ void cdb_pack(cdbi_t num, unsigned char buf[4]);
|
|||
struct cdb {
|
||||
int cdb_fd; /* file descriptor */
|
||||
/* private members */
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
void *cdb_mapping; /* Mapping handle. */
|
||||
#endif
|
||||
cdbi_t cdb_fsize; /* datafile size */
|
||||
const unsigned char *cdb_mem; /* mmap'ed file memory */
|
||||
cdbi_t cdb_vpos, cdb_vlen; /* found data */
|
||||
|
|
|
@ -135,7 +135,7 @@ cdb_init(struct cdb *cdbp, int fd)
|
|||
hFile = fd;
|
||||
# else
|
||||
hFile = (HANDLE) _get_osfhandle(fd);
|
||||
#endif
|
||||
# endif
|
||||
if (hFile == (HANDLE) -1)
|
||||
return -1;
|
||||
hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
|
@ -144,6 +144,7 @@ cdb_init(struct cdb *cdbp, int fd)
|
|||
mem = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
|
||||
if (!mem)
|
||||
return -1;
|
||||
cdbp->cdb_mapping = hMapping;
|
||||
#else
|
||||
mem = (unsigned char*)mmap(NULL, fsize, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (mem == MAP_FAILED)
|
||||
|
@ -180,17 +181,9 @@ cdb_free(struct cdb *cdbp)
|
|||
{
|
||||
if (cdbp->cdb_mem) {
|
||||
#ifdef _WIN32
|
||||
HANDLE hFile, hMapping;
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#ifdef __MINGW32CE__
|
||||
hFile = cdbp->cdb_fd;
|
||||
#else
|
||||
hFile = (HANDLE) _get_osfhandle(cdbp->cdb_fd);
|
||||
#endif
|
||||
hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
UnmapViewOfFile((void*) cdbp->cdb_mem);
|
||||
CloseHandle(hMapping);
|
||||
UnmapViewOfFile ((void*) cdbp->cdb_mem);
|
||||
CloseHandle (cdbp->cdb_mapping);
|
||||
cdbp->cdb_mapping = NULL;
|
||||
#else
|
||||
munmap((void*)cdbp->cdb_mem, cdbp->cdb_fsize);
|
||||
#endif /* _WIN32 */
|
||||
|
|
|
@ -178,7 +178,7 @@ static crl_cache_entry_t find_entry (crl_cache_entry_t first,
|
|||
|
||||
|
||||
|
||||
/* The currently loaded cache object. This isi usually initialized
|
||||
/* The currently loaded cache object. This is usually initialized
|
||||
right at startup. */
|
||||
static crl_cache_t current_cache;
|
||||
|
||||
|
@ -393,7 +393,7 @@ release_cache (crl_cache_t cache)
|
|||
{
|
||||
entry2 = entry->next;
|
||||
release_one_cache_entry (entry);
|
||||
}
|
||||
}
|
||||
cache->entries = NULL;
|
||||
xfree (cache);
|
||||
}
|
||||
|
@ -1189,6 +1189,7 @@ unlock_db_file (crl_cache_t cache, crl_cache_entry_t entry)
|
|||
cache->entries = enext;
|
||||
else
|
||||
eprev->next = enext;
|
||||
/* FIXME: Do we leak ENTRY? */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1204,7 +1205,6 @@ find_entry (crl_cache_entry_t first, const char *issuer_hash)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* Create a new CRL cache. This fucntion is usually called only once.
|
||||
never fail. */
|
||||
void
|
||||
|
@ -2177,6 +2177,31 @@ crl_cache_insert (ctrl_t ctrl, const char *url, ksba_reader_t reader)
|
|||
newfname = make_db_file_name (entry->issuer_hash);
|
||||
if (opt.verbose)
|
||||
log_info (_("creating cache file `%s'\n"), newfname);
|
||||
|
||||
/* Just in case close unused matching files. Actually we need this
|
||||
only under Windows but saving file descriptors is never bad. */
|
||||
{
|
||||
int any;
|
||||
do
|
||||
{
|
||||
any = 0;
|
||||
for (e = cache->entries; e; e = e->next)
|
||||
if (!e->cdb_use_count && e->cdb
|
||||
&& !strcmp (e->issuer_hash, entry->issuer_hash))
|
||||
{
|
||||
int fd = cdb_fileno (e->cdb);
|
||||
cdb_free (e->cdb);
|
||||
xfree (e->cdb);
|
||||
e->cdb = NULL;
|
||||
if (close (fd))
|
||||
log_error (_("error closing cache file: %s\n"),
|
||||
strerror(errno));
|
||||
any = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (any);
|
||||
}
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
gnupg_remove (newfname);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue