From e2b8bf88befb43e4a189ce3e659c595e5b3af7dc Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 12 Jun 2014 11:46:09 +0200 Subject: [PATCH] Allow memcached version 0.40 Remove some redundant memcached defines and rename a bit. --- configure.ac | 12 +++++------- src/zoom-memcached.c | 25 +++++++++++++------------ src/zoom-p.h | 4 ++-- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index ae1c9f1..5374f34 100644 --- a/configure.ac +++ b/configure.ac @@ -130,23 +130,21 @@ AC_ARG_WITH([memcached], [ --with-memcached Memcached library], [memcach if test "$memcached" != "no" -a -n "$libgcryptversion" -a "$pkgconfigpath" != "NONE"; then AC_MSG_CHECKING([for libmemcached]) if $pkgconfigpath --cflags libmemcached >/dev/null 2>&1 ; then - if $pkgconfigpath --atleast-version 1.0 libmemcached; then + if $pkgconfigpath --atleast-version 0.40 libmemcached; then AC_MSG_RESULT([yes]) CFLAGS="$CFLAGS `$pkgconfigpath --cflags libmemcached`" MEMCACHED_LIBS="`$pkgconfigpath --libs libmemcached`" - AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H],[1],[Define to 1 if memcached header]) - AC_DEFINE([HAVE_MEMCACHED_FUNC],[1],[Define to 1 if memcached function is defined]) - AC_DEFINE([HAVE_MEMCACHED_RETURN_T],[1],[Define to 1 if memcached_return_t is defined]) + AC_DEFINE([HAVE_LIBMEMCACHED],[1],[Define to 1 if memcached is enabled]) else - AC_MSG_RESULT([no. Version 1.0 required]) + AC_MSG_RESULT([no. Version 0.40 required]) if test "$memcached" != "default"; then - AC_MSG_ERROR([libmemcached libraries missing]) + AC_MSG_ERROR([libmemcached libraries missing]) fi fi else AC_MSG_RESULT([no]) if test "$memcached" != "default"; then - AC_MSG_ERROR([libmemcached libraries missing]) + AC_MSG_ERROR([libmemcached libraries missing]) fi fi fi diff --git a/src/zoom-memcached.c b/src/zoom-memcached.c index def2ac9..fbdc886 100644 --- a/src/zoom-memcached.c +++ b/src/zoom-memcached.c @@ -20,16 +20,17 @@ #include #include -#if HAVE_LIBMEMCACHED_MEMCACHED_H -#if HAVE_MEMCACHED_RETURN_T +#if HAVE_LIBMEMCACHED +#if LIBMEMCACHED_VERSION_HEX >= 0x01000000 +#define HAVE_MEMCACHED_FUNC 1 #else -typedef memcached_return memcached_return_t; +#define HAVE_MEMCACHED_FUNC 0 #endif #endif void ZOOM_memcached_init(ZOOM_connection c) { -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED c->mc_st = 0; #endif #if HAVE_HIREDIS @@ -39,7 +40,7 @@ void ZOOM_memcached_init(ZOOM_connection c) void ZOOM_memcached_destroy(ZOOM_connection c) { -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED if (c->mc_st) memcached_free(c->mc_st); #endif @@ -49,7 +50,7 @@ void ZOOM_memcached_destroy(ZOOM_connection c) #endif } -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED /* memcached wrapper.. Because memcached function do not exist in older libs */ static memcached_st *yaz_memcached_wrap(const char *conf) { @@ -137,7 +138,7 @@ int ZOOM_memcached_configure(ZOOM_connection c) c->redis_c = 0; } #endif -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED if (c->mc_st) { memcached_free(c->mc_st); @@ -165,7 +166,7 @@ int ZOOM_memcached_configure(ZOOM_connection c) val = ZOOM_options_get(c->options, "memcached"); if (val && *val) { -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED c->mc_st = yaz_memcached_wrap(val); if (!c->mc_st) { @@ -274,7 +275,7 @@ void ZOOM_memcached_search(ZOOM_connection c, ZOOM_resultset resultset) freeReplyObject(reply); } #endif -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED if (c->mc_st && resultset->live_set == 0) { size_t v_len; @@ -358,7 +359,7 @@ void ZOOM_memcached_hitcount(ZOOM_connection c, ZOOM_resultset resultset, odr_destroy(odr); } #endif -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED if (c->mc_st && resultset->live_set == 0) { uint32_t flags = 0; @@ -452,7 +453,7 @@ void ZOOM_memcached_add(ZOOM_resultset r, Z_NamePlusRecord *npr, wrbuf_destroy(rec_sha1); } #endif -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED if (r->connection->mc_st && !diag && npr->which == Z_NamePlusRecord_databaseRecord) { @@ -561,7 +562,7 @@ Z_NamePlusRecord *ZOOM_memcached_lookup(ZOOM_resultset r, int pos, freeReplyObject(reply1); } #endif -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED if (r->connection && r->connection->mc_st) { WRBUF k = wrbuf_alloc(); diff --git a/src/zoom-p.h b/src/zoom-p.h index bb6db6f..d533084 100644 --- a/src/zoom-p.h +++ b/src/zoom-p.h @@ -36,7 +36,7 @@ #include #include #include -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED #include #endif #if HAVE_HIREDIS @@ -115,7 +115,7 @@ struct ZOOM_connection_p { int log_details; int log_api; WRBUF saveAPDU_wrbuf; -#if HAVE_LIBMEMCACHED_MEMCACHED_H +#if HAVE_LIBMEMCACHED memcached_st *mc_st; #endif #if HAVE_HIREDIS -- 1.7.10.4