mirror of
https://github.com/NLnetLabs/unbound.git
synced 2024-09-21 06:37:08 +00:00
- Fix unfreed locks in log and arc4random at exit of unbound.
git-svn-id: file:///svn/unbound/trunk@4491 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
8605797002
commit
30891d6fff
@ -33,6 +33,9 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
#define LOCKRET(func) func
|
||||
#ifdef ENABLE_LOCK_CHECKS
|
||||
#undef ENABLE_LOCK_CHECKS
|
||||
#endif
|
||||
#include "util/locks.h"
|
||||
|
||||
void _ARC4_LOCK(void);
|
||||
@ -46,6 +49,10 @@ void _ARC4_LOCK(void)
|
||||
void _ARC4_UNLOCK(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _ARC4_LOCK_DESTROY(void)
|
||||
{
|
||||
}
|
||||
#else /* !THREADS_DISABLED */
|
||||
|
||||
static lock_quick_type arc4lock;
|
||||
@ -64,4 +71,12 @@ void _ARC4_UNLOCK(void)
|
||||
{
|
||||
lock_quick_unlock(&arc4lock);
|
||||
}
|
||||
|
||||
void _ARC4_LOCK_DESTROY(void)
|
||||
{
|
||||
if(arc4lockinit) {
|
||||
arc4lockinit = 0;
|
||||
lock_quick_destroy(&arc4lock);
|
||||
}
|
||||
}
|
||||
#endif /* THREADS_DISABLED */
|
||||
|
@ -1150,6 +1150,7 @@ uint32_t arc4random(void);
|
||||
void arc4random_buf(void* buf, size_t n);
|
||||
void _ARC4_LOCK(void);
|
||||
void _ARC4_UNLOCK(void);
|
||||
void _ARC4_LOCK_DESTROY(void);
|
||||
#endif
|
||||
#ifndef HAVE_ARC4RANDOM_UNIFORM
|
||||
uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||
|
@ -1661,6 +1661,7 @@ uint32_t arc4random(void);
|
||||
void arc4random_buf(void* buf, size_t n);
|
||||
void _ARC4_LOCK(void);
|
||||
void _ARC4_UNLOCK(void);
|
||||
void _ARC4_LOCK_DESTROY(void);
|
||||
#endif
|
||||
#ifndef HAVE_ARC4RANDOM_UNIFORM
|
||||
uint32_t arc4random_uniform(uint32_t upper_bound);
|
||||
|
@ -778,6 +778,9 @@ daemon_delete(struct daemon* daemon)
|
||||
# if defined(HAVE_SSL) && defined(OPENSSL_THREADS) && !defined(THREADS_DISABLED)
|
||||
ub_openssl_lock_delete();
|
||||
# endif
|
||||
#ifndef HAVE_ARC4RANDOM
|
||||
_ARC4_LOCK_DESTROY();
|
||||
#endif
|
||||
#elif defined(HAVE_NSS)
|
||||
NSS_Shutdown();
|
||||
#endif /* HAVE_SSL or HAVE_NSS */
|
||||
|
@ -744,5 +744,10 @@ main(int argc, char* argv[])
|
||||
|
||||
run_daemon(cfgfile, cmdline_verbose, debug_mode, log_ident_default, need_pidfile);
|
||||
log_init(NULL, 0, NULL); /* close logfile */
|
||||
#ifndef unbound_testbound
|
||||
if(log_get_lock()) {
|
||||
lock_quick_destroy((lock_quick_type*)log_get_lock());
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
2 February 2018: Wouter
|
||||
- Fix unfreed locks in log and arc4random at exit of unbound.
|
||||
|
||||
1 February 2018: Wouter
|
||||
- fix unaligned structure making a false positive in checklock
|
||||
unitialised memory.
|
||||
|
@ -4276,6 +4276,8 @@ check_xfer_packet(sldns_buffer* pkt, struct auth_xfer* xfr,
|
||||
return 0;
|
||||
}
|
||||
/* check ID */
|
||||
log_info("id wire %x, want %x", (int)LDNS_ID_WIRE(wire),
|
||||
(int)xfr->task_transfer->id);
|
||||
if(LDNS_ID_WIRE(wire) != xfr->task_transfer->id) {
|
||||
verbose(VERB_ALGO, "xfr to %s failed, packet wrong ID",
|
||||
xfr->task_transfer->master->host);
|
||||
|
@ -456,7 +456,10 @@ main(int argc, char* argv[])
|
||||
for(c=1; c<pass_argc; c++)
|
||||
free(pass_argv[c]);
|
||||
if(res == 0) {
|
||||
log_info("Testbound Exit Success");
|
||||
log_info("Testbound Exit Success\n");
|
||||
if(log_get_lock()) {
|
||||
lock_quick_destroy((lock_quick_type*)log_get_lock());
|
||||
}
|
||||
#ifdef HAVE_PTHREAD
|
||||
/* dlopen frees its thread state (dlopen of gost engine) */
|
||||
pthread_exit(NULL);
|
||||
|
@ -191,6 +191,13 @@ void log_set_time_asc(int use_asc)
|
||||
log_time_asc = use_asc;
|
||||
}
|
||||
|
||||
void* log_get_lock(void)
|
||||
{
|
||||
if(!key_created)
|
||||
return NULL;
|
||||
return (void*)&log_lock;
|
||||
}
|
||||
|
||||
void
|
||||
log_vmsg(int pri, const char* type,
|
||||
const char *format, va_list args)
|
||||
|
@ -127,6 +127,9 @@ void log_set_time(time_t* t);
|
||||
*/
|
||||
void log_set_time_asc(int use_asc);
|
||||
|
||||
/** get log lock */
|
||||
void* log_get_lock(void);
|
||||
|
||||
/**
|
||||
* Log informational message.
|
||||
* Pass printf formatted arguments. No trailing newline is needed.
|
||||
|
Loading…
Reference in New Issue
Block a user