On Aug 18, 11:35 am, Trond Norbye <[email protected]> wrote:

> You should lock the thread-local stat instead. Look at get/set etc..

Ah, of course.  How's this? (currently my issue_75 branch on top of
issue_71)

commit 785913b8674ccc20b62dd077060cffd2c13cdbda
Author: Dustin Sallings <[email protected]>
Date:   Tue Aug 18 10:52:29 2009 -0700

    Replace unnecessary and incorrect global lock with thread lock on
flush.

diff --git a/memcached.c b/memcached.c
index 6edc481..f8eb224 100644
--- a/memcached.c
+++ b/memcached.c
@@ -1764,9 +1764,9 @@ static void process_bin_flush(conn *c) {
     }
     item_flush_expired();

-    STATS_LOCK();
+    pthread_mutex_lock(&c->thread->stats.mutex);
     c->thread->stats.flush_cmds++;
-    STATS_UNLOCK();
+    pthread_mutex_unlock(&c->thread->stats.mutex);

     write_bin_response(c, NULL, 0, 0, 0);
 }
@@ -2778,9 +2778,9 @@ static void process_command(conn *c, char
*command) {

         set_noreply_maybe(c, tokens, ntokens);

-        STATS_LOCK();
+        pthread_mutex_lock(&c->thread->stats.mutex);
         c->thread->stats.flush_cmds++;
-        STATS_UNLOCK();
+        pthread_mutex_unlock(&c->thread->stats.mutex);

         if(ntokens == (c->noreply ? 3 : 2)) {
             settings.oldest_live = current_time - 1;

Reply via email to