"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "assoc.c" between
memcached-1.6.8.tar.gz and memcached-1.6.9.tar.gz

About: memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load.

assoc.c  (memcached-1.6.8):assoc.c  (memcached-1.6.9)
skipping to change at line 293 skipping to change at line 293
void stop_assoc_maintenance_thread() { void stop_assoc_maintenance_thread() {
mutex_lock(&maintenance_lock); mutex_lock(&maintenance_lock);
do_run_maintenance_thread = 0; do_run_maintenance_thread = 0;
pthread_cond_signal(&maintenance_cond); pthread_cond_signal(&maintenance_cond);
mutex_unlock(&maintenance_lock); mutex_unlock(&maintenance_lock);
/* Wait for the maintenance thread to stop */ /* Wait for the maintenance thread to stop */
pthread_join(maintenance_tid, NULL); pthread_join(maintenance_tid, NULL);
} }
struct assoc_iterator {
unsigned int bucket;
bool bucket_locked;
item *it;
item *next;
};
void *assoc_get_iterator(void) {
struct assoc_iterator *iter = calloc(1, sizeof(struct assoc_iterator));
if (iter == NULL) {
return NULL;
}
// this will hang the caller while a hash table expansion is running.
mutex_lock(&maintenance_lock);
return iter;
}
bool assoc_iterate(void *iterp, item **it) {
struct assoc_iterator *iter = (struct assoc_iterator *) iterp;
*it = NULL;
// - if locked bucket and next, update next and return
if (iter->bucket_locked) {
if (iter->next != NULL) {
iter->it = iter->next;
iter->next = iter->it->h_next;
*it = iter->it;
} else {
// unlock previous bucket, if any
item_unlock(iter->bucket);
// iterate the bucket post since it starts at 0.
iter->bucket++;
iter->bucket_locked = false;
*it = NULL;
}
return true;
}
// - loop until we hit the end or find something.
if (iter->bucket != hashsize(hashpower)) {
// - lock next bucket
item_lock(iter->bucket);
iter->bucket_locked = true;
// - only check the primary hash table since expand is blocked.
iter->it = primary_hashtable[iter->bucket];
if (iter->it != NULL) {
// - set it, next and return
iter->next = iter->it->h_next;
*it = iter->it;
} else {
// - nothing found in this bucket, try next.
item_unlock(iter->bucket);
iter->bucket_locked = false;
iter->bucket++;
}
} else {
return false;
}
return true;
}
void assoc_iterate_final(void *iterp) {
struct assoc_iterator *iter = (struct assoc_iterator *) iterp;
if (iter->bucket_locked) {
item_unlock(iter->bucket);
}
mutex_unlock(&maintenance_lock);
free(iter);
}
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)