summaryrefslogtreecommitdiff
path: root/extra/memcached/0001-don-t-drop-to-a-condition-without-holding-the-lock.patch
blob: 6cae4123801ae9484303d979840d316f70ac3838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 9d635fa7f46f000d23663e0be3a900d2c51a3ed8 Mon Sep 17 00:00:00 2001
From: dormando <dormando@rydia.net>
Date: Sat, 19 Apr 2014 12:15:29 -0700
Subject: [PATCH 1/2] don't drop to a condition without holding the lock

I am a moran. How do you even thread.
---
 items.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/items.c b/items.c
index 688ad03..3e2f71f 100644
--- a/items.c
+++ b/items.c
@@ -764,6 +764,7 @@ static void item_crawler_evaluate(item *search, uint32_t hv, int i) {
 static void *item_crawler_thread(void *arg) {
     int i;
 
+    pthread_mutex_lock(&lru_crawler_lock);
     if (settings.verbose > 2)
         fprintf(stderr, "Starting LRU crawler background thread\n");
     while (do_run_lru_crawler_thread) {
@@ -827,8 +828,8 @@ static void *item_crawler_thread(void *arg) {
     STATS_LOCK();
     stats.lru_crawler_running = false;
     STATS_UNLOCK();
-    pthread_mutex_unlock(&lru_crawler_lock);
     }
+    pthread_mutex_unlock(&lru_crawler_lock);
     if (settings.verbose > 2)
         fprintf(stderr, "LRU crawler thread stopping\n");
 
-- 
1.9.2