Permalink
Browse files

repcached 1.0

  • Loading branch information...
mdounin committed Feb 4, 2010
1 parent 24d9040 commit 59a0ac3ab218fcd0d59c6575cd0ef31cd7b9ec48
Showing with 1,051 additions and 2 deletions.
  1. +2 −0 AUTHORS.repcached
  2. +3 −0 Makefile.am
  3. +49 −0 assoc.c
  4. +5 −0 assoc.h
  5. +11 −0 configure.ac
  6. +591 −2 memcached.c
  7. +17 −0 memcached.h
  8. +337 −0 replication.c
  9. +36 −0 replication.h
View
@@ -0,0 +1,2 @@
+YASUI Masanobu <yasui-m at klab.org>
+HIROSE Masaaki <hirose at klab.org>
View
@@ -1,6 +1,9 @@
bin_PROGRAMS = memcached memcached-debug
memcached_SOURCES = memcached.c slabs.c slabs.h items.c items.h assoc.c assoc.h memcached.h thread.c stats.c stats.h
+if ENABLE_REPLICATION
+memcached_SOURCES += replication.h replication.c
+endif
memcached_debug_SOURCES = $(memcached_SOURCES)
memcached_CPPFLAGS = -DNDEBUG
memcached_LDADD = @LIBOBJS@
View
49 assoc.c
@@ -615,3 +615,52 @@ void assoc_delete(const char *key, const size_t nkey) {
they can't find. */
assert(*before != 0);
}
+
+#ifdef USE_REPLICATION
+char *assoc_key_snap(int *n)
+{
+ char *p = NULL;
+ char *b = NULL;
+ item *i = NULL;
+ int co = 0;
+ int sz = 1;
+ int hs = 0;
+ int hm = hashsize(hashpower);
+
+ hs = hm;
+ while(hs--){
+ if(expanding && hs < hashsize(hashpower - 1) && hs >= expand_bucket){
+ i = old_hashtable[hs];
+ }else{
+ i = primary_hashtable[hs];
+ }
+ while(i){
+ sz += i->nkey + 1;
+ co++;
+ i = i->h_next;
+ }
+ }
+
+ if(co){
+ if(p = b = malloc(sz)){
+ hs = hm;
+ while(hs--){
+ if(expanding && hs < hashsize(hashpower - 1) && hs >= expand_bucket){
+ i = old_hashtable[hs];
+ }else{
+ i = primary_hashtable[hs];
+ }
+ while(i){
+ memcpy(p, ITEM_key(i), i->nkey);
+ p += i->nkey;
+ *(p++) = 0;
+ i = i->h_next;
+ }
+ }
+ *(p++) = 0;
+ }
+ }
+ if(n) *n = co;
+ return(b);
+}
+#endif /* USE_REPLICATION */
View
@@ -5,3 +5,8 @@ int assoc_insert(item *item);
void assoc_delete(const char *key, const size_t nkey);
void do_assoc_move_next_bucket(void);
uint32_t hash( const void *key, size_t length, const uint32_t initval);
+
+#ifdef USE_REPLICATION
+char *assoc_key_snap();
+#endif /* USE_REPLICATION */
+
View
@@ -166,6 +166,17 @@ AC_ARG_ENABLE(threads,
AC_MSG_ERROR([Can't enable threads without the POSIX thread library.])
fi])
+dnl Check whether the user wants replication or not
+AC_ARG_ENABLE(replication,
+ [AS_HELP_STRING([--enable-replication],[support replication])],
+ [if test "x$enable_threads" = "xyes"; then
+ AC_MSG_ERROR([Can't enable threads and replication together.])
+ else
+ AC_DEFINE([USE_REPLICATION],,[Define this if you want to use replication])
+ fi
+ ])
+AM_CONDITIONAL(ENABLE_REPLICATION, test "x$enable_replication" = "xyes")
+
AC_CHECK_FUNCS(mlockall)
AC_CONFIG_FILES(Makefile doc/Makefile)
Oops, something went wrong.

0 comments on commit 59a0ac3

Please sign in to comment.