List:Commits« Previous MessageNext Message »
From:John David Duncan Date:October 1 2011 8:24pm
Subject:bzr push into mysql-5.5-cluster branch (john.duncan:3579 to 3580)
View as plain text  
 3580 John David Duncan	2011-10-01
      Instead of copying the default_engine into cache-src, use the bundled memcached source.

    removed:
      storage/ndb/memcache/cache-src/
      storage/ndb/memcache/cache-src/LICENSE
      storage/ndb/memcache/cache-src/assoc.c
      storage/ndb/memcache/cache-src/assoc.h
      storage/ndb/memcache/cache-src/default_engine.c
      storage/ndb/memcache/cache-src/default_engine.h
      storage/ndb/memcache/cache-src/items.c
      storage/ndb/memcache/cache-src/items.h
      storage/ndb/memcache/cache-src/slabs.c
      storage/ndb/memcache/cache-src/slabs.h
      storage/ndb/memcache/cache-src/trace.h
    modified:
      storage/ndb/memcache/CMakeLists.txt
      storage/ndb/memcache/unit/all_tests.h
      storage/ndb/memcache/unit/test_workqueue.c
 3579 John David Duncan	2011-09-30
      Coerce workitem.inline_buffer to be suitably aligned to hold a bigint.

    modified:
      storage/ndb/memcache/include/workitem.h
      storage/ndb/memcache/src/Record.cc
      storage/ndb/memcache/src/workitem.c
=== modified file 'storage/ndb/memcache/CMakeLists.txt'
--- a/storage/ndb/memcache/CMakeLists.txt	2011-09-30 17:04:30 +0000
+++ b/storage/ndb/memcache/CMakeLists.txt	2011-10-01 16:54:26 +0000
@@ -38,12 +38,17 @@ if(NO_ATOMICS)
   RETURN()
 ENDIF()
 
+# Reuse the default engine from the bundled source tree
+set(BUNDLED_MEMCACHED extra/memcached)
+set(CACHE_SRC ${BUNDLED_MEMCACHED}/engines/default_engine)
+
 # Paths to header files
 include_directories(BEFORE include)
-include_directories(BEFORE cache-src)
+include_directories(BEFORE ${CACHE_SRC})
 include_directories(${NDB_SOURCE_DIR}/src/ndbjtie/mysql)
-include_directories(AFTER ${MEMCACHED_INCLUDE_DIR})
 include_directories(${NDB_SOURCE_DIR}/src/ndbapi/)
+include_directories(AFTER ${MEMCACHED_INCLUDE_DIR})
+include_directories(AFTER ${BUNDLED_MEMCACHED})
 
 # Paths to libraries
 link_directories(${NDB_SOURCE_DIR}/src 
@@ -81,9 +86,9 @@ set(NDB_MEMCACHE_SOURCE_FILES
     src/schedulers/Stockholm.cc
     src/ndb_engine.c
     src/embedded_default_engine.c
-    cache-src/assoc.c
-    cache-src/items.c
-    cache-src/slabs.c
+    ${CACHE_SRC}/assoc.c
+    ${CACHE_SRC}/items.c
+    ${CACHE_SRC}/slabs.c
  )
   
 

=== removed directory 'storage/ndb/memcache/cache-src'
=== removed file 'storage/ndb/memcache/cache-src/LICENSE'
--- a/storage/ndb/memcache/cache-src/LICENSE	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/LICENSE	1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
-Copyright (c) 2003, Danga Interactive, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-
-    * Neither the name of the Danga Interactive nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=== removed file 'storage/ndb/memcache/cache-src/assoc.c'
--- a/storage/ndb/memcache/cache-src/assoc.c	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/assoc.c	1970-01-01 00:00:00 +0000
@@ -1,203 +0,0 @@
-/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Hash table
- *
- */
-#include "config.h"
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <pthread.h>
-
-#include "default_engine.h"
-
-#define hashsize(n) ((uint32_t)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-
-ENGINE_ERROR_CODE assoc_init(struct default_engine *engine) {
-    engine->assoc.primary_hashtable = calloc(hashsize(engine->assoc.hashpower), sizeof(void *));
-    return (engine->assoc.primary_hashtable != NULL) ? ENGINE_SUCCESS : ENGINE_ENOMEM;
-}
-
-hash_item *assoc_find(struct default_engine *engine, uint32_t hash, const char *key, const size_t nkey) {
-    hash_item *it;
-    unsigned int oldbucket;
-
-    if (engine->assoc.expanding &&
-        (oldbucket = (hash & hashmask(engine->assoc.hashpower - 1))) >= engine->assoc.expand_bucket)
-    {
-        it = engine->assoc.old_hashtable[oldbucket];
-    } else {
-        it = engine->assoc.primary_hashtable[hash & hashmask(engine->assoc.hashpower)];
-    }
-
-    hash_item *ret = NULL;
-    int depth = 0;
-    while (it) {
-        if ((nkey == it->nkey) && (memcmp(key, item_get_key(it), nkey) == 0)) {
-            ret = it;
-            break;
-        }
-        it = it->h_next;
-        ++depth;
-    }
-    MEMCACHED_ASSOC_FIND(key, nkey, depth);
-    return ret;
-}
-
-/* returns the address of the item pointer before the key.  if *item == 0,
-   the item wasn't found */
-
-static hash_item** _hashitem_before(struct default_engine *engine,
-                                    uint32_t hash,
-                                    const char *key,
-                                    const size_t nkey) {
-    hash_item **pos;
-    unsigned int oldbucket;
-
-    if (engine->assoc.expanding &&
-        (oldbucket = (hash & hashmask(engine->assoc.hashpower - 1))) >= engine->assoc.expand_bucket)
-    {
-        pos = &engine->assoc.old_hashtable[oldbucket];
-    } else {
-        pos = &engine->assoc.primary_hashtable[hash & hashmask(engine->assoc.hashpower)];
-    }
-
-    while (*pos && ((nkey != (*pos)->nkey) || memcmp(key, item_get_key(*pos), nkey))) {
-        pos = &(*pos)->h_next;
-    }
-    return pos;
-}
-
-static void *assoc_maintenance_thread(void *arg);
-
-/* grows the hashtable to the next power of 2. */
-static void assoc_expand(struct default_engine *engine) {
-    engine->assoc.old_hashtable = engine->assoc.primary_hashtable;
-
-    engine->assoc.primary_hashtable = calloc(hashsize(engine->assoc.hashpower + 1), sizeof(void *));
-    if (engine->assoc.primary_hashtable) {
-        engine->assoc.hashpower++;
-        engine->assoc.expanding = true;
-        engine->assoc.expand_bucket = 0;
-
-        /* start a thread to do the expansion */
-        int ret = 0;
-        pthread_t tid;
-        pthread_attr_t attr;
-
-        if (pthread_attr_init(&attr) != 0 ||
-            pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0 ||
-            (ret = pthread_create(&tid, &attr,
-                                  assoc_maintenance_thread, engine)) != 0)
-        {
-            EXTENSION_LOGGER_DESCRIPTOR *logger;
-            logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-            logger->log(EXTENSION_LOG_WARNING, NULL,
-                        "Can't create thread: %s\n", strerror(ret));
-            engine->assoc.hashpower--;
-            engine->assoc.expanding = false;
-            free(engine->assoc.primary_hashtable);
-            engine->assoc.primary_hashtable =engine->assoc.old_hashtable;
-        }
-    } else {
-        engine->assoc.primary_hashtable = engine->assoc.old_hashtable;
-        /* Bad news, but we can keep running. */
-    }
-}
-
-/* Note: this isn't an assoc_update.  The key must not already exist to call this */
-int assoc_insert(struct default_engine *engine, uint32_t hash, hash_item *it) {
-    unsigned int oldbucket;
-
-    assert(assoc_find(engine, hash, item_get_key(it), it->nkey) == 0);  /* shouldn't have duplicately named things defined */
-
-    if (engine->assoc.expanding &&
-        (oldbucket = (hash & hashmask(engine->assoc.hashpower - 1))) >= engine->assoc.expand_bucket)
-    {
-        it->h_next = engine->assoc.old_hashtable[oldbucket];
-        engine->assoc.old_hashtable[oldbucket] = it;
-    } else {
-        it->h_next = engine->assoc.primary_hashtable[hash & hashmask(engine->assoc.hashpower)];
-        engine->assoc.primary_hashtable[hash & hashmask(engine->assoc.hashpower)] = it;
-    }
-
-    engine->assoc.hash_items++;
-    if (! engine->assoc.expanding && engine->assoc.hash_items > (hashsize(engine->assoc.hashpower) * 3) / 2) {
-        assoc_expand(engine);
-    }
-
-    MEMCACHED_ASSOC_INSERT(item_get_key(it), it->nkey, engine->assoc.hash_items);
-    return 1;
-}
-
-void assoc_delete(struct default_engine *engine, uint32_t hash, const char *key, const size_t nkey) {
-    hash_item **before = _hashitem_before(engine, hash, key, nkey);
-
-    if (*before) {
-        hash_item *nxt;
-        engine->assoc.hash_items--;
-        /* The DTrace probe cannot be triggered as the last instruction
-         * due to possible tail-optimization by the compiler
-         */
-        MEMCACHED_ASSOC_DELETE(key, nkey, engine->assoc.hash_items);
-        nxt = (*before)->h_next;
-        (*before)->h_next = 0;   /* probably pointless, but whatever. */
-        *before = nxt;
-        return;
-    }
-    /* Note:  we never actually get here.  the callers don't delete things
-       they can't find. */
-    assert(*before != 0);
-}
-
-
-
-#define DEFAULT_HASH_BULK_MOVE 1
-int hash_bulk_move = DEFAULT_HASH_BULK_MOVE;
-
-static void *assoc_maintenance_thread(void *arg) {
-    struct default_engine *engine = arg;
-    bool done = false;
-    do {
-        int ii;
-        pthread_mutex_lock(&engine->cache_lock);
-
-        for (ii = 0; ii < hash_bulk_move && engine->assoc.expanding; ++ii) {
-            hash_item *it, *next;
-            int bucket;
-
-            for (it = engine->assoc.old_hashtable[engine->assoc.expand_bucket];
-                 NULL != it; it = next) {
-                next = it->h_next;
-
-                bucket = engine->server.core->hash(item_get_key(it), it->nkey, 0)
-                    & hashmask(engine->assoc.hashpower);
-                it->h_next = engine->assoc.primary_hashtable[bucket];
-                engine->assoc.primary_hashtable[bucket] = it;
-            }
-
-            engine->assoc.old_hashtable[engine->assoc.expand_bucket] = NULL;
-            engine->assoc.expand_bucket++;
-            if (engine->assoc.expand_bucket == hashsize(engine->assoc.hashpower - 1)) {
-                engine->assoc.expanding = false;
-                free(engine->assoc.old_hashtable);
-                if (engine->config.verbose > 1) {
-                    EXTENSION_LOGGER_DESCRIPTOR *logger;
-                    logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-                    logger->log(EXTENSION_LOG_INFO, NULL,
-                                "Hash table expansion done\n");
-                }
-            }
-        }
-        if (!engine->assoc.expanding) {
-            done = true;
-        }
-        pthread_mutex_unlock(&engine->cache_lock);
-    } while (!done);
-
-    return NULL;
-}

=== removed file 'storage/ndb/memcache/cache-src/assoc.h'
--- a/storage/ndb/memcache/cache-src/assoc.h	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/assoc.h	1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
-#ifndef ASSOC_H
-#define ASSOC_H
-
-struct assoc {
-   /* how many powers of 2's worth of buckets we use */
-   unsigned int hashpower;
-
-
-   /* Main hash table. This is where we look except during expansion. */
-   hash_item** primary_hashtable;
-
-   /*
-    * Previous hash table. During expansion, we look here for keys that haven't
-    * been moved over to the primary yet.
-    */
-   hash_item** old_hashtable;
-
-   /* Number of items in the hash table. */
-   unsigned int hash_items;
-
-   /* Flag: Are we in the middle of expanding now? */
-   bool expanding;
-
-   /*
-    * During expansion we migrate values with bucket granularity; this is how
-    * far we've gotten so far. Ranges from 0 .. hashsize(hashpower - 1) - 1.
-    */
-   unsigned int expand_bucket;
-};
-
-/* associative array */
-ENGINE_ERROR_CODE assoc_init(struct default_engine *engine);
-hash_item *assoc_find(struct default_engine *engine, uint32_t hash,
-                      const char *key, const size_t nkey);
-int assoc_insert(struct default_engine *engine, uint32_t hash,
-                 hash_item *item);
-void assoc_delete(struct default_engine *engine, uint32_t hash,
-                  const char *key, const size_t nkey);
-int start_assoc_maintenance_thread(struct default_engine *engine);
-void stop_assoc_maintenance_thread(struct default_engine *engine);
-
-#endif

=== removed file 'storage/ndb/memcache/cache-src/default_engine.c'
--- a/storage/ndb/memcache/cache-src/default_engine.c	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/default_engine.c	1970-01-01 00:00:00 +0000
@@ -1,909 +0,0 @@
-/*
-   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
- */
-/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <stddef.h>
-#include <inttypes.h>
-
-#include "default_engine.h"
-#include "memcached/util.h"
-#include "memcached/config_parser.h"
-
-static const engine_info* default_get_info(ENGINE_HANDLE* handle);
-static ENGINE_ERROR_CODE default_initialize(ENGINE_HANDLE* handle,
-                                            const char* config_str);
-static void default_destroy(ENGINE_HANDLE* handle,
-                            const bool force);
-static ENGINE_ERROR_CODE default_item_allocate(ENGINE_HANDLE* handle,
-                                               const void* cookie,
-                                               item **item,
-                                               const void* key,
-                                               const size_t nkey,
-                                               const size_t nbytes,
-                                               const int flags,
-                                               const rel_time_t exptime);
-static ENGINE_ERROR_CODE default_item_delete(ENGINE_HANDLE* handle,
-                                             const void* cookie,
-                                             const void* key,
-                                             const size_t nkey,
-                                             uint64_t cas,
-                                             uint16_t vbucket);
-
-static void default_item_release(ENGINE_HANDLE* handle, const void *cookie,
-                                 item* item);
-static ENGINE_ERROR_CODE default_get(ENGINE_HANDLE* handle,
-                                     const void* cookie,
-                                     item** item,
-                                     const void* key,
-                                     const int nkey,
-                                     uint16_t vbucket);
-static ENGINE_ERROR_CODE default_get_stats(ENGINE_HANDLE* handle,
-                  const void *cookie,
-                  const char *stat_key,
-                  int nkey,
-                  ADD_STAT add_stat);
-static void default_reset_stats(ENGINE_HANDLE* handle, const void *cookie);
-static ENGINE_ERROR_CODE default_store(ENGINE_HANDLE* handle,
-                                       const void *cookie,
-                                       item* item,
-                                       uint64_t *cas,
-                                       ENGINE_STORE_OPERATION operation,
-                                       uint16_t vbucket);
-static ENGINE_ERROR_CODE default_arithmetic(ENGINE_HANDLE* handle,
-                                            const void* cookie,
-                                            const void* key,
-                                            const int nkey,
-                                            const bool increment,
-                                            const bool create,
-                                            const uint64_t delta,
-                                            const uint64_t initial,
-                                            const rel_time_t exptime,
-                                            uint64_t *cas,
-                                            uint64_t *result,
-                                            uint16_t vbucket);
-static ENGINE_ERROR_CODE default_flush(ENGINE_HANDLE* handle,
-                                       const void* cookie, time_t when);
-static ENGINE_ERROR_CODE initalize_configuration(struct default_engine *se,
-                                                 const char *cfg_str);
-static ENGINE_ERROR_CODE default_unknown_command(ENGINE_HANDLE* handle,
-                                                 const void* cookie,
-                                                 protocol_binary_request_header *request,
-                                                 ADD_RESPONSE response);
-
-static ENGINE_ERROR_CODE default_tap_notify(ENGINE_HANDLE* handle,
-                                            const void *cookie,
-                                            void *engine_specific,
-                                            uint16_t nengine,
-                                            uint8_t ttl,
-                                            uint16_t tap_flags,
-                                            tap_event_t tap_event,
-                                            uint32_t tap_seqno,
-                                            const void *key,
-                                            size_t nkey,
-                                            uint32_t flags,
-                                            uint32_t exptime,
-                                            uint64_t cas,
-                                            const void *data,
-                                            size_t ndata,
-                                            uint16_t vbucket);
-
-static TAP_ITERATOR default_get_tap_iterator(ENGINE_HANDLE* handle,
-                                             const void* cookie,
-                                             const void* client,
-                                             size_t nclient,
-                                             uint32_t flags,
-                                             const void* userdata,
-                                             size_t nuserdata);
-
-static void default_handle_disconnect(const void *cookie,
-                                      ENGINE_EVENT_TYPE type,
-                                      const void *event_data,
-                                      const void *cb_data);
-
-union vbucket_info_adapter {
-    char c;
-    struct vbucket_info v;
-};
-
-static void set_vbucket_state(struct default_engine *e,
-                              uint16_t vbid, vbucket_state_t to) {
-    union vbucket_info_adapter vi;
-    vi.c = e->vbucket_infos[vbid];
-    vi.v.state = to;
-    e->vbucket_infos[vbid] = vi.c;
-}
-
-static vbucket_state_t get_vbucket_state(struct default_engine *e,
-                                         uint16_t vbid) {
-    union vbucket_info_adapter vi;
-    vi.c = e->vbucket_infos[vbid];
-    return vi.v.state;
-}
-
-static bool handled_vbucket(struct default_engine *e, uint16_t vbid) {
-    return e->config.ignore_vbucket
-        || (get_vbucket_state(e, vbid) == vbucket_state_active);
-}
-
-/* mechanism for handling bad vbucket requests */
-#define VBUCKET_GUARD(e, v) if (!handled_vbucket(e, v)) { return ENGINE_NOT_MY_VBUCKET; }
-
-static bool get_item_info(ENGINE_HANDLE *handle, const void *cookie,
-                          const item* item, item_info *item_info);
-
-static const char const * vbucket_state_name(vbucket_state_t s) {
-    static const char const * vbucket_states[] = {
-        [vbucket_state_active] = "active",
-        [vbucket_state_replica] = "replica",
-        [vbucket_state_pending] = "pending",
-        [vbucket_state_dead] = "dead"
-    };
-    if (is_valid_vbucket_state_t(s)) {
-        return vbucket_states[s];
-    } else {
-        return "Illegal vbucket state";
-    }
-}
-
-ENGINE_ERROR_CODE default_engine_create_instance(uint64_t interface,
-                                  GET_SERVER_API get_server_api,
-                                  ENGINE_HANDLE **handle) {
-   SERVER_HANDLE_V1 *api = get_server_api();
-   if (interface != 1 || api == NULL) {
-      return ENGINE_ENOTSUP;
-   }
-
-   struct default_engine *engine = malloc(sizeof(*engine));
-   if (engine == NULL) {
-      return ENGINE_ENOMEM;
-   }
-
-   struct default_engine default_engine = {
-      .engine = {
-         .interface = {
-            .interface = 1
-         },
-         .get_info = default_get_info,
-         .initialize = default_initialize,
-         .destroy = default_destroy,
-         .allocate = default_item_allocate,
-         .remove = default_item_delete,
-         .release = default_item_release,
-         .get = default_get,
-         .get_stats = default_get_stats,
-         .reset_stats = default_reset_stats,
-         .store = default_store,
-         .arithmetic = default_arithmetic,
-         .flush = default_flush,
-         .unknown_command = default_unknown_command,
-         .tap_notify = default_tap_notify,
-         .get_tap_iterator = default_get_tap_iterator,
-         .item_set_cas = item_set_cas,
-         .get_item_info = get_item_info
-      },
-      .server = *api,
-      .get_server_api = get_server_api,
-      .initialized = true,
-      .assoc = {
-         .hashpower = 16,
-      },
-      .slabs = {
-         .lock = PTHREAD_MUTEX_INITIALIZER
-      },
-      .cache_lock = PTHREAD_MUTEX_INITIALIZER,
-      .stats = {
-         .lock = PTHREAD_MUTEX_INITIALIZER,
-      },
-      .config = {
-         .use_cas = true,
-         .verbose = 0,
-         .oldest_live = 0,
-         .evict_to_free = true,
-         .maxbytes = 64 * 1024 * 1024,
-         .preallocate = false,
-         .factor = 1.25,
-         .chunk_size = 48,
-         .item_size_max= 1024 * 1024,
-       },
-      .scrubber = {
-         .lock = PTHREAD_MUTEX_INITIALIZER,
-      },
-      .tap_connections = {
-         .lock = PTHREAD_MUTEX_INITIALIZER,
-         .size = 10,
-      },
-      .info.engine_info = {
-           .description = "Default engine v0.1",
-           .num_features = 1,
-           .features = {
-               [0].feature = ENGINE_FEATURE_LRU
-           }
-       }
-   };
-
-   *engine = default_engine;
-   engine->tap_connections.clients = calloc(default_engine.tap_connections.size, sizeof(void*));
-   if (engine->tap_connections.clients == NULL) {
-       free(engine);
-       return ENGINE_ENOMEM;
-   }
-   *handle = (ENGINE_HANDLE*)&engine->engine;
-   return ENGINE_SUCCESS;
-}
-
-static inline struct default_engine* get_handle(ENGINE_HANDLE* handle) {
-   return (struct default_engine*)handle;
-}
-
-static inline hash_item* get_real_item(item* item) {
-    return (hash_item*)item;
-}
-
-static const engine_info* default_get_info(ENGINE_HANDLE* handle) {
-    return &get_handle(handle)->info.engine_info;
-}
-
-static ENGINE_ERROR_CODE default_initialize(ENGINE_HANDLE* handle,
-                                            const char* config_str) {
-   struct default_engine* se = get_handle(handle);
-
-   ENGINE_ERROR_CODE ret = initalize_configuration(se, config_str);
-   if (ret != ENGINE_SUCCESS) {
-      return ret;
-   }
-
-   /* fixup feature_info */
-   if (se->config.use_cas) {
-       se->info.engine_info.features[se->info.engine_info.num_features++].feature = ENGINE_FEATURE_CAS;
-   }
-
-   ret = assoc_init(se);
-   if (ret != ENGINE_SUCCESS) {
-      return ret;
-   }
-
-   ret = slabs_init(se, se->config.maxbytes, se->config.factor,
-                    se->config.preallocate);
-   if (ret != ENGINE_SUCCESS) {
-      return ret;
-   }
-
-   se->server.callback->register_callback(handle, ON_DISCONNECT, default_handle_disconnect, handle);
-
-   return ENGINE_SUCCESS;
-}
-
-static void default_destroy(ENGINE_HANDLE* handle, const bool force) {
-   (void) force;
-   struct default_engine* se = get_handle(handle);
-
-   if (se->initialized) {
-      pthread_mutex_destroy(&se->cache_lock);
-      pthread_mutex_destroy(&se->stats.lock);
-      pthread_mutex_destroy(&se->slabs.lock);
-      se->initialized = false;
-      free(se->tap_connections.clients);
-      free(se);
-   }
-}
-
-static ENGINE_ERROR_CODE default_item_allocate(ENGINE_HANDLE* handle,
-                                               const void* cookie,
-                                               item **item,
-                                               const void* key,
-                                               const size_t nkey,
-                                               const size_t nbytes,
-                                               const int flags,
-                                               const rel_time_t exptime) {
-   struct default_engine* engine = get_handle(handle);
-   size_t ntotal = sizeof(hash_item) + nkey + nbytes;
-   if (engine->config.use_cas) {
-      ntotal += sizeof(uint64_t);
-   }
-   unsigned int id = slabs_clsid(engine, ntotal);
-   if (id == 0) {
-      return ENGINE_E2BIG;
-   }
-
-   hash_item *it;
-   it = item_alloc(engine, key, nkey, flags, engine->server.core->realtime(exptime),
-                   nbytes, cookie);
-
-   if (it != NULL) {
-      *item = it;
-      return ENGINE_SUCCESS;
-   } else {
-      return ENGINE_ENOMEM;
-   }
-}
-
-static ENGINE_ERROR_CODE default_item_delete(ENGINE_HANDLE* handle,
-                                             const void* cookie,
-                                             const void* key,
-                                             const size_t nkey,
-                                             uint64_t cas,
-                                             uint16_t vbucket)
-{
-   struct default_engine* engine = get_handle(handle);
-   VBUCKET_GUARD(engine, vbucket);
-
-   hash_item *it = item_get(engine, key, nkey);
-   if (it == NULL) {
-      return ENGINE_KEY_ENOENT;
-   }
-
-   if (cas == 0 || cas == item_get_cas(it)) {
-      item_unlink(engine, it);
-      item_release(engine, it);
-   } else {
-      return ENGINE_KEY_EEXISTS;
-   }
-
-   return ENGINE_SUCCESS;
-}
-
-static void default_item_release(ENGINE_HANDLE* handle,
-                                 const void *cookie,
-                                 item* item) {
-   item_release(get_handle(handle), get_real_item(item));
-}
-
-static ENGINE_ERROR_CODE default_get(ENGINE_HANDLE* handle,
-                                     const void* cookie,
-                                     item** item,
-                                     const void* key,
-                                     const int nkey,
-                                     uint16_t vbucket) {
-   struct default_engine *engine = get_handle(handle);
-   VBUCKET_GUARD(engine, vbucket);
-
-   *item = item_get(engine, key, nkey);
-   if (*item != NULL) {
-      return ENGINE_SUCCESS;
-   } else {
-      return ENGINE_KEY_ENOENT;
-   }
-}
-
-static void stats_vbucket(struct default_engine *e,
-                          ADD_STAT add_stat,
-                          const void *cookie) {
-    for (int i = 0; i < NUM_VBUCKETS; i++) {
-        vbucket_state_t state = get_vbucket_state(e, i);
-        if (state != vbucket_state_dead) {
-            char buf[16];
-            snprintf(buf, sizeof(buf), "vb_%d", i);
-            const char * state_name = vbucket_state_name(state);
-            add_stat(buf, strlen(buf), state_name, strlen(state_name), cookie);
-        }
-    }
-}
-
-static ENGINE_ERROR_CODE default_get_stats(ENGINE_HANDLE* handle,
-                                           const void* cookie,
-                                           const char* stat_key,
-                                           int nkey,
-                                           ADD_STAT add_stat)
-{
-   struct default_engine* engine = get_handle(handle);
-   ENGINE_ERROR_CODE ret = ENGINE_SUCCESS;
-
-   if (stat_key == NULL) {
-      char val[128];
-      int len;
-
-      pthread_mutex_lock(&engine->stats.lock);
-      len = sprintf(val, "%"PRIu64, (uint64_t)engine->stats.evictions);
-      add_stat("evictions", 9, val, len, cookie);
-      len = sprintf(val, "%"PRIu64, (uint64_t)engine->stats.curr_items);
-      add_stat("curr_items", 10, val, len, cookie);
-      len = sprintf(val, "%"PRIu64, (uint64_t)engine->stats.total_items);
-      add_stat("total_items", 11, val, len, cookie);
-      len = sprintf(val, "%"PRIu64, (uint64_t)engine->stats.curr_bytes);
-      add_stat("bytes", 5, val, len, cookie);
-      len = sprintf(val, "%"PRIu64, engine->stats.reclaimed);
-      add_stat("reclaimed", 9, val, len, cookie);
-      len = sprintf(val, "%"PRIu64, (uint64_t)engine->config.maxbytes);
-      add_stat("engine_maxbytes", 15, val, len, cookie);
-      pthread_mutex_unlock(&engine->stats.lock);
-   } else if (strncmp(stat_key, "slabs", 5) == 0) {
-      slabs_stats(engine, add_stat, cookie);
-   } else if (strncmp(stat_key, "items", 5) == 0) {
-      item_stats(engine, add_stat, cookie);
-   } else if (strncmp(stat_key, "sizes", 5) == 0) {
-      item_stats_sizes(engine, add_stat, cookie);
-   } else if (strncmp(stat_key, "vbucket", 7) == 0) {
-      stats_vbucket(engine, add_stat, cookie);
-   } else if (strncmp(stat_key, "scrub", 5) == 0) {
-      char val[128];
-      int len;
-
-      pthread_mutex_lock(&engine->scrubber.lock);
-      if (engine->scrubber.running) {
-         add_stat("scrubber:status", 15, "running", 7, cookie);
-      } else {
-         add_stat("scrubber:status", 15, "stopped", 7, cookie);
-      }
-
-      if (engine->scrubber.started != 0) {
-         if (engine->scrubber.stopped != 0) {
-            time_t diff = engine->scrubber.started - engine->scrubber.stopped;
-            len = sprintf(val, "%"PRIu64, (uint64_t)diff);
-            add_stat("scrubber:last_run", 17, val, len, cookie);
-         }
-
-         len = sprintf(val, "%"PRIu64, engine->scrubber.visited);
-         add_stat("scrubber:visited", 16, val, len, cookie);
-         len = sprintf(val, "%"PRIu64, engine->scrubber.cleaned);
-         add_stat("scrubber:cleaned", 16, val, len, cookie);
-      }
-      pthread_mutex_unlock(&engine->scrubber.lock);
-   } else {
-      ret = ENGINE_KEY_ENOENT;
-   }
-
-   return ret;
-}
-
-static ENGINE_ERROR_CODE default_store(ENGINE_HANDLE* handle,
-                                       const void *cookie,
-                                       item* item,
-                                       uint64_t *cas,
-                                       ENGINE_STORE_OPERATION operation,
-                                       uint16_t vbucket) {
-    struct default_engine *engine = get_handle(handle);
-    VBUCKET_GUARD(engine, vbucket);
-    return store_item(engine, get_real_item(item), cas, operation,
-                      cookie);
-}
-
-static ENGINE_ERROR_CODE default_arithmetic(ENGINE_HANDLE* handle,
-                                            const void* cookie,
-                                            const void* key,
-                                            const int nkey,
-                                            const bool increment,
-                                            const bool create,
-                                            const uint64_t delta,
-                                            const uint64_t initial,
-                                            const rel_time_t exptime,
-                                            uint64_t *cas,
-                                            uint64_t *result,
-                                            uint16_t vbucket) {
-   struct default_engine *engine = get_handle(handle);
-   VBUCKET_GUARD(engine, vbucket);
-
-   return arithmetic(engine, cookie, key, nkey, increment,
-                     create, delta, initial, engine->server.core->realtime(exptime), cas,
-                     result);
-}
-
-static ENGINE_ERROR_CODE default_flush(ENGINE_HANDLE* handle,
-                                       const void* cookie, time_t when) {
-   item_flush_expired(get_handle(handle), when);
-
-   return ENGINE_SUCCESS;
-}
-
-static void default_reset_stats(ENGINE_HANDLE* handle, const void *cookie) {
-   struct default_engine *engine = get_handle(handle);
-   item_stats_reset(engine);
-
-   pthread_mutex_lock(&engine->stats.lock);
-   engine->stats.evictions = 0;
-   engine->stats.reclaimed = 0;
-   engine->stats.total_items = 0;
-   pthread_mutex_unlock(&engine->stats.lock);
-}
-
-static ENGINE_ERROR_CODE initalize_configuration(struct default_engine *se,
-                                                 const char *cfg_str) {
-   ENGINE_ERROR_CODE ret = ENGINE_SUCCESS;
-
-   se->config.vb0 = true;
-
-   if (cfg_str != NULL) {
-      struct config_item items[] = {
-         { .key = "use_cas",
-           .datatype = DT_BOOL,
-           .value.dt_bool = &se->config.use_cas },
-         { .key = "verbose",
-           .datatype = DT_SIZE,
-           .value.dt_size = &se->config.verbose },
-         { .key = "eviction",
-           .datatype = DT_BOOL,
-           .value.dt_bool = &se->config.evict_to_free },
-         { .key = "cache_size",
-           .datatype = DT_SIZE,
-           .value.dt_size = &se->config.maxbytes },
-         { .key = "preallocate",
-           .datatype = DT_BOOL,
-           .value.dt_bool = &se->config.preallocate },
-         { .key = "factor",
-           .datatype = DT_FLOAT,
-           .value.dt_float = &se->config.factor },
-         { .key = "chunk_size",
-           .datatype = DT_SIZE,
-           .value.dt_size = &se->config.chunk_size },
-         { .key = "item_size_max",
-           .datatype = DT_SIZE,
-           .value.dt_size = &se->config.item_size_max },
-         { .key = "ignore_vbucket",
-           .datatype = DT_BOOL,
-           .value.dt_bool = &se->config.ignore_vbucket },
-         { .key = "vb0",
-           .datatype = DT_BOOL,
-           .value.dt_bool = &se->config.vb0 },
-         { .key = "config_file",
-           .datatype = DT_CONFIGFILE },
-         { .key = NULL}
-      };
-
-      ret = se->server.core->parse_config(cfg_str, items, stderr);
-   }
-
-   if (se->config.vb0) {
-       set_vbucket_state(se, 0, vbucket_state_active);
-   }
-
-   return ENGINE_SUCCESS;
-}
-
-static bool set_vbucket(struct default_engine *e,
-                        const void* cookie,
-                        protocol_binary_request_set_vbucket *req,
-                        ADD_RESPONSE response) {
-    size_t bodylen = ntohl(req->message.header.request.bodylen)
-        - ntohs(req->message.header.request.keylen);
-    if (bodylen != sizeof(vbucket_state_t)) {
-        const char *msg = "Incorrect packet format";
-        return response(NULL, 0, NULL, 0, msg, strlen(msg),
-                        PROTOCOL_BINARY_RAW_BYTES,
-                        PROTOCOL_BINARY_RESPONSE_EINVAL, 0, cookie);
-    }
-    vbucket_state_t state;
-    memcpy(&state, &req->message.body.state, sizeof(state));
-    state = ntohl(state);
-
-    if (!is_valid_vbucket_state_t(state)) {
-        const char *msg = "Invalid vbucket state";
-        return response(NULL, 0, NULL, 0, msg, strlen(msg),
-                        PROTOCOL_BINARY_RAW_BYTES,
-                        PROTOCOL_BINARY_RESPONSE_EINVAL, 0, cookie);
-    }
-
-    set_vbucket_state(e, ntohs(req->message.header.request.vbucket), state);
-    return response(NULL, 0, NULL, 0, &state, sizeof(state),
-                    PROTOCOL_BINARY_RAW_BYTES,
-                    PROTOCOL_BINARY_RESPONSE_SUCCESS, 0, cookie);
-}
-
-static bool get_vbucket(struct default_engine *e,
-                        const void* cookie,
-                        protocol_binary_request_get_vbucket *req,
-                        ADD_RESPONSE response) {
-    vbucket_state_t state;
-    state = get_vbucket_state(e, ntohs(req->message.header.request.vbucket));
-    state = ntohl(state);
-
-    return response(NULL, 0, NULL, 0, &state, sizeof(state),
-                    PROTOCOL_BINARY_RAW_BYTES,
-                    PROTOCOL_BINARY_RESPONSE_SUCCESS, 0, cookie);
-}
-
-static bool rm_vbucket(struct default_engine *e,
-                       const void *cookie,
-                       protocol_binary_request_header *req,
-                       ADD_RESPONSE response) {
-    set_vbucket_state(e, ntohs(req->request.vbucket), vbucket_state_dead);
-    return response(NULL, 0, NULL, 0, NULL, 0, PROTOCOL_BINARY_RAW_BYTES,
-                    PROTOCOL_BINARY_RESPONSE_SUCCESS, 0, cookie);
-}
-
-static bool scrub_cmd(struct default_engine *e,
-                      const void *cookie,
-                      protocol_binary_request_header *request,
-                      ADD_RESPONSE response) {
-
-    protocol_binary_response_status res = PROTOCOL_BINARY_RESPONSE_SUCCESS;
-    if (!item_start_scrub(e)) {
-        res = PROTOCOL_BINARY_RESPONSE_EBUSY;
-    }
-
-    return response(NULL, 0, NULL, 0, NULL, 0, PROTOCOL_BINARY_RAW_BYTES,
-                    res, 0, cookie);
-}
-
-static bool touch(struct default_engine *e, const void *cookie,
-                  protocol_binary_request_header *request,
-                  ADD_RESPONSE response) {
-    if (request->request.extlen != 4 || request->request.keylen == 0) {
-        return response(NULL, 0, NULL, 0, NULL, 0, PROTOCOL_BINARY_RAW_BYTES,
-                        PROTOCOL_BINARY_RESPONSE_EINVAL, 0, cookie);
-    }
-
-    protocol_binary_request_touch *t = (void*)request;
-    void *key = t->bytes + sizeof(t->bytes);
-    uint32_t exptime = ntohl(t->message.body.expiration);
-    uint16_t nkey = ntohs(request->request.keylen);
-
-    hash_item *item = touch_item(e, key, nkey,
-                                 e->server.core->realtime(exptime));
-    if (item == NULL) {
-        if (request->request.opcode == PROTOCOL_BINARY_CMD_GATQ) {
-            return true;
-        } else {
-            return response(NULL, 0, NULL, 0, NULL, 0, PROTOCOL_BINARY_RAW_BYTES,
-                            PROTOCOL_BINARY_RESPONSE_KEY_ENOENT, 0, cookie);
-        }
-    } else {
-        bool ret;
-        if (request->request.opcode == PROTOCOL_BINARY_CMD_TOUCH) {
-            ret = response(NULL, 0, NULL, 0, NULL, 0, PROTOCOL_BINARY_RAW_BYTES,
-                           PROTOCOL_BINARY_RESPONSE_SUCCESS, 0, cookie);
-        } else {
-            ret = response(NULL, 0, &item->flags, sizeof(item->flags),
-                           item_get_data(item), item->nbytes,
-                           PROTOCOL_BINARY_RAW_BYTES,
-                           PROTOCOL_BINARY_RESPONSE_SUCCESS,
-                           item_get_cas(item), cookie);
-        }
-        item_release(e, item);
-        return ret;
-    }
-}
-
-static ENGINE_ERROR_CODE default_unknown_command(ENGINE_HANDLE* handle,
-                                                 const void* cookie,
-                                                 protocol_binary_request_header *request,
-                                                 ADD_RESPONSE response)
-{
-    struct default_engine* e = get_handle(handle);
-    bool sent;
-
-    switch(request->request.opcode) {
-    case PROTOCOL_BINARY_CMD_SCRUB:
-        sent = scrub_cmd(e, cookie, request, response);
-        break;
-    case PROTOCOL_BINARY_CMD_DEL_VBUCKET:
-        sent = rm_vbucket(e, cookie, request, response);
-        break;
-    case PROTOCOL_BINARY_CMD_SET_VBUCKET:
-        sent = set_vbucket(e, cookie, (void*)request, response);
-        break;
-    case PROTOCOL_BINARY_CMD_GET_VBUCKET:
-        sent = get_vbucket(e, cookie, (void*)request, response);
-        break;
-    case PROTOCOL_BINARY_CMD_TOUCH:
-    case PROTOCOL_BINARY_CMD_GAT:
-    case PROTOCOL_BINARY_CMD_GATQ:
-        sent = touch(e, cookie, request, response);
-        break;
-    default:
-        sent = response(NULL, 0, NULL, 0, NULL, 0, PROTOCOL_BINARY_RAW_BYTES,
-                        PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND, 0, cookie);
-        break;
-    }
-
-    if (sent) {
-        return ENGINE_SUCCESS;
-    } else {
-        return ENGINE_FAILED;
-    }
-}
-
-
-uint64_t item_get_cas(const hash_item* item)
-{
-    if (item->iflag & ITEM_WITH_CAS) {
-        return *(uint64_t*)(item + 1);
-    }
-    return 0;
-}
-
-void item_set_cas(ENGINE_HANDLE *handle, const void *cookie,
-                  item* item, uint64_t val)
-{
-    hash_item* it = get_real_item(item);
-    if (it->iflag & ITEM_WITH_CAS) {
-        *(uint64_t*)(it + 1) = val;
-    }
-}
-
-const void* item_get_key(const hash_item* item)
-{
-    char *ret = (void*)(item + 1);
-    if (item->iflag & ITEM_WITH_CAS) {
-        ret += sizeof(uint64_t);
-    }
-
-    return ret;
-}
-
-char* item_get_data(const hash_item* item)
-{
-    return ((char*)item_get_key(item)) + item->nkey;
-}
-
-uint8_t item_get_clsid(const hash_item* item)
-{
-    return 0;
-}
-
-static bool get_item_info(ENGINE_HANDLE *handle, const void *cookie,
-                          const item* item, item_info *item_info)
-{
-    hash_item* it = (hash_item*)item;
-    if (item_info->nvalue < 1) {
-        return false;
-    }
-    item_info->cas = item_get_cas(it);
-    item_info->exptime = it->exptime;
-    item_info->nbytes = it->nbytes;
-    item_info->flags = it->flags;
-    item_info->clsid = it->slabs_clsid;
-    item_info->nkey = it->nkey;
-    item_info->nvalue = 1;
-    item_info->key = item_get_key(it);
-    item_info->value[0].iov_base = item_get_data(it);
-    item_info->value[0].iov_len = it->nbytes;
-    return true;
-}
-
-static ENGINE_ERROR_CODE default_tap_notify(ENGINE_HANDLE* handle,
-                                            const void *cookie,
-                                            void *engine_specific,
-                                            uint16_t nengine,
-                                            uint8_t ttl,
-                                            uint16_t tap_flags,
-                                            tap_event_t tap_event,
-                                            uint32_t tap_seqno,
-                                            const void *key,
-                                            size_t nkey,
-                                            uint32_t flags,
-                                            uint32_t exptime,
-                                            uint64_t cas,
-                                            const void *data,
-                                            size_t ndata,
-                                            uint16_t vbucket) {
-    struct default_engine* engine = get_handle(handle);
-    vbucket_state_t state;
-    item *it;
-    ENGINE_ERROR_CODE ret = ENGINE_SUCCESS;
-
-    switch (tap_event) {
-    case TAP_ACK:
-        /* We don't provide a tap stream, so we should never receive this */
-        abort();
-
-    case TAP_FLUSH:
-        return default_flush(handle, cookie, 0);
-
-    case TAP_DELETION:
-        return default_item_delete(handle, cookie, key, nkey, cas, vbucket);
-
-    case TAP_MUTATION:
-        it = engine->server.cookie->get_engine_specific(cookie);
-        if (it == NULL) {
-            ret = default_item_allocate(handle, cookie, &it, key, nkey, ndata, flags, exptime);
-            switch (ret) {
-            case ENGINE_SUCCESS:
-                break;
-            case ENGINE_ENOMEM:
-                return ENGINE_TMPFAIL;
-            default:
-                return ret;
-            }
-        }
-        memcpy(item_get_data(it), data, ndata);
-        engine->server.cookie->store_engine_specific(cookie, NULL);
-        item_set_cas(handle, cookie, it, cas);
-        ret = default_store(handle, cookie, it, &cas, OPERATION_SET, vbucket);
-        if (ret == ENGINE_EWOULDBLOCK) {
-            engine->server.cookie->store_engine_specific(cookie, it);
-        } else {
-            item_release(engine, it);
-        }
-
-        break;
-
-    case TAP_VBUCKET_SET:
-        if (nengine != sizeof(vbucket_state_t)) {
-            // illegal size of the vbucket set package...
-            return ENGINE_DISCONNECT;
-        }
-
-        memcpy(&state, engine_specific, nengine);
-        state = (vbucket_state_t)ntohl(state);
-
-        if (!is_valid_vbucket_state_t(state)) {
-            return ENGINE_DISCONNECT;
-        }
-
-        set_vbucket_state(engine, vbucket, state);
-        return ENGINE_SUCCESS;
-
-    case TAP_OPAQUE:
-        // not supported, ignore
-    default:
-        engine->server.log->get_logger()->log(EXTENSION_LOG_DEBUG, cookie,
-                    "Ignoring unknown tap event: %x", tap_event);
-    }
-
-    return ret;
-}
-
-static TAP_ITERATOR default_get_tap_iterator(ENGINE_HANDLE* handle,
-                                             const void* cookie,
-                                             const void* client,
-                                             size_t nclient,
-                                             uint32_t flags,
-                                             const void* userdata,
-                                             size_t nuserdata) {
-    struct default_engine* engine = get_handle(handle);
-
-    if ((flags & TAP_CONNECT_FLAG_TAKEOVER_VBUCKETS)) { /* Not supported */
-        return NULL;
-    }
-
-    pthread_mutex_lock(&engine->tap_connections.lock);
-    int ii;
-    for (ii = 0; ii < engine->tap_connections.size; ++ii) {
-        if (engine->tap_connections.clients[ii] == NULL) {
-            engine->tap_connections.clients[ii] = cookie;
-            break;
-        }
-    }
-    pthread_mutex_unlock(&engine->tap_connections.lock);
-    if (ii == engine->tap_connections.size) {
-        // @todo allow more connections :)
-        return NULL;
-    }
-
-    if (!initialize_item_tap_walker(engine, cookie)) {
-        /* Failed to create */
-        pthread_mutex_lock(&engine->tap_connections.lock);
-        engine->tap_connections.clients[ii] = NULL;
-        pthread_mutex_unlock(&engine->tap_connections.lock);
-        return NULL;
-    }
-
-    return item_tap_walker;
- }
-
-static void default_handle_disconnect(const void *cookie,
-                                      ENGINE_EVENT_TYPE type,
-                                      const void *event_data,
-                                      const void *cb_data) {
-    struct default_engine *engine = (struct default_engine*)cb_data;
-    pthread_mutex_lock(&engine->tap_connections.lock);
-    int ii;
-    for (ii = 0; ii < engine->tap_connections.size; ++ii) {
-        if (engine->tap_connections.clients[ii] == cookie) {
-            free(engine->server.cookie->get_engine_specific(cookie));
-            break;
-        }
-    }
-    pthread_mutex_unlock(&engine->tap_connections.lock);
-}

=== removed file 'storage/ndb/memcache/cache-src/default_engine.h'
--- a/storage/ndb/memcache/cache-src/default_engine.h	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/default_engine.h	1970-01-01 00:00:00 +0000
@@ -1,165 +0,0 @@
-/*
-   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
- */
-/*
- * Summary: Specification of the storage engine interface.
- *
- * Copy: See Copyright for the status of this software.
- *
- * Author: Trond Norbye <trond.norbye@stripped>
- */
-#ifndef MEMCACHED_DEFAULT_ENGINE_H
-#define MEMCACHED_DEFAULT_ENGINE_H
-
-#include "config.h"
-
-#include <pthread.h>
-#include <stdbool.h>
-
-#include <memcached/engine.h>
-#include <memcached/util.h>
-#include <memcached/visibility.h>
-
-/* Slab sizing definitions. */
-#define POWER_SMALLEST 1
-#define POWER_LARGEST  200
-#define CHUNK_ALIGN_BYTES 8
-#define DONT_PREALLOC_SLABS
-#define MAX_NUMBER_OF_SLAB_CLASSES (POWER_LARGEST + 1)
-
-/** How long an object can reasonably be assumed to be locked before
-    harvesting it on a low memory condition. */
-#define TAIL_REPAIR_TIME (3 * 3600)
-
-
-/* Forward decl */
-struct default_engine;
-
-#include "trace.h"
-#include "items.h"
-#include "assoc.h"
-#include "slabs.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-   /* Flags */
-#define ITEM_WITH_CAS 1
-
-#define ITEM_LINKED (1<<8)
-
-/* temp */
-#define ITEM_SLABBED (2<<8)
-
-struct config {
-   bool use_cas;
-   size_t verbose;
-   rel_time_t oldest_live;
-   bool evict_to_free;
-   size_t maxbytes;
-   bool preallocate;
-   float factor;
-   size_t chunk_size;
-   size_t item_size_max;
-   bool ignore_vbucket;
-   bool vb0;
-};
-
-MEMCACHED_PUBLIC_API
-ENGINE_ERROR_CODE default_engine_create_instance(uint64_t interface,
-                                  GET_SERVER_API get_server_api,
-                                  ENGINE_HANDLE **handle);
-
-/**
- * Statistic information collected by the default engine
- */
-struct engine_stats {
-   pthread_mutex_t lock;
-   uint64_t evictions;
-   uint64_t reclaimed;
-   uint64_t curr_bytes;
-   uint64_t curr_items;
-   uint64_t total_items;
-};
-
-struct engine_scrubber {
-   pthread_mutex_t lock;
-   bool running;
-   uint64_t visited;
-   uint64_t cleaned;
-   time_t started;
-   time_t stopped;
-};
-
-struct tap_connections {
-    pthread_mutex_t lock;
-    size_t size;
-    const void* *clients;
-};
-
-struct vbucket_info {
-    int state : 2;
-};
-
-#define NUM_VBUCKETS 65536
-
-/**
- * Definition of the private instance data used by the default engine.
- *
- * This is currently "work in progress" so it is not as clean as it should be.
- */
-struct default_engine {
-   ENGINE_HANDLE_V1 engine;
-   SERVER_HANDLE_V1 server;
-   GET_SERVER_API get_server_api;
-
-   /**
-    * Is the engine initalized or not
-    */
-   bool initialized;
-
-   struct assoc assoc;
-   struct slabs slabs;
-   struct items items;
-
-   /**
-    * The cache layer (item_* and assoc_*) is currently protected by
-    * this single mutex
-    */
-   pthread_mutex_t cache_lock;
-
-   struct config config;
-   struct engine_stats stats;
-   struct engine_scrubber scrubber;
-   struct tap_connections tap_connections;
-
-   union {
-       engine_info engine_info;
-       char buffer[sizeof(engine_info) +
-                   (sizeof(feature_info) * LAST_REGISTERED_ENGINE_FEATURE)];
-   } info;
-
-   char vbucket_infos[NUM_VBUCKETS];
-};
-
-char* item_get_data(const hash_item* item);
-const void* item_get_key(const hash_item* item);
-void item_set_cas(ENGINE_HANDLE *handle, const void *cookie,
-                  item* item, uint64_t val);
-uint64_t item_get_cas(const hash_item* item);
-uint8_t item_get_clsid(const hash_item* item);
-#endif

=== removed file 'storage/ndb/memcache/cache-src/items.c'
--- a/storage/ndb/memcache/cache-src/items.c	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/items.c	1970-01-01 00:00:00 +0000
@@ -1,1207 +0,0 @@
-/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-#include "config.h"
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <assert.h>
-#include <inttypes.h>
-
-#include "default_engine.h"
-
-/* Forward Declarations */
-static void item_link_q(struct default_engine *engine, hash_item *it);
-static void item_unlink_q(struct default_engine *engine, hash_item *it);
-static hash_item *do_item_alloc(struct default_engine *engine,
-                                const void *key, const size_t nkey,
-                                const int flags, const rel_time_t exptime,
-                                const int nbytes,
-                                const void *cookie);
-static hash_item *do_item_get(struct default_engine *engine,
-                              const char *key, const size_t nkey);
-static int do_item_link(struct default_engine *engine, hash_item *it);
-static void do_item_unlink(struct default_engine *engine, hash_item *it);
-static void do_item_release(struct default_engine *engine, hash_item *it);
-static void do_item_update(struct default_engine *engine, hash_item *it);
-static int do_item_replace(struct default_engine *engine,
-                            hash_item *it, hash_item *new_it);
-static void item_free(struct default_engine *engine, hash_item *it);
-
-/*
- * We only reposition items in the LRU queue if they haven't been repositioned
- * in this many seconds. That saves us from churning on frequently-accessed
- * items.
- */
-#define ITEM_UPDATE_INTERVAL 60
-/*
- * To avoid scanning through the complete cache in some circumstances we'll
- * just give up and return an error after inspecting a fixed number of objects.
- */
-static const int search_items = 50;
-
-void item_stats_reset(struct default_engine *engine) {
-    pthread_mutex_lock(&engine->cache_lock);
-    memset(engine->items.itemstats, 0, sizeof(engine->items.itemstats));
-    pthread_mutex_unlock(&engine->cache_lock);
-}
-
-
-/* warning: don't use these macros with a function, as it evals its arg twice */
-static inline size_t ITEM_ntotal(struct default_engine *engine,
-                                 const hash_item *item) {
-    size_t ret = sizeof(*item) + item->nkey + item->nbytes;
-    if (engine->config.use_cas) {
-        ret += sizeof(uint64_t);
-    }
-
-    return ret;
-}
-
-/* Get the next CAS id for a new item. */
-static uint64_t get_cas_id(void) {
-    static uint64_t cas_id = 0;
-    return ++cas_id;
-}
-
-/* Enable this for reference-count debugging. */
-#if 0
-# define DEBUG_REFCNT(it,op) \
-                fprintf(stderr, "item %x refcnt(%c) %d %c%c%c\n", \
-                        it, op, it->refcount, \
-                        (it->it_flags & ITEM_LINKED) ? 'L' : ' ', \
-                        (it->it_flags & ITEM_SLABBED) ? 'S' : ' ')
-#else
-# define DEBUG_REFCNT(it,op) while(0)
-#endif
-
-
-/*@null@*/
-hash_item *do_item_alloc(struct default_engine *engine,
-                         const void *key,
-                         const size_t nkey,
-                         const int flags,
-                         const rel_time_t exptime,
-                         const int nbytes,
-                         const void *cookie) {
-    hash_item *it = NULL;
-    size_t ntotal = sizeof(hash_item) + nkey + nbytes;
-    if (engine->config.use_cas) {
-        ntotal += sizeof(uint64_t);
-    }
-
-    unsigned int id = slabs_clsid(engine, ntotal);
-    if (id == 0)
-        return 0;
-
-    /* do a quick check if we have any expired items in the tail.. */
-    int tries = search_items;
-    hash_item *search;
-
-    rel_time_t current_time = engine->server.core->get_current_time();
-
-    for (search = engine->items.tails[id];
-         tries > 0 && search != NULL;
-         tries--, search=search->prev) {
-        if (search->refcount == 0 &&
-            (search->exptime != 0 && search->exptime < current_time)) {
-            it = search;
-            /* I don't want to actually free the object, just steal
-             * the item to avoid to grab the slab mutex twice ;-)
-             */
-            pthread_mutex_lock(&engine->stats.lock);
-            engine->stats.reclaimed++;
-            pthread_mutex_unlock(&engine->stats.lock);
-            engine->items.itemstats[id].reclaimed++;
-            it->refcount = 1;
-            slabs_adjust_mem_requested(engine, it->slabs_clsid, ITEM_ntotal(engine, it), ntotal);
-            do_item_unlink(engine, it);
-            /* Initialize the item block: */
-            it->slabs_clsid = 0;
-            it->refcount = 0;
-            break;
-        }
-    }
-
-    if (it == NULL && (it = slabs_alloc(engine, ntotal, id)) == NULL) {
-        /*
-        ** Could not find an expired item at the tail, and memory allocation
-        ** failed. Try to evict some items!
-        */
-        tries = search_items;
-
-        /* If requested to not push old items out of cache when memory runs out,
-         * we're out of luck at this point...
-         */
-
-        if (engine->config.evict_to_free == 0) {
-            engine->items.itemstats[id].outofmemory++;
-            return NULL;
-        }
-
-        /*
-         * try to get one off the right LRU
-         * don't necessariuly unlink the tail because it may be locked: refcount>0
-         * search up from tail an item with refcount==0 and unlink it; give up after search_items
-         * tries
-         */
-
-        if (engine->items.tails[id] == 0) {
-            engine->items.itemstats[id].outofmemory++;
-            return NULL;
-        }
-
-        for (search = engine->items.tails[id]; tries > 0 && search != NULL; tries--, search=search->prev) {
-            if (search->refcount == 0) {
-                if (search->exptime == 0 || search->exptime > current_time) {
-                    engine->items.itemstats[id].evicted++;
-                    engine->items.itemstats[id].evicted_time = current_time - search->time;
-                    if (search->exptime != 0) {
-                        engine->items.itemstats[id].evicted_nonzero++;
-                    }
-                    pthread_mutex_lock(&engine->stats.lock);
-                    engine->stats.evictions++;
-                    pthread_mutex_unlock(&engine->stats.lock);
-                    engine->server.stat->evicting(cookie,
-                                                  item_get_key(search),
-                                                  search->nkey);
-                } else {
-                    engine->items.itemstats[id].reclaimed++;
-                    pthread_mutex_lock(&engine->stats.lock);
-                    engine->stats.reclaimed++;
-                    pthread_mutex_unlock(&engine->stats.lock);
-                }
-                do_item_unlink(engine, search);
-                break;
-            }
-        }
-        it = slabs_alloc(engine, ntotal, id);
-        if (it == 0) {
-            engine->items.itemstats[id].outofmemory++;
-            /* Last ditch effort. There is a very rare bug which causes
-             * refcount leaks. We've fixed most of them, but it still happens,
-             * and it may happen in the future.
-             * We can reasonably assume no item can stay locked for more than
-             * three hours, so if we find one in the tail which is that old,
-             * free it anyway.
-             */
-            tries = search_items;
-            for (search = engine->items.tails[id]; tries > 0 && search != NULL; tries--, search=search->prev) {
-                if (search->refcount != 0 && search->time + TAIL_REPAIR_TIME < current_time) {
-                    engine->items.itemstats[id].tailrepairs++;
-                    search->refcount = 0;
-                    do_item_unlink(engine, search);
-                    break;
-                }
-            }
-            it = slabs_alloc(engine, ntotal, id);
-            if (it == 0) {
-                return NULL;
-            }
-        }
-    }
-
-    assert(it->slabs_clsid == 0);
-
-    it->slabs_clsid = id;
-
-    assert(it != engine->items.heads[it->slabs_clsid]);
-
-    it->next = it->prev = it->h_next = 0;
-    it->refcount = 1;     /* the caller will have a reference */
-    DEBUG_REFCNT(it, '*');
-    it->iflag = engine->config.use_cas ? ITEM_WITH_CAS : 0;
-    it->nkey = nkey;
-    it->nbytes = nbytes;
-    it->flags = flags;
-    memcpy((void*)item_get_key(it), key, nkey);
-    it->exptime = exptime;
-    return it;
-}
-
-static void item_free(struct default_engine *engine, hash_item *it) {
-    size_t ntotal = ITEM_ntotal(engine, it);
-    unsigned int clsid;
-    assert((it->iflag & ITEM_LINKED) == 0);
-    assert(it != engine->items.heads[it->slabs_clsid]);
-    assert(it != engine->items.tails[it->slabs_clsid]);
-    assert(it->refcount == 0);
-
-    /* so slab size changer can tell later if item is already free or not */
-    clsid = it->slabs_clsid;
-    it->slabs_clsid = 0;
-    it->iflag |= ITEM_SLABBED;
-    DEBUG_REFCNT(it, 'F');
-    slabs_free(engine, it, ntotal, clsid);
-}
-
-static void item_link_q(struct default_engine *engine, hash_item *it) { /* item is the new head */
-    hash_item **head, **tail;
-    assert(it->slabs_clsid < POWER_LARGEST);
-    assert((it->iflag & ITEM_SLABBED) == 0);
-
-    head = &engine->items.heads[it->slabs_clsid];
-    tail = &engine->items.tails[it->slabs_clsid];
-    assert(it != *head);
-    assert((*head && *tail) || (*head == 0 && *tail == 0));
-    it->prev = 0;
-    it->next = *head;
-    if (it->next) it->next->prev = it;
-    *head = it;
-    if (*tail == 0) *tail = it;
-    engine->items.sizes[it->slabs_clsid]++;
-    return;
-}
-
-static void item_unlink_q(struct default_engine *engine, hash_item *it) {
-    hash_item **head, **tail;
-    assert(it->slabs_clsid < POWER_LARGEST);
-    head = &engine->items.heads[it->slabs_clsid];
-    tail = &engine->items.tails[it->slabs_clsid];
-
-    if (*head == it) {
-        assert(it->prev == 0);
-        *head = it->next;
-    }
-    if (*tail == it) {
-        assert(it->next == 0);
-        *tail = it->prev;
-    }
-    assert(it->next != it);
-    assert(it->prev != it);
-
-    if (it->next) it->next->prev = it->prev;
-    if (it->prev) it->prev->next = it->next;
-    engine->items.sizes[it->slabs_clsid]--;
-    return;
-}
-
-int do_item_link(struct default_engine *engine, hash_item *it) {
-    MEMCACHED_ITEM_LINK(item_get_key(it), it->nkey, it->nbytes);
-    assert((it->iflag & (ITEM_LINKED|ITEM_SLABBED)) == 0);
-    assert(it->nbytes < (1024 * 1024));  /* 1MB max size */
-    it->iflag |= ITEM_LINKED;
-    it->time = engine->server.core->get_current_time();
-    assoc_insert(engine, engine->server.core->hash(item_get_key(it),
-                                                        it->nkey, 0),
-                 it);
-
-    pthread_mutex_lock(&engine->stats.lock);
-    engine->stats.curr_bytes += ITEM_ntotal(engine, it);
-    engine->stats.curr_items += 1;
-    engine->stats.total_items += 1;
-    pthread_mutex_unlock(&engine->stats.lock);
-
-    /* Allocate a new CAS ID on link. */
-    item_set_cas(NULL, NULL, it, get_cas_id());
-
-    item_link_q(engine, it);
-
-    return 1;
-}
-
-void do_item_unlink(struct default_engine *engine, hash_item *it) {
-    MEMCACHED_ITEM_UNLINK(item_get_key(it), it->nkey, it->nbytes);
-    if ((it->iflag & ITEM_LINKED) != 0) {
-        it->iflag &= ~ITEM_LINKED;
-        pthread_mutex_lock(&engine->stats.lock);
-        engine->stats.curr_bytes -= ITEM_ntotal(engine, it);
-        engine->stats.curr_items -= 1;
-        pthread_mutex_unlock(&engine->stats.lock);
-        assoc_delete(engine, engine->server.core->hash(item_get_key(it),
-                                                            it->nkey, 0),
-                     item_get_key(it), it->nkey);
-        item_unlink_q(engine, it);
-        if (it->refcount == 0) {
-            item_free(engine, it);
-        }
-    }
-}
-
-void do_item_release(struct default_engine *engine, hash_item *it) {
-    MEMCACHED_ITEM_REMOVE(item_get_key(it), it->nkey, it->nbytes);
-    if (it->refcount != 0) {
-        it->refcount--;
-        DEBUG_REFCNT(it, '-');
-    }
-    if (it->refcount == 0 && (it->iflag & ITEM_LINKED) == 0) {
-        item_free(engine, it);
-    }
-}
-
-void do_item_update(struct default_engine *engine, hash_item *it) {
-    rel_time_t current_time = engine->server.core->get_current_time();
-    MEMCACHED_ITEM_UPDATE(item_get_key(it), it->nkey, it->nbytes);
-    if (it->time < current_time - ITEM_UPDATE_INTERVAL) {
-        assert((it->iflag & ITEM_SLABBED) == 0);
-
-        if ((it->iflag & ITEM_LINKED) != 0) {
-            item_unlink_q(engine, it);
-            it->time = current_time;
-            item_link_q(engine, it);
-        }
-    }
-}
-
-int do_item_replace(struct default_engine *engine,
-                    hash_item *it, hash_item *new_it) {
-    MEMCACHED_ITEM_REPLACE(item_get_key(it), it->nkey, it->nbytes,
-                           item_get_key(new_it), new_it->nkey, new_it->nbytes);
-    assert((it->iflag & ITEM_SLABBED) == 0);
-
-    do_item_unlink(engine, it);
-    return do_item_link(engine, new_it);
-}
-
-/*@null@*/
-static char *do_item_cachedump(const unsigned int slabs_clsid,
-                               const unsigned int limit,
-                               unsigned int *bytes) {
-#ifdef FUTURE
-    unsigned int memlimit = 2 * 1024 * 1024;   /* 2MB max response size */
-    char *buffer;
-    unsigned int bufcurr;
-    hash_item *it;
-    unsigned int len;
-    unsigned int shown = 0;
-    char key_temp[KEY_MAX_LENGTH + 1];
-    char temp[512];
-
-    it = engine->items.heads[slabs_clsid];
-
-    buffer = malloc((size_t)memlimit);
-    if (buffer == 0) return NULL;
-    bufcurr = 0;
-
-
-    while (it != NULL && (limit == 0 || shown < limit)) {
-        assert(it->nkey <= KEY_MAX_LENGTH);
-        /* Copy the key since it may not be null-terminated in the struct */
-        strncpy(key_temp, item_get_key(it), it->nkey);
-        key_temp[it->nkey] = 0x00; /* terminate */
-        len = snprintf(temp, sizeof(temp), "ITEM %s [%d b; %lu s]\r\n",
-                       key_temp, it->nbytes,
-                       (unsigned long)it->exptime + process_started);
-        if (bufcurr + len + 6 > memlimit)  /* 6 is END\r\n\0 */
-            break;
-        memcpy(buffer + bufcurr, temp, len);
-        bufcurr += len;
-        shown++;
-        it = it->next;
-    }
-
-
-    memcpy(buffer + bufcurr, "END\r\n", 6);
-    bufcurr += 5;
-
-    *bytes = bufcurr;
-    return buffer;
-#endif
-    (void)slabs_clsid;
-    (void)limit;
-    (void)bytes;
-    return NULL;
-}
-
-static void do_item_stats(struct default_engine *engine,
-                          ADD_STAT add_stats, const void *c) {
-    int i;
-    rel_time_t current_time = engine->server.core->get_current_time();
-    for (i = 0; i < POWER_LARGEST; i++) {
-        if (engine->items.tails[i] != NULL) {
-            int search = search_items;
-            while (search > 0 &&
-                   engine->items.tails[i] != NULL &&
-                   ((engine->config.oldest_live != 0 && /* Item flushd */
-                     engine->config.oldest_live <= current_time &&
-                     engine->items.tails[i]->time <= engine->config.oldest_live) ||
-                    (engine->items.tails[i]->exptime != 0 && /* and not expired */
-                     engine->items.tails[i]->exptime < current_time))) {
-                --search;
-                if (engine->items.tails[i]->refcount == 0) {
-                    do_item_unlink(engine, engine->items.tails[i]);
-                } else {
-                    break;
-                }
-            }
-            if (engine->items.tails[i] == NULL) {
-                /* We removed all of the items in this slab class */
-                continue;
-            }
-
-            const char *prefix = "items";
-            add_statistics(c, add_stats, prefix, i, "number", "%u",
-                           engine->items.sizes[i]);
-            add_statistics(c, add_stats, prefix, i, "age", "%u",
-                           engine->items.tails[i]->time);
-            add_statistics(c, add_stats, prefix, i, "evicted",
-                           "%u", engine->items.itemstats[i].evicted);
-            add_statistics(c, add_stats, prefix, i, "evicted_nonzero",
-                           "%u", engine->items.itemstats[i].evicted_nonzero);
-            add_statistics(c, add_stats, prefix, i, "evicted_time",
-                           "%u", engine->items.itemstats[i].evicted_time);
-            add_statistics(c, add_stats, prefix, i, "outofmemory",
-                           "%u", engine->items.itemstats[i].outofmemory);
-            add_statistics(c, add_stats, prefix, i, "tailrepairs",
-                           "%u", engine->items.itemstats[i].tailrepairs);;
-            add_statistics(c, add_stats, prefix, i, "reclaimed",
-                           "%u", engine->items.itemstats[i].reclaimed);;
-        }
-    }
-}
-
-/** dumps out a list of objects of each size, with granularity of 32 bytes */
-/*@null@*/
-static void do_item_stats_sizes(struct default_engine *engine,
-                                ADD_STAT add_stats, const void *c) {
-
-    /* max 1MB object, divided into 32 bytes size buckets */
-    const int num_buckets = 32768;
-    unsigned int *histogram = calloc(num_buckets, sizeof(int));
-
-    if (histogram != NULL) {
-        int i;
-
-        /* build the histogram */
-        for (i = 0; i < POWER_LARGEST; i++) {
-            hash_item *iter = engine->items.heads[i];
-            while (iter) {
-                int ntotal = ITEM_ntotal(engine, iter);
-                int bucket = ntotal / 32;
-                if ((ntotal % 32) != 0) bucket++;
-                if (bucket < num_buckets) histogram[bucket]++;
-                iter = iter->next;
-            }
-        }
-
-        /* write the buffer */
-        for (i = 0; i < num_buckets; i++) {
-            if (histogram[i] != 0) {
-                char key[8], val[32];
-                int klen, vlen;
-                klen = snprintf(key, sizeof(key), "%d", i * 32);
-                vlen = snprintf(val, sizeof(val), "%u", histogram[i]);
-                assert(klen < sizeof(key));
-                assert(vlen < sizeof(val));
-                add_stats(key, klen, val, vlen, c);
-            }
-        }
-        free(histogram);
-    }
-}
-
-/** wrapper around assoc_find which does the lazy expiration logic */
-hash_item *do_item_get(struct default_engine *engine,
-                       const char *key, const size_t nkey) {
-    rel_time_t current_time = engine->server.core->get_current_time();
-    hash_item *it = assoc_find(engine, engine->server.core->hash(key,
-                                                                      nkey, 0),
-                               key, nkey);
-    int was_found = 0;
-
-    if (engine->config.verbose > 2) {
-        EXTENSION_LOGGER_DESCRIPTOR *logger;
-        logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-        if (it == NULL) {
-            logger->log(EXTENSION_LOG_DEBUG, NULL,
-                        "> NOT FOUND %s", key);
-        } else {
-            logger->log(EXTENSION_LOG_DEBUG, NULL,
-                        "> FOUND KEY %s",
-                        (const char*)item_get_key(it));
-            was_found++;
-        }
-    }
-
-    if (it != NULL && engine->config.oldest_live != 0 &&
-        engine->config.oldest_live <= current_time &&
-        it->time <= engine->config.oldest_live) {
-        do_item_unlink(engine, it);           /* MTSAFE - cache_lock held */
-        it = NULL;
-    }
-
-    if (it == NULL && was_found) {
-        EXTENSION_LOGGER_DESCRIPTOR *logger;
-        logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-        logger->log(EXTENSION_LOG_DEBUG, NULL, " -nuked by flush");
-        was_found--;
-    }
-
-    if (it != NULL && it->exptime != 0 && it->exptime <= current_time) {
-        do_item_unlink(engine, it);           /* MTSAFE - cache_lock held */
-        it = NULL;
-    }
-
-    if (it == NULL && was_found) {
-        EXTENSION_LOGGER_DESCRIPTOR *logger;
-        logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-        logger->log(EXTENSION_LOG_DEBUG, NULL, " -nuked by expire");
-        was_found--;
-    }
-
-    if (it != NULL) {
-        it->refcount++;
-        DEBUG_REFCNT(it, '+');
-        do_item_update(engine, it);
-    }
-
-    return it;
-}
-
-/*
- * Stores an item in the cache according to the semantics of one of the set
- * commands. In threaded mode, this is protected by the cache lock.
- *
- * Returns the state of storage.
- */
-static ENGINE_ERROR_CODE do_store_item(struct default_engine *engine,
-                                       hash_item *it, uint64_t *cas,
-                                       ENGINE_STORE_OPERATION operation,
-                                       const void *cookie) {
-    const char *key = item_get_key(it);
-    hash_item *old_it = do_item_get(engine, key, it->nkey);
-    ENGINE_ERROR_CODE stored = ENGINE_NOT_STORED;
-
-    hash_item *new_it = NULL;
-
-    if (old_it != NULL && operation == OPERATION_ADD) {
-        /* add only adds a nonexistent item, but promote to head of LRU */
-        do_item_update(engine, old_it);
-    } else if (!old_it && (operation == OPERATION_REPLACE
-        || operation == OPERATION_APPEND || operation == OPERATION_PREPEND))
-    {
-        /* replace only replaces an existing value; don't store */
-    } else if (operation == OPERATION_CAS) {
-        /* validate cas operation */
-        if(old_it == NULL) {
-            // LRU expired
-            stored = ENGINE_KEY_ENOENT;
-        }
-        else if (item_get_cas(it) == item_get_cas(old_it)) {
-            // cas validates
-            // it and old_it may belong to different classes.
-            // I'm updating the stats for the one that's getting pushed out
-            do_item_replace(engine, old_it, it);
-            stored = ENGINE_SUCCESS;
-        } else {
-            if (engine->config.verbose > 1) {
-                EXTENSION_LOGGER_DESCRIPTOR *logger;
-                logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-                logger->log(EXTENSION_LOG_INFO, NULL,
-                        "CAS:  failure: expected %"PRIu64", got %"PRIu64"\n",
-                        item_get_cas(old_it),
-                        item_get_cas(it));
-            }
-            stored = ENGINE_KEY_EEXISTS;
-        }
-    } else {
-        /*
-         * Append - combine new and old record into single one. Here it's
-         * atomic and thread-safe.
-         */
-        if (operation == OPERATION_APPEND || operation == OPERATION_PREPEND) {
-            /*
-             * Validate CAS
-             */
-            if (item_get_cas(it) != 0) {
-                // CAS much be equal
-                if (item_get_cas(it) != item_get_cas(old_it)) {
-                    stored = ENGINE_KEY_EEXISTS;
-                }
-            }
-
-            if (stored == ENGINE_NOT_STORED) {
-                /* we have it and old_it here - alloc memory to hold both */
-                new_it = do_item_alloc(engine, key, it->nkey,
-                                       old_it->flags,
-                                       old_it->exptime,
-                                       it->nbytes + old_it->nbytes,
-                                       cookie);
-
-                if (new_it == NULL) {
-                    /* SERVER_ERROR out of memory */
-                    if (old_it != NULL) {
-                        do_item_release(engine, old_it);
-                    }
-
-                    return ENGINE_NOT_STORED;
-                }
-
-                /* copy data from it and old_it to new_it */
-
-                if (operation == OPERATION_APPEND) {
-                    memcpy(item_get_data(new_it), item_get_data(old_it), old_it->nbytes);
-                    memcpy(item_get_data(new_it) + old_it->nbytes, item_get_data(it), it->nbytes);
-                } else {
-                    /* OPERATION_PREPEND */
-                    memcpy(item_get_data(new_it), item_get_data(it), it->nbytes);
-                    memcpy(item_get_data(new_it) + it->nbytes, item_get_data(old_it), old_it->nbytes);
-                }
-
-                it = new_it;
-            }
-        }
-
-        if (stored == ENGINE_NOT_STORED) {
-            if (old_it != NULL) {
-                do_item_replace(engine, old_it, it);
-            } else {
-                do_item_link(engine, it);
-            }
-
-            *cas = item_get_cas(it);
-            stored = ENGINE_SUCCESS;
-        }
-    }
-
-    if (old_it != NULL) {
-        do_item_release(engine, old_it);         /* release our reference */
-    }
-
-    if (new_it != NULL) {
-        do_item_release(engine, new_it);
-    }
-
-    if (stored == ENGINE_SUCCESS) {
-        *cas = item_get_cas(it);
-    }
-
-    return stored;
-}
-
-
-/*
- * adds a delta value to a numeric item.
- *
- * c     connection requesting the operation
- * it    item to adjust
- * incr  true to increment value, false to decrement
- * delta amount to adjust value by
- * buf   buffer for response string
- *
- * returns a response string to send back to the client.
- */
-static ENGINE_ERROR_CODE do_add_delta(struct default_engine *engine,
-                                      hash_item *it, const bool incr,
-                                      const int64_t delta, uint64_t *rcas,
-                                      uint64_t *result, const void *cookie) {
-    const char *ptr;
-    uint64_t value;
-    char buf[80];
-    int res;
-
-    if (it->nbytes >= (sizeof(buf) - 1)) {
-        return ENGINE_EINVAL;
-    }
-
-    ptr = item_get_data(it);
-    memcpy(buf, ptr, it->nbytes);
-    buf[it->nbytes] = '\0';
-
-    if (!safe_strtoull(buf, &value)) {
-        return ENGINE_EINVAL;
-    }
-
-    if (incr) {
-        value += delta;
-    } else {
-        if(delta > value) {
-            value = 0;
-        } else {
-            value -= delta;
-        }
-    }
-
-    *result = value;
-    if ((res = snprintf(buf, sizeof(buf), "%" PRIu64, value)) == -1) {
-        return ENGINE_EINVAL;
-    }
-
-    if (it->refcount == 1 && res <= it->nbytes) {
-        // we can do inline replacement
-        memcpy(item_get_data(it), buf, res);
-        memset(item_get_data(it) + res, ' ', it->nbytes - res);
-        item_set_cas(NULL, NULL, it, get_cas_id());
-        *rcas = item_get_cas(it);
-    } else {
-        hash_item *new_it = do_item_alloc(engine, item_get_key(it),
-                                          it->nkey, it->flags,
-                                          it->exptime, res,
-                                          cookie);
-        if (new_it == NULL) {
-            do_item_unlink(engine, it);
-            return ENGINE_ENOMEM;
-        }
-        memcpy(item_get_data(new_it), buf, res);
-        do_item_replace(engine, it, new_it);
-        *rcas = item_get_cas(new_it);
-        do_item_release(engine, new_it);       /* release our reference */
-    }
-
-    return ENGINE_SUCCESS;
-}
-
-/********************************* ITEM ACCESS *******************************/
-
-/*
- * Allocates a new item.
- */
-hash_item *item_alloc(struct default_engine *engine,
-                      const void *key, size_t nkey, int flags,
-                      rel_time_t exptime, int nbytes, const void *cookie) {
-    hash_item *it;
-    pthread_mutex_lock(&engine->cache_lock);
-    it = do_item_alloc(engine, key, nkey, flags, exptime, nbytes, cookie);
-    pthread_mutex_unlock(&engine->cache_lock);
-    return it;
-}
-
-/*
- * Returns an item if it hasn't been marked as expired,
- * lazy-expiring as needed.
- */
-hash_item *item_get(struct default_engine *engine,
-                    const void *key, const size_t nkey) {
-    hash_item *it;
-    pthread_mutex_lock(&engine->cache_lock);
-    it = do_item_get(engine, key, nkey);
-    pthread_mutex_unlock(&engine->cache_lock);
-    return it;
-}
-
-/*
- * Decrements the reference count on an item and adds it to the freelist if
- * needed.
- */
-void item_release(struct default_engine *engine, hash_item *item) {
-    pthread_mutex_lock(&engine->cache_lock);
-    do_item_release(engine, item);
-    pthread_mutex_unlock(&engine->cache_lock);
-}
-
-/*
- * Unlinks an item from the LRU and hashtable.
- */
-void item_unlink(struct default_engine *engine, hash_item *item) {
-    pthread_mutex_lock(&engine->cache_lock);
-    do_item_unlink(engine, item);
-    pthread_mutex_unlock(&engine->cache_lock);
-}
-
-static ENGINE_ERROR_CODE do_arithmetic(struct default_engine *engine,
-                                       const void* cookie,
-                                       const void* key,
-                                       const int nkey,
-                                       const bool increment,
-                                       const bool create,
-                                       const uint64_t delta,
-                                       const uint64_t initial,
-                                       const rel_time_t exptime,
-                                       uint64_t *cas,
-                                       uint64_t *result)
-{
-   hash_item *item = do_item_get(engine, key, nkey);
-   ENGINE_ERROR_CODE ret;
-
-   if (item == NULL) {
-      if (!create) {
-         return ENGINE_KEY_ENOENT;
-      } else {
-         char buffer[128];
-         int len = snprintf(buffer, sizeof(buffer), "%"PRIu64,
-                            (uint64_t)initial);
-
-         item = do_item_alloc(engine, key, nkey, 0, exptime, len, cookie);
-         if (item == NULL) {
-            return ENGINE_ENOMEM;
-         }
-         memcpy((void*)item_get_data(item), buffer, len);
-         if ((ret = do_store_item(engine, item, cas,
-                                  OPERATION_ADD, cookie)) == ENGINE_SUCCESS) {
-             *result = initial;
-             *cas = item_get_cas(item);
-         }
-         do_item_release(engine, item);
-      }
-   } else {
-      ret = do_add_delta(engine, item, increment, delta, cas, result, cookie);
-      do_item_release(engine, item);
-   }
-
-   return ret;
-}
-
-ENGINE_ERROR_CODE arithmetic(struct default_engine *engine,
-                             const void* cookie,
-                             const void* key,
-                             const int nkey,
-                             const bool increment,
-                             const bool create,
-                             const uint64_t delta,
-                             const uint64_t initial,
-                             const rel_time_t exptime,
-                             uint64_t *cas,
-                             uint64_t *result)
-{
-    ENGINE_ERROR_CODE ret;
-
-    pthread_mutex_lock(&engine->cache_lock);
-    ret = do_arithmetic(engine, cookie, key, nkey, increment,
-                        create, delta, initial, exptime, cas,
-                        result);
-    pthread_mutex_unlock(&engine->cache_lock);
-    return ret;
-}
-
-/*
- * Stores an item in the cache (high level, obeys set/add/replace semantics)
- */
-ENGINE_ERROR_CODE store_item(struct default_engine *engine,
-                             hash_item *item, uint64_t *cas,
-                             ENGINE_STORE_OPERATION operation,
-                             const void *cookie) {
-    ENGINE_ERROR_CODE ret;
-
-    pthread_mutex_lock(&engine->cache_lock);
-    ret = do_store_item(engine, item, cas, operation, cookie);
-    pthread_mutex_unlock(&engine->cache_lock);
-    return ret;
-}
-
-static hash_item *do_touch_item(struct default_engine *engine,
-                                     const void *key,
-                                     uint16_t nkey,
-                                     uint32_t exptime)
-{
-   hash_item *item = do_item_get(engine, key, nkey);
-   if (item != NULL) {
-       item->exptime = exptime;
-   }
-   return item;
-}
-
-hash_item *touch_item(struct default_engine *engine,
-                           const void *key,
-                           uint16_t nkey,
-                           uint32_t exptime)
-{
-    hash_item *ret;
-
-    pthread_mutex_lock(&engine->cache_lock);
-    ret = do_touch_item(engine, key, nkey, exptime);
-    pthread_mutex_unlock(&engine->cache_lock);
-    return ret;
-}
-
-/*
- * Flushes expired items after a flush_all call
- */
-void item_flush_expired(struct default_engine *engine, time_t when) {
-    int i;
-    hash_item *iter, *next;
-
-    pthread_mutex_lock(&engine->cache_lock);
-
-    if (when == 0) {
-        engine->config.oldest_live = engine->server.core->get_current_time() - 1;
-    } else {
-        engine->config.oldest_live = engine->server.core->realtime(when) - 1;
-    }
-
-    if (engine->config.oldest_live != 0) {
-        for (i = 0; i < POWER_LARGEST; i++) {
-            /*
-             * The LRU is sorted in decreasing time order, and an item's
-             * timestamp is never newer than its last access time, so we
-             * only need to walk back until we hit an item older than the
-             * oldest_live time.
-             * The oldest_live checking will auto-expire the remaining items.
-             */
-            for (iter = engine->items.heads[i]; iter != NULL; iter = next) {
-                if (iter->time >= engine->config.oldest_live) {
-                    next = iter->next;
-                    if ((iter->iflag & ITEM_SLABBED) == 0) {
-                        do_item_unlink(engine, iter);
-                    }
-                } else {
-                    /* We've hit the first old item. Continue to the next queue. */
-                    break;
-                }
-            }
-        }
-    }
-    pthread_mutex_unlock(&engine->cache_lock);
-}
-
-/*
- * Dumps part of the cache
- */
-char *item_cachedump(struct default_engine *engine,
-                     unsigned int slabs_clsid,
-                     unsigned int limit,
-                     unsigned int *bytes) {
-    char *ret;
-
-    pthread_mutex_lock(&engine->cache_lock);
-    ret = do_item_cachedump(slabs_clsid, limit, bytes);
-    pthread_mutex_unlock(&engine->cache_lock);
-    return ret;
-}
-
-void item_stats(struct default_engine *engine,
-                   ADD_STAT add_stat, const void *cookie)
-{
-    pthread_mutex_lock(&engine->cache_lock);
-    do_item_stats(engine, add_stat, cookie);
-    pthread_mutex_unlock(&engine->cache_lock);
-}
-
-
-void item_stats_sizes(struct default_engine *engine,
-                      ADD_STAT add_stat, const void *cookie)
-{
-    pthread_mutex_lock(&engine->cache_lock);
-    do_item_stats_sizes(engine, add_stat, cookie);
-    pthread_mutex_unlock(&engine->cache_lock);
-}
-
-static void do_item_link_cursor(struct default_engine *engine,
-                                hash_item *cursor, int ii)
-{
-    cursor->slabs_clsid = (uint8_t)ii;
-    cursor->next = NULL;
-    cursor->prev = engine->items.tails[ii];
-    engine->items.tails[ii]->next = cursor;
-    engine->items.tails[ii] = cursor;
-    engine->items.sizes[ii]++;
-}
-
-typedef ENGINE_ERROR_CODE (*ITERFUNC)(struct default_engine *engine,
-                                      hash_item *item, void *cookie);
-
-static bool do_item_walk_cursor(struct default_engine *engine,
-                                hash_item *cursor,
-                                int steplength,
-                                ITERFUNC itemfunc,
-                                void* itemdata,
-                                ENGINE_ERROR_CODE *error)
-{
-    int ii = 0;
-    *error = ENGINE_SUCCESS;
-
-    while (cursor->prev != NULL && ii < steplength) {
-        ++ii;
-        /* Move cursor */
-        hash_item *ptr = cursor->prev;
-        item_unlink_q(engine, cursor);
-
-        bool done = false;
-        if (ptr == engine->items.heads[cursor->slabs_clsid]) {
-            done = true;
-            cursor->prev = NULL;
-        } else {
-            cursor->next = ptr;
-            cursor->prev = ptr->prev;
-            cursor->prev->next = cursor;
-            ptr->prev = cursor;
-        }
-
-        /* Ignore cursors */
-        if (ptr->nkey == 0 && ptr->nbytes == 0) {
-            --ii;
-        } else {
-            *error = itemfunc(engine, ptr, itemdata);
-            if (*error != ENGINE_SUCCESS) {
-                return false;
-            }
-        }
-
-        if (done) {
-            return false;
-        }
-    }
-
-    return (cursor->prev != NULL);
-}
-
-static ENGINE_ERROR_CODE item_scrub(struct default_engine *engine,
-                                    hash_item *item,
-                                    void *cookie) {
-    (void)cookie;
-    engine->scrubber.visited++;
-    rel_time_t current_time = engine->server.core->get_current_time();
-    if (item->refcount == 0 &&
-        (item->exptime != 0 && item->exptime < current_time)) {
-        do_item_unlink(engine, item);
-        engine->scrubber.cleaned++;
-    }
-    return ENGINE_SUCCESS;
-}
-
-static void item_scrub_class(struct default_engine *engine,
-                             hash_item *cursor) {
-
-    ENGINE_ERROR_CODE ret;
-    bool more;
-    do {
-        pthread_mutex_lock(&engine->cache_lock);
-        more = do_item_walk_cursor(engine, cursor, 200, item_scrub, NULL, &ret);
-        pthread_mutex_unlock(&engine->cache_lock);
-        if (ret != ENGINE_SUCCESS) {
-            break;
-        }
-    } while (more);
-}
-
-static void *item_scubber_main(void *arg)
-{
-    struct default_engine *engine = arg;
-    hash_item cursor = { .refcount = 1 };
-
-    for (int ii = 0; ii < POWER_LARGEST; ++ii) {
-        pthread_mutex_lock(&engine->cache_lock);
-        bool skip = false;
-        if (engine->items.heads[ii] == NULL) {
-            skip = true;
-        } else {
-            // add the item at the tail
-            do_item_link_cursor(engine, &cursor, ii);
-        }
-        pthread_mutex_unlock(&engine->cache_lock);
-
-        if (!skip) {
-            item_scrub_class(engine, &cursor);
-        }
-    }
-
-    pthread_mutex_lock(&engine->scrubber.lock);
-    engine->scrubber.stopped = time(NULL);
-    engine->scrubber.running = false;
-    pthread_mutex_unlock(&engine->scrubber.lock);
-
-    return NULL;
-}
-
-bool item_start_scrub(struct default_engine *engine)
-{
-    bool ret = false;
-    pthread_mutex_lock(&engine->scrubber.lock);
-    if (!engine->scrubber.running) {
-        engine->scrubber.started = time(NULL);
-        engine->scrubber.stopped = 0;
-        engine->scrubber.visited = 0;
-        engine->scrubber.cleaned = 0;
-        engine->scrubber.running = true;
-
-        pthread_t t;
-        pthread_attr_t attr;
-
-        if (pthread_attr_init(&attr) != 0 ||
-            pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0 ||
-            pthread_create(&t, &attr, item_scubber_main, engine) != 0)
-        {
-            engine->scrubber.running = false;
-        } else {
-            ret = true;
-        }
-    }
-    pthread_mutex_unlock(&engine->scrubber.lock);
-
-    return ret;
-}
-
-struct tap_client {
-    hash_item cursor;
-    hash_item *it;
-};
-
-static ENGINE_ERROR_CODE item_tap_iterfunc(struct default_engine *engine,
-                                    hash_item *item,
-                                    void *cookie) {
-    struct tap_client *client = cookie;
-    client->it = item;
-    ++client->it->refcount;
-    return ENGINE_SUCCESS;
-}
-
-static tap_event_t do_item_tap_walker(struct default_engine *engine,
-                                         const void *cookie, item **itm,
-                                         void **es, uint16_t *nes, uint8_t *ttl,
-                                         uint16_t *flags, uint32_t *seqno,
-                                         uint16_t *vbucket)
-{
-    struct tap_client *client = engine->server.cookie->get_engine_specific(cookie);
-    if (client == NULL) {
-        return TAP_DISCONNECT;
-    }
-
-    *es = NULL;
-    *nes = 0;
-    *ttl = (uint8_t)-1;
-    *seqno = 0;
-    *flags = 0;
-    *vbucket = 0;
-    client->it = NULL;
-
-    ENGINE_ERROR_CODE r;
-    do {
-        if (!do_item_walk_cursor(engine, &client->cursor, 1, item_tap_iterfunc, client, &r)) {
-            // find next slab class to look at..
-            bool linked = false;
-            for (int ii = client->cursor.slabs_clsid + 1; ii < POWER_LARGEST && !linked;  ++ii) {
-                if (engine->items.heads[ii] != NULL) {
-                    // add the item at the tail
-                    do_item_link_cursor(engine, &client->cursor, ii);
-                    linked = true;
-                }
-            }
-            if (!linked) {
-                break;
-            }
-        }
-    } while (client->it == NULL);
-    *itm = client->it;
-
-    return (*itm == NULL) ? TAP_DISCONNECT : TAP_MUTATION;
-}
-
-tap_event_t item_tap_walker(ENGINE_HANDLE* handle,
-                            const void *cookie, item **itm,
-                            void **es, uint16_t *nes, uint8_t *ttl,
-                            uint16_t *flags, uint32_t *seqno,
-                            uint16_t *vbucket)
-{
-    tap_event_t ret;
-    struct default_engine *engine = (struct default_engine*)handle;
-    pthread_mutex_lock(&engine->cache_lock);
-    ret = do_item_tap_walker(engine, cookie, itm, es, nes, ttl, flags, seqno, vbucket);
-    pthread_mutex_unlock(&engine->cache_lock);
-
-    return ret;
-}
-
-bool initialize_item_tap_walker(struct default_engine *engine,
-                                const void* cookie)
-{
-    struct tap_client *client = calloc(1, sizeof(*client));
-    if (client == NULL) {
-        return false;
-    }
-    client->cursor.refcount = 1;
-
-    /* Link the cursor! */
-    bool linked = false;
-    for (int ii = 0; ii < POWER_LARGEST && !linked; ++ii) {
-        pthread_mutex_lock(&engine->cache_lock);
-        if (engine->items.heads[ii] != NULL) {
-            // add the item at the tail
-            do_item_link_cursor(engine, &client->cursor, ii);
-            linked = true;
-        }
-        pthread_mutex_unlock(&engine->cache_lock);
-    }
-
-    engine->server.cookie->store_engine_specific(cookie, client);
-    return true;
-}

=== removed file 'storage/ndb/memcache/cache-src/items.h'
--- a/storage/ndb/memcache/cache-src/items.h	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/items.h	1970-01-01 00:00:00 +0000
@@ -1,192 +0,0 @@
-#ifndef ITEMS_H
-#define ITEMS_H
-
-/*
- * You should not try to aquire any of the item locks before calling these
- * functions.
- */
-typedef struct _hash_item {
-    struct _hash_item *next;
-    struct _hash_item *prev;
-    struct _hash_item *h_next; /* hash chain next */
-    rel_time_t time;  /* least recent access */
-    rel_time_t exptime; /**< When the item will expire (relative to process
-                         * startup) */
-    uint32_t nbytes; /**< The total size of the data (in bytes) */
-    uint32_t flags; /**< Flags associated with the item (in network byte order)*/
-    uint16_t nkey; /**< The total length of the key (in bytes) */
-    uint16_t iflag; /**< Intermal flags. lower 8 bit is reserved for the core
-                     * server, the upper 8 bits is reserved for engine
-                     * implementation. */
-    unsigned short refcount;
-    uint8_t slabs_clsid;/* which slab class we're in */
-} hash_item;
-
-typedef struct {
-    unsigned int evicted;
-    unsigned int evicted_nonzero;
-    rel_time_t evicted_time;
-    unsigned int outofmemory;
-    unsigned int tailrepairs;
-    unsigned int reclaimed;
-} itemstats_t;
-
-struct items {
-   hash_item *heads[POWER_LARGEST];
-   hash_item *tails[POWER_LARGEST];
-   itemstats_t itemstats[POWER_LARGEST];
-   unsigned int sizes[POWER_LARGEST];
-};
-
-
-/**
- * Allocate and initialize a new item structure
- * @param engine handle to the storage engine
- * @param key the key for the new item
- * @param nkey the number of bytes in the key
- * @param flags the flags in the new item
- * @param exptime when the object should expire
- * @param nbytes the number of bytes in the body for the item
- * @return a pointer to an item on success NULL otherwise
- */
-hash_item *item_alloc(struct default_engine *engine,
-                      const void *key, size_t nkey, int flags,
-                      rel_time_t exptime, int nbytes, const void *cookie);
-
-/**
- * Get an item from the cache
- *
- * @param engine handle to the storage engine
- * @param key the key for the item to get
- * @param nkey the number of bytes in the key
- * @return pointer to the item if it exists or NULL otherwise
- */
-hash_item *item_get(struct default_engine *engine,
-                    const void *key, const size_t nkey);
-
-/**
- * Reset the item statistics
- * @param engine handle to the storage engine
- */
-void item_stats_reset(struct default_engine *engine);
-
-/**
- * Get item statitistics
- * @param engine handle to the storage engine
- * @param add_stat callback provided by the core used to
- *                 push statistics into the response
- * @param cookie cookie provided by the core to identify the client
- */
-void item_stats(struct default_engine *engine,
-                ADD_STAT add_stat,
-                const void *cookie);
-
-/**
- * Get detaild item statitistics
- * @param engine handle to the storage engine
- * @param add_stat callback provided by the core used to
- *                 push statistics into the response
- * @param cookie cookie provided by the core to identify the client
- */
-void item_stats_sizes(struct default_engine *engine,
-                      ADD_STAT add_stat, const void *cookie);
-
-/**
- * Dump items from the cache
- * @param engine handle to the storage engine
- * @param slabs_clsid the slab class to get items from
- * @param limit the maximum number of items to receive
- * @param bytes the number of bytes in the return message (OUT)
- * @return pointer to a string containint the data
- *
- * @todo we need to rewrite this to use callbacks!!!! currently disabled
- */
-char *item_cachedump(struct default_engine *engine,
-                     const unsigned int slabs_clsid,
-                     const unsigned int limit,
-                     unsigned int *bytes);
-
-/**
- * Flush expired items from the cache
- * @param engine handle to the storage engine
- * @param when when the items should be flushed
- */
-void  item_flush_expired(struct default_engine *engine, time_t when);
-
-/**
- * Release our reference to the current item
- * @param engine handle to the storage engine
- * @param it the item to release
- */
-void item_release(struct default_engine *engine, hash_item *it);
-
-/**
- * Unlink the item from the hash table (make it inaccessible)
- * @param engine handle to the storage engine
- * @param it the item to unlink
- */
-void item_unlink(struct default_engine *engine, hash_item *it);
-
-/**
- * Set the expiration time for an object
- * @param engine handle to the storage engine
- * @param key the key to set
- * @param nkey the number of characters in key..
- * @param exptime the expiration time
- * @return The (updated) item if it exists
- */
-hash_item *touch_item(struct default_engine *engine,
-                      const void *key,
-                      uint16_t nkey,
-                      uint32_t exptime);
-
-/**
- * Store an item in the cache
- * @param engine handle to the storage engine
- * @param item the item to store
- * @param cas the cas value (OUT)
- * @param operation what kind of store operation is this (ADD/SET etc)
- * @return ENGINE_SUCCESS on success
- *
- * @todo should we refactor this into hash_item ** and remove the cas
- *       there so that we can get it from the item instead?
- */
-ENGINE_ERROR_CODE store_item(struct default_engine *engine,
-                             hash_item *item,
-                             uint64_t *cas,
-                             ENGINE_STORE_OPERATION operation,
-                             const void *cookie);
-
-ENGINE_ERROR_CODE arithmetic(struct default_engine *engine,
-                             const void* cookie,
-                             const void* key,
-                             const int nkey,
-                             const bool increment,
-                             const bool create,
-                             const uint64_t delta,
-                             const uint64_t initial,
-                             const rel_time_t exptime,
-                             uint64_t *cas,
-                             uint64_t *result);
-
-
-/**
- * Start the item scrubber
- * @param engine handle to the storage engine
- */
-bool item_start_scrub(struct default_engine *engine);
-
-/**
- * The tap walker to walk the hashtables
- */
-tap_event_t item_tap_walker(ENGINE_HANDLE* handle,
-                            const void *cookie, item **itm,
-                            void **es, uint16_t *nes, uint8_t *ttl,
-                            uint16_t *flags, uint32_t *seqno,
-                            uint16_t *vbucket);
-
-bool initialize_item_tap_walker(struct default_engine *engine,
-                                const void* cookie);
-
-
-#endif

=== removed file 'storage/ndb/memcache/cache-src/slabs.c'
--- a/storage/ndb/memcache/cache-src/slabs.c	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/slabs.c	1970-01-01 00:00:00 +0000
@@ -1,424 +0,0 @@
-/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Slabs memory allocation, based on powers-of-N. Slabs are up to 1MB in size
- * and are divided into chunks. The chunk sizes start off at the size of the
- * "item" structure plus space for a small key and value. They increase by
- * a multiplier factor from there, up to half the maximum slab size. The last
- * slab size is always 1MB, since that's the maximum item size allowed by the
- * memcached protocol.
- */
-#include "config.h"
-
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <pthread.h>
-#include <inttypes.h>
-#include <stdarg.h>
-
-#include "default_engine.h"
-
-/*
- * Forward Declarations
- */
-static int do_slabs_newslab(struct default_engine *engine, const unsigned int id);
-static void *memory_allocate(struct default_engine *engine, size_t size);
-
-#ifndef DONT_PREALLOC_SLABS
-/* Preallocate as many slab pages as possible (called from slabs_init)
-   on start-up, so users don't get confused out-of-memory errors when
-   they do have free (in-slab) space, but no space to make new slabs.
-   if maxslabs is 18 (POWER_LARGEST - POWER_SMALLEST + 1), then all
-   slab types can be made.  if max memory is less than 18 MB, only the
-   smaller ones will be made.  */
-static void slabs_preallocate (const unsigned int maxslabs);
-#endif
-
-/*
- * Figures out which slab class (chunk size) is required to store an item of
- * a given size.
- *
- * Given object size, return id to use when allocating/freeing memory for object
- * 0 means error: can't store such a large object
- */
-
-unsigned int slabs_clsid(struct default_engine *engine, const size_t size) {
-    int res = POWER_SMALLEST;
-
-    if (size == 0)
-        return 0;
-    while (size > engine->slabs.slabclass[res].size)
-        if (res++ == engine->slabs.power_largest)     /* won't fit in the biggest slab */
-            return 0;
-    return res;
-}
-
-/**
- * Determines the chunk sizes and initializes the slab class descriptors
- * accordingly.
- */
-ENGINE_ERROR_CODE slabs_init(struct default_engine *engine,
-                             const size_t limit,
-                             const double factor,
-                             const bool prealloc) {
-    int i = POWER_SMALLEST - 1;
-    unsigned int size = sizeof(hash_item) + engine->config.chunk_size;
-
-    engine->slabs.mem_limit = limit;
-
-    if (prealloc) {
-        /* Allocate everything in a big chunk with malloc */
-        engine->slabs.mem_base = malloc(engine->slabs.mem_limit);
-        if (engine->slabs.mem_base != NULL) {
-            engine->slabs.mem_current = engine->slabs.mem_base;
-            engine->slabs.mem_avail = engine->slabs.mem_limit;
-        } else {
-            return ENGINE_ENOMEM;
-        }
-    }
-
-    memset(engine->slabs.slabclass, 0, sizeof(engine->slabs.slabclass));
-
-    while (++i < POWER_LARGEST && size <= engine->config.item_size_max / factor) {
-        /* Make sure items are always n-byte aligned */
-        if (size % CHUNK_ALIGN_BYTES)
-            size += CHUNK_ALIGN_BYTES - (size % CHUNK_ALIGN_BYTES);
-
-        engine->slabs.slabclass[i].size = size;
-        engine->slabs.slabclass[i].perslab = engine->config.item_size_max / engine->slabs.slabclass[i].size;
-        size *= factor;
-        if (engine->config.verbose > 1) {
-            EXTENSION_LOGGER_DESCRIPTOR *logger;
-            logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-            logger->log(EXTENSION_LOG_INFO, NULL,
-                        "slab class %3d: chunk size %9u perslab %7u\n",
-                        i, engine->slabs.slabclass[i].size,
-                        engine->slabs.slabclass[i].perslab);
-        }
-    }
-
-    engine->slabs.power_largest = i;
-    engine->slabs.slabclass[engine->slabs.power_largest].size = engine->config.item_size_max;
-    engine->slabs.slabclass[engine->slabs.power_largest].perslab = 1;
-    if (engine->config.verbose > 1) {
-        EXTENSION_LOGGER_DESCRIPTOR *logger;
-        logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-        logger->log(EXTENSION_LOG_INFO, NULL,
-                    "slab class %3d: chunk size %9u perslab %7u\n",
-                    i, engine->slabs.slabclass[i].size,
-                    engine->slabs.slabclass[i].perslab);
-    }
-
-    /* for the test suite:  faking of how much we've already malloc'd */
-    {
-        char *t_initial_malloc = getenv("T_MEMD_INITIAL_MALLOC");
-        if (t_initial_malloc) {
-            engine->slabs.mem_malloced = (size_t)atol(t_initial_malloc);
-        }
-
-    }
-
-#ifndef DONT_PREALLOC_SLABS
-    {
-        char *pre_alloc = getenv("T_MEMD_SLABS_ALLOC");
-
-        if (pre_alloc == NULL || atoi(pre_alloc) != 0) {
-            slabs_preallocate(power_largest);
-        }
-    }
-#endif
-
-    return ENGINE_SUCCESS;
-}
-
-#ifndef DONT_PREALLOC_SLABS
-static void slabs_preallocate (const unsigned int maxslabs) {
-    int i;
-    unsigned int prealloc = 0;
-
-    /* pre-allocate a 1MB slab in every size class so people don't get
-       confused by non-intuitive "SERVER_ERROR out of memory"
-       messages.  this is the most common question on the mailing
-       list.  if you really don't want this, you can rebuild without
-       these three lines.  */
-
-    for (i = POWER_SMALLEST; i <= POWER_LARGEST; i++) {
-        if (++prealloc > maxslabs)
-            return;
-        do_slabs_newslab(i);
-    }
-
-}
-#endif
-
-static int grow_slab_list (struct default_engine *engine, const unsigned int id) {
-    slabclass_t *p = &engine->slabs.slabclass[id];
-    if (p->slabs == p->list_size) {
-        size_t new_size =  (p->list_size != 0) ? p->list_size * 2 : 16;
-        void *new_list = realloc(p->slab_list, new_size * sizeof(void *));
-        if (new_list == 0) return 0;
-        p->list_size = new_size;
-        p->slab_list = new_list;
-    }
-    return 1;
-}
-
-static int do_slabs_newslab(struct default_engine *engine, const unsigned int id) {
-    slabclass_t *p = &engine->slabs.slabclass[id];
-    int len = p->size * p->perslab;
-    char *ptr;
-
-    if ((engine->slabs.mem_limit && engine->slabs.mem_malloced + len > engine->slabs.mem_limit && p->slabs > 0) ||
-        (grow_slab_list(engine, id) == 0) ||
-        ((ptr = memory_allocate(engine, (size_t)len)) == 0)) {
-
-        MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED(id);
-        return 0;
-    }
-
-    memset(ptr, 0, (size_t)len);
-    p->end_page_ptr = ptr;
-    p->end_page_free = p->perslab;
-
-    p->slab_list[p->slabs++] = ptr;
-    engine->slabs.mem_malloced += len;
-    MEMCACHED_SLABS_SLABCLASS_ALLOCATE(id);
-
-    return 1;
-}
-
-/*@null@*/
-static void *do_slabs_alloc(struct default_engine *engine, const size_t size, unsigned int id) {
-    slabclass_t *p;
-    void *ret = NULL;
-
-    if (id < POWER_SMALLEST || id > engine->slabs.power_largest) {
-        MEMCACHED_SLABS_ALLOCATE_FAILED(size, 0);
-        return NULL;
-    }
-
-    p = &engine->slabs.slabclass[id];
-
-#ifdef USE_SYSTEM_MALLOC
-    if (engine->slabs.mem_limit && engine->slabs.mem_malloced + size > engine->slabs.mem_limit) {
-        MEMCACHED_SLABS_ALLOCATE_FAILED(size, id);
-        return 0;
-    }
-    engine->slabs.mem_malloced += size;
-    ret = malloc(size);
-    MEMCACHED_SLABS_ALLOCATE(size, id, 0, ret);
-    return ret;
-#endif
-
-    /* fail unless we have space at the end of a recently allocated page,
-       we have something on our freelist, or we could allocate a new page */
-    if (! (p->end_page_ptr != 0 || p->sl_curr != 0 ||
-           do_slabs_newslab(engine, id) != 0)) {
-        /* We don't have more memory available */
-        ret = NULL;
-    } else if (p->sl_curr != 0) {
-        /* return off our freelist */
-        ret = p->slots[--p->sl_curr];
-    } else {
-        /* if we recently allocated a whole page, return from that */
-        assert(p->end_page_ptr != NULL);
-        ret = p->end_page_ptr;
-        if (--p->end_page_free != 0) {
-            p->end_page_ptr = ((caddr_t)p->end_page_ptr) + p->size;
-        } else {
-            p->end_page_ptr = 0;
-        }
-    }
-
-    if (ret) {
-        p->requested += size;
-        MEMCACHED_SLABS_ALLOCATE(size, id, p->size, ret);
-    } else {
-        MEMCACHED_SLABS_ALLOCATE_FAILED(size, id);
-    }
-
-    return ret;
-}
-
-static void do_slabs_free(struct default_engine *engine, void *ptr, const size_t size, unsigned int id) {
-    slabclass_t *p;
-
-    if (id < POWER_SMALLEST || id > engine->slabs.power_largest)
-        return;
-
-    MEMCACHED_SLABS_FREE(size, id, ptr);
-    p = &engine->slabs.slabclass[id];
-
-#ifdef USE_SYSTEM_MALLOC
-    engine->slabs.mem_malloced -= size;
-    free(ptr);
-    return;
-#endif
-
-    if (p->sl_curr == p->sl_total) { /* need more space on the free list */
-        int new_size = (p->sl_total != 0) ? p->sl_total * 2 : 16;  /* 16 is arbitrary */
-        void **new_slots = realloc(p->slots, new_size * sizeof(void *));
-        if (new_slots == 0)
-            return;
-        p->slots = new_slots;
-        p->sl_total = new_size;
-    }
-    p->slots[p->sl_curr++] = ptr;
-    p->requested -= size;
-    return;
-}
-
-void add_statistics(const void *cookie, ADD_STAT add_stats,
-                    const char* prefix, int num, const char *key,
-                    const char *fmt, ...) {
-    char name[80], val[80];
-    int klen = 0, vlen;
-    va_list ap;
-
-    assert(cookie);
-    assert(add_stats);
-    assert(key);
-
-    va_start(ap, fmt);
-    vlen = vsnprintf(val, sizeof(val) - 1, fmt, ap);
-    va_end(ap);
-
-    if (prefix != NULL) {
-        klen = snprintf(name, sizeof(name), "%s:", prefix);
-    }
-
-    if (num != -1) {
-        klen += snprintf(name + klen, sizeof(name) - klen, "%d:", num);
-    }
-
-    klen += snprintf(name + klen, sizeof(name) - klen, "%s", key);
-
-    add_stats(name, klen, val, vlen, cookie);
-}
-
-/*@null@*/
-static void do_slabs_stats(struct default_engine *engine, ADD_STAT add_stats, const void *cookie) {
-    int i, total;
-    /* Get the per-thread stats which contain some interesting aggregates */
-#ifdef FUTURE
-    struct conn *conn = (struct conn*)cookie;
-    struct thread_stats thread_stats;
-    threadlocal_stats_aggregate(c, &thread_stats);
-#endif
-
-    total = 0;
-    for(i = POWER_SMALLEST; i <= engine->slabs.power_largest; i++) {
-        slabclass_t *p = &engine->slabs.slabclass[i];
-        if (p->slabs != 0) {
-            uint32_t perslab, slabs;
-            slabs = p->slabs;
-            perslab = p->perslab;
-
-            add_statistics(cookie, add_stats, NULL, i, "chunk_size", "%u",
-                           p->size);
-            add_statistics(cookie, add_stats, NULL, i, "chunks_per_page", "%u",
-                           perslab);
-            add_statistics(cookie, add_stats, NULL, i, "total_pages", "%u",
-                           slabs);
-            add_statistics(cookie, add_stats, NULL, i, "total_chunks", "%u",
-                           slabs * perslab);
-            add_statistics(cookie, add_stats, NULL, i, "used_chunks", "%u",
-                           slabs*perslab - p->sl_curr - p->end_page_free);
-            add_statistics(cookie, add_stats, NULL, i, "free_chunks", "%u",
-                           p->sl_curr);
-            add_statistics(cookie, add_stats, NULL, i, "free_chunks_end", "%u",
-                           p->end_page_free);
-            add_statistics(cookie, add_stats, NULL, i, "mem_requested", "%zu",
-                           p->requested);
-#ifdef FUTURE
-            add_statistics(cookie, add_stats, NULL, i, "get_hits", "%"PRIu64,
-                           thread_stats.slab_stats[i].get_hits);
-            add_statistics(cookie, add_stats, NULL, i, "cmd_set", "%"PRIu64,
-                           thread_stats.slab_stats[i].set_cmds);
-            add_statistics(cookie, add_stats, NULL, i, "delete_hits", "%"PRIu64,
-                           thread_stats.slab_stats[i].delete_hits);
-            add_statistics(cookie, add_stats, NULL, i, "cas_hits", "%"PRIu64,
-                           thread_stats.slab_stats[i].cas_hits);
-            add_statistics(cookie, add_stats, NULL, i, "cas_badval", "%"PRIu64,
-                           thread_stats.slab_stats[i].cas_badval);
-#endif
-            total++;
-        }
-    }
-
-    /* add overall slab stats and append terminator */
-
-    add_statistics(cookie, add_stats, NULL, -1, "active_slabs", "%d", total);
-    add_statistics(cookie, add_stats, NULL, -1, "total_malloced", "%zu",
-                   engine->slabs.mem_malloced);
-}
-
-static void *memory_allocate(struct default_engine *engine, size_t size) {
-    void *ret;
-
-    if (engine->slabs.mem_base == NULL) {
-        /* We are not using a preallocated large memory chunk */
-        ret = malloc(size);
-    } else {
-        ret = engine->slabs.mem_current;
-
-        if (size > engine->slabs.mem_avail) {
-            return NULL;
-        }
-
-        /* mem_current pointer _must_ be aligned!!! */
-        if (size % CHUNK_ALIGN_BYTES) {
-            size += CHUNK_ALIGN_BYTES - (size % CHUNK_ALIGN_BYTES);
-        }
-
-        engine->slabs.mem_current = ((char*)engine->slabs.mem_current) + size;
-        if (size < engine->slabs.mem_avail) {
-            engine->slabs.mem_avail -= size;
-        } else {
-            engine->slabs.mem_avail = 0;
-        }
-    }
-
-    return ret;
-}
-
-void *slabs_alloc(struct default_engine *engine, size_t size, unsigned int id) {
-    void *ret;
-
-    pthread_mutex_lock(&engine->slabs.lock);
-    ret = do_slabs_alloc(engine, size, id);
-    pthread_mutex_unlock(&engine->slabs.lock);
-    return ret;
-}
-
-void slabs_free(struct default_engine *engine, void *ptr, size_t size, unsigned int id) {
-    pthread_mutex_lock(&engine->slabs.lock);
-    do_slabs_free(engine, ptr, size, id);
-    pthread_mutex_unlock(&engine->slabs.lock);
-}
-
-void slabs_stats(struct default_engine *engine, ADD_STAT add_stats, const void *c) {
-    pthread_mutex_lock(&engine->slabs.lock);
-    do_slabs_stats(engine, add_stats, c);
-    pthread_mutex_unlock(&engine->slabs.lock);
-}
-
-void slabs_adjust_mem_requested(struct default_engine *engine, unsigned int id, size_t old, size_t ntotal)
-{
-    pthread_mutex_lock(&engine->slabs.lock);
-    slabclass_t *p;
-    if (id < POWER_SMALLEST || id > engine->slabs.power_largest) {
-        EXTENSION_LOGGER_DESCRIPTOR *logger;
-        logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
-        logger->log(EXTENSION_LOG_WARNING, NULL,
-                    "Internal error! Invalid slab class\n");
-        abort();
-    }
-
-    p = &engine->slabs.slabclass[id];
-    p->requested = p->requested - old + ntotal;
-    pthread_mutex_unlock(&engine->slabs.lock);
-}

=== removed file 'storage/ndb/memcache/cache-src/slabs.h'
--- a/storage/ndb/memcache/cache-src/slabs.h	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/slabs.h	1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-/* slabs memory allocation */
-#ifndef SLABS_H
-#define SLABS_H
-
-#include "default_engine.h"
-
-
-
-/* powers-of-N allocation structures */
-
-typedef struct {
-    unsigned int size;      /* sizes of items */
-    unsigned int perslab;   /* how many items per slab */
-
-    void **slots;           /* list of item ptrs */
-    unsigned int sl_total;  /* size of previous array */
-    unsigned int sl_curr;   /* first free slot */
-
-    void *end_page_ptr;         /* pointer to next free item at end of page, or 0 */
-    unsigned int end_page_free; /* number of items remaining at end of last alloced page */
-
-    unsigned int slabs;     /* how many slabs were allocated for this class */
-
-    void **slab_list;       /* array of slab pointers */
-    unsigned int list_size; /* size of prev array */
-
-    unsigned int killing;  /* index+1 of dying slab, or zero if none */
-    size_t requested; /* The number of requested bytes */
-} slabclass_t;
-
-struct slabs {
-   slabclass_t slabclass[MAX_NUMBER_OF_SLAB_CLASSES];
-   size_t mem_limit;
-   size_t mem_malloced;
-   int power_largest;
-
-   void *mem_base;
-   void *mem_current;
-   size_t mem_avail;
-
-   /**
-    * Access to the slab allocator is protected by this lock
-    */
-   pthread_mutex_t lock;
-};
-
-
-
-
-/** Init the subsystem. 1st argument is the limit on no. of bytes to allocate,
-    0 if no limit. 2nd argument is the growth factor; each slab will use a chunk
-    size equal to the previous slab's chunk size times this factor.
-    3rd argument specifies if the slab allocator should allocate all memory
-    up front (if true), or allocate memory in chunks as it is needed (if false)
-*/
-ENGINE_ERROR_CODE slabs_init(struct default_engine *engine,
-                             const size_t limit,
-                             const double factor,
-                             const bool prealloc);
-
-
-/**
- * Given object size, return id to use when allocating/freeing memory for object
- * 0 means error: can't store such a large object
- */
-
-unsigned int slabs_clsid(struct default_engine *engine, const size_t size);
-
-/** Allocate object of given length. 0 on error */ /*@null@*/
-void *slabs_alloc(struct default_engine *engine, const size_t size, unsigned int id);
-
-/** Free previously allocated object */
-void slabs_free(struct default_engine *engine, void *ptr, size_t size, unsigned int id);
-
-/** Adjust the stats for memory requested */
-void slabs_adjust_mem_requested(struct default_engine *engine, unsigned int id, size_t old, size_t ntotal);
-
-/** Fill buffer with stats */ /*@null@*/
-void slabs_stats(struct default_engine *engine, ADD_STAT add_stats, const void *c);
-
-void add_statistics(const void *cookie, ADD_STAT add_stats,
-                    const char *prefix, int num, const char *key,
-                    const char *fmt, ...);
-
-#endif

=== removed file 'storage/ndb/memcache/cache-src/trace.h'
--- a/storage/ndb/memcache/cache-src/trace.h	2011-09-12 10:05:07 +0000
+++ b/storage/ndb/memcache/cache-src/trace.h	1970-01-01 00:00:00 +0000
@@ -1,69 +0,0 @@
-#ifndef TRACE_H
-#define TRACE_H
-
-#ifdef ENABLE_DTRACE
-#include "memcached_dtrace.h"
-#else
-#define MEMCACHED_ASSOC_DELETE(arg0, arg1, arg2)
-#define MEMCACHED_ASSOC_DELETE_ENABLED() (0)
-#define MEMCACHED_ASSOC_FIND(arg0, arg1, arg2)
-#define MEMCACHED_ASSOC_FIND_ENABLED() (0)
-#define MEMCACHED_ASSOC_INSERT(arg0, arg1, arg2)
-#define MEMCACHED_ASSOC_INSERT_ENABLED() (0)
-#define MEMCACHED_COMMAND_ADD(arg0, arg1, arg2, arg3, arg4)
-#define MEMCACHED_COMMAND_ADD_ENABLED() (0)
-#define MEMCACHED_COMMAND_APPEND(arg0, arg1, arg2, arg3, arg4)
-#define MEMCACHED_COMMAND_APPEND_ENABLED() (0)
-#define MEMCACHED_COMMAND_CAS(arg0, arg1, arg2, arg3, arg4)
-#define MEMCACHED_COMMAND_CAS_ENABLED() (0)
-#define MEMCACHED_COMMAND_DECR(arg0, arg1, arg2, arg3)
-#define MEMCACHED_COMMAND_DECR_ENABLED() (0)
-#define MEMCACHED_COMMAND_DELETE(arg0, arg1, arg2)
-#define MEMCACHED_COMMAND_DELETE_ENABLED() (0)
-#define MEMCACHED_COMMAND_GET(arg0, arg1, arg2, arg3, arg4)
-#define MEMCACHED_COMMAND_GET_ENABLED() (0)
-#define MEMCACHED_COMMAND_INCR(arg0, arg1, arg2, arg3)
-#define MEMCACHED_COMMAND_INCR_ENABLED() (0)
-#define MEMCACHED_COMMAND_PREPEND(arg0, arg1, arg2, arg3, arg4)
-#define MEMCACHED_COMMAND_PREPEND_ENABLED() (0)
-#define MEMCACHED_COMMAND_REPLACE(arg0, arg1, arg2, arg3, arg4)
-#define MEMCACHED_COMMAND_REPLACE_ENABLED() (0)
-#define MEMCACHED_COMMAND_SET(arg0, arg1, arg2, arg3, arg4)
-#define MEMCACHED_COMMAND_SET_ENABLED() (0)
-#define MEMCACHED_CONN_ALLOCATE(arg0)
-#define MEMCACHED_CONN_ALLOCATE_ENABLED() (0)
-#define MEMCACHED_CONN_CREATE(arg0)
-#define MEMCACHED_CONN_CREATE_ENABLED() (0)
-#define MEMCACHED_CONN_DESTROY(arg0)
-#define MEMCACHED_CONN_DESTROY_ENABLED() (0)
-#define MEMCACHED_CONN_DISPATCH(arg0, arg1)
-#define MEMCACHED_CONN_DISPATCH_ENABLED() (0)
-#define MEMCACHED_CONN_RELEASE(arg0)
-#define MEMCACHED_CONN_RELEASE_ENABLED() (0)
-#define MEMCACHED_ITEM_LINK(arg0, arg1, arg2)
-#define MEMCACHED_ITEM_LINK_ENABLED() (0)
-#define MEMCACHED_ITEM_REMOVE(arg0, arg1, arg2)
-#define MEMCACHED_ITEM_REMOVE_ENABLED() (0)
-#define MEMCACHED_ITEM_REPLACE(arg0, arg1, arg2, arg3, arg4, arg5)
-#define MEMCACHED_ITEM_REPLACE_ENABLED() (0)
-#define MEMCACHED_ITEM_UNLINK(arg0, arg1, arg2)
-#define MEMCACHED_ITEM_UNLINK_ENABLED() (0)
-#define MEMCACHED_ITEM_UPDATE(arg0, arg1, arg2)
-#define MEMCACHED_ITEM_UPDATE_ENABLED() (0)
-#define MEMCACHED_PROCESS_COMMAND_END(arg0, arg1, arg2)
-#define MEMCACHED_PROCESS_COMMAND_END_ENABLED() (0)
-#define MEMCACHED_PROCESS_COMMAND_START(arg0, arg1, arg2)
-#define MEMCACHED_PROCESS_COMMAND_START_ENABLED() (0)
-#define MEMCACHED_SLABS_ALLOCATE(arg0, arg1, arg2, arg3)
-#define MEMCACHED_SLABS_ALLOCATE_ENABLED() (0)
-#define MEMCACHED_SLABS_ALLOCATE_FAILED(arg0, arg1)
-#define MEMCACHED_SLABS_ALLOCATE_FAILED_ENABLED() (0)
-#define MEMCACHED_SLABS_FREE(arg0, arg1, arg2)
-#define MEMCACHED_SLABS_FREE_ENABLED() (0)
-#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE(arg0)
-#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_ENABLED() (0)
-#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED(arg0)
-#define MEMCACHED_SLABS_SLABCLASS_ALLOCATE_FAILED_ENABLED() (0)
-#endif
-
-#endif

=== modified file 'storage/ndb/memcache/unit/all_tests.h'
--- a/storage/ndb/memcache/unit/all_tests.h	2011-09-30 16:22:30 +0000
+++ b/storage/ndb/memcache/unit/all_tests.h	2011-10-01 16:54:26 +0000
@@ -63,7 +63,7 @@ struct test_item all_tests[] = { 
   { 0, "pool",            run_pool_test,        REQ_NDB_CONNECTION },
   { 1, "tsv",             run_tsv_test,         REQ_NONE },
   { 1, "queue",           run_queue_test,       REQ_NONE },
-  { 0, NULL, NULL, NULL }
+  { 0, NULL, NULL, 0 }
 };
 
 

=== modified file 'storage/ndb/memcache/unit/test_workqueue.c'
--- a/storage/ndb/memcache/unit/test_workqueue.c	2011-09-23 18:29:30 +0000
+++ b/storage/ndb/memcache/unit/test_workqueue.c	2011-10-01 16:54:26 +0000
@@ -35,6 +35,7 @@
 #define TEST_ITERATIONS 1000000
 #define DO_SLEEP 1
 
+
 void * producer_thread(void *arg);
 void * consumer_thread(void *arg);
 
@@ -49,12 +50,16 @@ struct threadinfo { 
   int report_interval;
 };  
 
+struct threadreturn {
+  unsigned int nrecv;
+};
+
 int run_test(struct threadinfo *);
 void express_nanosec(Uint64 nsec);
 
 int sleep_microseconds(int);
 
-int main(int argc, char *argv[]) {
+int main() {
   struct workqueue *queue; 
   queue = (struct workqueue *) calloc(1, sizeof(struct workqueue));
 
@@ -126,9 +131,9 @@ int run_test(struct threadinfo *params) 
   
   pthread_join(producer_thd_id, NULL);
   for(i = 0; i < params->nconsumers; i++) {
-    size_t nrecv;
-    pthread_join(consumer_thd_ids[i], (void **) &nrecv) ;
-    total_consumed += nrecv;
+    struct threadreturn *ret;
+    pthread_join(consumer_thd_ids[i], (void **) &ret) ;
+    total_consumed += ret->nrecv;
   }
 
   workqueue_destroy(params->q);  
@@ -192,11 +197,12 @@ void * consumer_thread(void *arg) {
   long long total_sleep = 0;
   size_t i;
   size_t last_i = 0;
-  size_t nrecv = 0;
   
   struct threadinfo *testinfo = (struct threadinfo *) arg;  
   struct workqueue *queue = testinfo->q;
   int sleeptime = testinfo->consumer_median_sleep;
+  struct threadreturn *ret = malloc(sizeof(struct threadreturn));
+  ret->nrecv = 0;
   
   /* fetch items from the queue, 1 at a time, and sleep for some time to 
      simulate processing them */
@@ -208,7 +214,7 @@ void * consumer_thread(void *arg) {
 
     i = (size_t) workqueue_consumer_wait(queue);
     if(i) {
-      nrecv++;
+      ret->nrecv++;
       if(i == 10) printf("read 10.\n");
       if(i % testinfo->report_interval == 0) printf("read %d.\n", (int) i);
       assert(i > last_i);
@@ -216,9 +222,9 @@ void * consumer_thread(void *arg) {
       if(sleeptime) total_sleep += sleep_microseconds(slp);
     }
     else {    
-      printf("Consumer thread read %d; slept for %f sec. \n", (int) nrecv,
+      printf("Consumer thread read %d; slept for %f sec. \n", ret->nrecv,
              (double) total_sleep / 1000000);
-      return (void *) nrecv;
+      return (void *) ret;
     }
   }
 }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster branch (john.duncan:3579 to 3580) John David Duncan2 Oct