Skip to content
Browse files

call mutex_unlock() when we use mutex_lock()

use both #define's when using the spinlock version of our locks. not all locks
are designed to be that way, so this doesn't touch the whole thing.
  • Loading branch information...
1 parent 67c9060 commit 890dfb75ed40e59bf3e46904431a5c27824e0b7e @dormando dormando committed
Showing with 19 additions and 19 deletions.
  1. +2 −2 assoc.c
  2. +9 −9 items.c
  3. +1 −1 memcached.c
  4. +7 −7 thread.c
View
4 assoc.c
@@ -235,7 +235,7 @@ static void *assoc_maintenance_thread(void *arg) {
pthread_cond_wait(&maintenance_cond, &cache_lock);
}
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
return NULL;
}
@@ -263,7 +263,7 @@ void stop_assoc_maintenance_thread() {
mutex_lock(&cache_lock);
do_run_maintenance_thread = 0;
pthread_cond_signal(&maintenance_cond);
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
/* Wait for the maintenance thread to stop */
pthread_join(maintenance_tid, NULL);
View
18 items.c
@@ -44,7 +44,7 @@ static unsigned int sizes[LARGEST_ID];
void item_stats_reset(void) {
mutex_lock(&cache_lock);
memset(itemstats, 0, sizeof(itemstats));
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
@@ -125,7 +125,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim
} else if ((it = slabs_alloc(ntotal, id)) == NULL) {
if (settings.evict_to_free == 0) {
itemstats[id].outofmemory++;
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
return NULL;
}
itemstats[id].evicted++;
@@ -181,7 +181,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim
search->refcount = 1;
do_item_unlink_nolock(search, hash(ITEM_key(search), search->nkey, 0));
}
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
return NULL;
}
@@ -192,7 +192,7 @@ item *do_item_alloc(char *key, const size_t nkey, const int flags, const rel_tim
* been removed from the slab LRU.
*/
it->refcount = 1; /* the caller will have a reference */
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
it->next = it->prev = it->h_next = 0;
it->slabs_clsid = id;
@@ -298,7 +298,7 @@ int do_item_link(item *it, const uint32_t hv) {
assoc_insert(it, hv);
item_link_q(it);
refcount_incr(&it->refcount);
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
return 1;
}
@@ -316,7 +316,7 @@ void do_item_unlink(item *it, const uint32_t hv) {
item_unlink_q(it);
do_item_remove(it);
}
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
/* FIXME: Is it necessary to keep this copy/pasted code? */
@@ -354,7 +354,7 @@ void do_item_update(item *it) {
it->time = current_time;
item_link_q(it);
}
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
}
@@ -413,7 +413,7 @@ void item_stats_evictions(uint64_t *evicted) {
for (i = 0; i < LARGEST_ID; i++) {
evicted[i] = itemstats[i].evicted;
}
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
void do_item_stats(ADD_STAT add_stats, void *c) {
@@ -505,7 +505,7 @@ item *do_item_get(const char *key, const size_t nkey, const uint32_t hv) {
it = NULL;
}
}
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
int was_found = 0;
if (settings.verbose > 2) {
View
2 memcached.c
@@ -3118,7 +3118,7 @@ enum delta_result_type do_add_delta(conn *c, const char *key, const size_t nkey,
need to update the CAS on the existing item. */
mutex_lock(&cache_lock); /* FIXME */
ITEM_set_cas(it, (settings.use_cas) ? get_cas_id() : 0);
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
memcpy(ITEM_data(it), buf, res);
memset(ITEM_data(it) + res, ' ', it->nbytes - res - 2);
View
14 thread.c
@@ -88,7 +88,7 @@ unsigned short refcount_incr(unsigned short *refcount) {
mutex_lock(&atomics_mutex);
(*refcount)++;
res = *refcount;
- pthread_mutex_unlock(&atomics_mutex);
+ mutex_unlock(&atomics_mutex);
return res;
#endif
}
@@ -103,7 +103,7 @@ unsigned short refcount_decr(unsigned short *refcount) {
mutex_lock(&atomics_mutex);
(*refcount)--;
res = *refcount;
- pthread_mutex_unlock(&atomics_mutex);
+ mutex_unlock(&atomics_mutex);
return res;
#endif
}
@@ -113,7 +113,7 @@ void item_lock(uint32_t hv) {
}
void item_unlock(uint32_t hv) {
- pthread_mutex_unlock(&item_locks[hv & item_lock_mask]);
+ mutex_unlock(&item_locks[hv & item_lock_mask]);
}
/*
@@ -505,7 +505,7 @@ enum store_item_type store_item(item *item, int comm, conn* c) {
void item_flush_expired() {
mutex_lock(&cache_lock);
do_item_flush_expired();
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
/*
@@ -516,7 +516,7 @@ char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int
mutex_lock(&cache_lock);
ret = do_item_cachedump(slabs_clsid, limit, bytes);
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
return ret;
}
@@ -526,7 +526,7 @@ char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int
void item_stats(ADD_STAT add_stats, void *c) {
mutex_lock(&cache_lock);
do_item_stats(add_stats, c);
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
/*
@@ -535,7 +535,7 @@ void item_stats(ADD_STAT add_stats, void *c) {
void item_stats_sizes(ADD_STAT add_stats, void *c) {
mutex_lock(&cache_lock);
do_item_stats_sizes(add_stats, c);
- pthread_mutex_unlock(&cache_lock);
+ mutex_unlock(&cache_lock);
}
/******************************* GLOBAL STATS ******************************/

0 comments on commit 890dfb7

Please sign in to comment.
Something went wrong with that request. Please try again.