busy with lruhash.

git-svn-id: file:///svn/unbound/trunk@175 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards
2007-03-13 16:22:24 +00:00
parent 09db7f94ed
commit 8fb3bb8bef
7 changed files with 528 additions and 1 deletions
+25
View File
@@ -132,6 +132,31 @@ lock_protect(void *p, void* area, size_t size)
LOCKRET(pthread_mutex_unlock(&lock->lock));
}
/** remove protected region */
void
lock_unprotect(void* mangled, void* area)
{
struct checked_lock* lock = *(struct checked_lock**)mangled;
struct protected_area* p, **prevp;
if(!lock)
return;
acquire_locklock(lock, __func__, __FILE__, __LINE__);
p = lock->prot;
prevp = &lock->prot;
while(p) {
if(p->region == area) {
*prevp = p->next;
free(p->hold);
free(p);
LOCKRET(pthread_mutex_unlock(&lock->lock));
return;
}
prevp = &p->next;
p = p->next;
}
LOCKRET(pthread_mutex_unlock(&lock->lock));
}
/**
* Check protected memory region. Memory compare. Exit on error.
* @param lock: which lock to check.
+8
View File
@@ -182,6 +182,14 @@ struct checked_lock {
*/
void lock_protect(void* lock, void* area, size_t size);
/**
* Remove protected area from lock.
* No need to call this when deleting the lock.
* @param lock: the lock, any type, (struct checked_lock**).
* @param area: pointer to memory.
*/
void lock_unprotect(void* lock, void* area);
/**
* Initialise checklock. Sets up internal debug structures.
*/