From: Brian Aker Date: Fri, 28 Sep 2007 23:41:07 +0000 (-0700) Subject: DTrace support X-Git-Tag: 0.3~16 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a95ca4ad9c0f9d23c8a83bd337acdecc221021ef;p=m6w6%2Flibmemcached DTrace support Refactored to use config built for application Fixed test case push --- diff --git a/Makefile.am b/Makefile.am index 5cc8d5c5..51c7b706 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,21 +1,21 @@ -INCLUDES = include -SUBDIRS = docs include lib src tests support - -test: all - cd tests; make test; cd .. - -test-extended: all - cd tests; make test-extended; cd .. - -valgrind: - cd tests; make valgrind; cd .. - -valgrind-extended: - cd tests; make valgrind-extended; cd .. - - -rpm: all dist - cp libmemcached-$(VERSION).tar.gz /home/brian/rpmbuild/SOURCES/ - rpmbuild -ba support/libmemcached.spec - cp /home/brian/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm . - cp /home/brian/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm . +INCLUDES = include +SUBDIRS = docs include lib src tests support + +test: all + cd tests; make test; cd .. + +test-extended: all + cd tests; make test-extended; cd .. + +valgrind: + cd tests; make valgrind; cd .. + +valgrind-extended: + cd tests; make valgrind-extended; cd .. + + +rpm: all dist + cp libmemcached-$(VERSION).tar.gz /home/brian/rpmbuild/SOURCES/ + rpmbuild -ba support/libmemcached.spec + cp /home/brian/rpmbuild/RPMS/x86_64/libmemcached-$(VERSION)*.rpm . + cp /home/brian/rpmbuild/SRPMS/libmemcached-$(VERSION)*.rpm . diff --git a/configure.in b/configure.in index b3b0bc21..cb15a7b1 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ AC_INIT(src/memcat.c) AC_CONFIG_AUX_DIR(config) -AM_CONFIG_HEADER(config.h) +AM_CONFIG_HEADER(libmemcached_config.h) AM_INIT_AUTOMAKE("libmemcached", 0.2 ) AC_PROG_CC @@ -8,6 +8,8 @@ AC_PROG_LIBTOOL LIBTOOL="$LIBTOOL --preserve-dup-deps" AC_SUBST(LIBTOOL)dnl +sinclude(config/dtrace.m4) + # We only support GCC and Sun's forte at the moment if test "$GCC" = "yes" then diff --git a/lib/Makefile.am b/lib/Makefile.am index 0b4bbc6b..1c688533 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,28 @@ -INCLUDES = -I$(top_builddir)/include +EXTRA_DIST = libmemcached_probes.d + +INCLUDES = -I$(top_builddir)/include -I$(top_builddir) LIBS = +DTRACE = @DTRACE@ +DTRACEFLAGS = @DTRACEFLAGS@ +DTRACEFILES = memcached.o \ + memcached_strerror.o \ + memcached_connect.o \ + memcached_response.o \ + memcached_get.o \ + memcached_storage.o \ + memcached_delete.o \ + memcached_hash.o \ + memcached_auto.o \ + memcached_verbosity.o \ + memcached_quit.o \ + memcached_flush.o \ + memcached_string.o \ + memcached_stats.o + +noinst_HEADERS = libmemcached_probes.h \ + common.h + lib_LTLIBRARIES = libmemcached.la libmemcached_la_SOURCES = memcached.c \ memcached_strerror.c \ @@ -16,3 +38,17 @@ libmemcached_la_SOURCES = memcached.c \ memcached_flush.c \ memcached_string.c \ memcached_stats.c +libmemcached_la_LIBADD = + +if HAVE_DTRACE + libmemcached_la_LIBADD += libmemcached_probes.o +endif + +libmemcached_probes.h: libmemcached_probes.d + $(DTRACE) $(DTRACEFLAGS) -h -s libmemcached_probes.d + mv libmemcached_probes.h libmemcached_probes.h.bak + sed "s/#include //g" libmemcached_probes.h.bak > libmemcached_probes.h + rm libmemcached_probes.h.bak + +libmemcached_probes.o: + $(DTRACE) $(DTRACEFLAGS) -G -s libmemcached_probes.d $(DTRACEFILES) diff --git a/lib/libmemcached_probes.d b/lib/libmemcached_probes.d new file mode 100644 index 00000000..ae68e34c --- /dev/null +++ b/lib/libmemcached_probes.d @@ -0,0 +1,24 @@ +provider libmemcached { + probe memcached_delete_start(); + probe memcached_delete_end(); + probe memcached_increment_start(); + probe memcached_increment_end(); + probe memcached_decrement_start(); + probe memcached_decrement_end(); + probe memcached_flush_start(); + probe memcached_flush_end(); + probe memcached_set_start(); + probe memcached_set_end(); + probe memcached_add_start(); + probe memcached_add_end(); + probe memcached_replace_start(); + probe memcached_replace_end(); + probe memcached_get_start(); + probe memcached_get_end(); + probe memcached_mget_start(); + probe memcached_mget_end(); + probe memcached_connect_start(); + probe memcached_connect_end(); + probe memcached_server_add_start(); + probe memcached_server_add_end(); +}; diff --git a/lib/libmemcached_probes.h b/lib/libmemcached_probes.h new file mode 100644 index 00000000..ba563ac2 --- /dev/null +++ b/lib/libmemcached_probes.h @@ -0,0 +1,207 @@ +/* + * Generated by dtrace(1M). + */ + +#ifndef _LIBMEMCACHED_PROBES_H +#define _LIBMEMCACHED_PROBES_H + + + +#ifdef __cplusplus +extern "C" { +#endif + +#if _DTRACE_VERSION + +#warning "Trying to BUILD WITH DTRACE!!!!" + +#define LIBMEMCACHED_MEMCACHED_ADD_END() \ + __dtrace_libmemcached___memcached_add_end() +#define LIBMEMCACHED_MEMCACHED_ADD_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_add_end() +#define LIBMEMCACHED_MEMCACHED_ADD_START() \ + __dtrace_libmemcached___memcached_add_start() +#define LIBMEMCACHED_MEMCACHED_ADD_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_add_start() +#define LIBMEMCACHED_MEMCACHED_CONNECT_END() \ + __dtrace_libmemcached___memcached_connect_end() +#define LIBMEMCACHED_MEMCACHED_CONNECT_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_connect_end() +#define LIBMEMCACHED_MEMCACHED_CONNECT_START() \ + __dtrace_libmemcached___memcached_connect_start() +#define LIBMEMCACHED_MEMCACHED_CONNECT_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_connect_start() +#define LIBMEMCACHED_MEMCACHED_DECREMENT_END() \ + __dtrace_libmemcached___memcached_decrement_end() +#define LIBMEMCACHED_MEMCACHED_DECREMENT_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_decrement_end() +#define LIBMEMCACHED_MEMCACHED_DECREMENT_START() \ + __dtrace_libmemcached___memcached_decrement_start() +#define LIBMEMCACHED_MEMCACHED_DECREMENT_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_decrement_start() +#define LIBMEMCACHED_MEMCACHED_DELETE_END() \ + __dtrace_libmemcached___memcached_delete_end() +#define LIBMEMCACHED_MEMCACHED_DELETE_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_delete_end() +#define LIBMEMCACHED_MEMCACHED_DELETE_START() \ + __dtrace_libmemcached___memcached_delete_start() +#define LIBMEMCACHED_MEMCACHED_DELETE_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_delete_start() +#define LIBMEMCACHED_MEMCACHED_FLUSH_END() \ + __dtrace_libmemcached___memcached_flush_end() +#define LIBMEMCACHED_MEMCACHED_FLUSH_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_flush_end() +#define LIBMEMCACHED_MEMCACHED_FLUSH_START() \ + __dtrace_libmemcached___memcached_flush_start() +#define LIBMEMCACHED_MEMCACHED_FLUSH_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_flush_start() +#define LIBMEMCACHED_MEMCACHED_GET_END() \ + __dtrace_libmemcached___memcached_get_end() +#define LIBMEMCACHED_MEMCACHED_GET_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_get_end() +#define LIBMEMCACHED_MEMCACHED_GET_START() \ + __dtrace_libmemcached___memcached_get_start() +#define LIBMEMCACHED_MEMCACHED_GET_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_get_start() +#define LIBMEMCACHED_MEMCACHED_INCREMENT_END() \ + __dtrace_libmemcached___memcached_increment_end() +#define LIBMEMCACHED_MEMCACHED_INCREMENT_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_increment_end() +#define LIBMEMCACHED_MEMCACHED_INCREMENT_START() \ + __dtrace_libmemcached___memcached_increment_start() +#define LIBMEMCACHED_MEMCACHED_INCREMENT_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_increment_start() +#define LIBMEMCACHED_MEMCACHED_MGET_END() \ + __dtrace_libmemcached___memcached_mget_end() +#define LIBMEMCACHED_MEMCACHED_MGET_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_mget_end() +#define LIBMEMCACHED_MEMCACHED_MGET_START() \ + __dtrace_libmemcached___memcached_mget_start() +#define LIBMEMCACHED_MEMCACHED_MGET_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_mget_start() +#define LIBMEMCACHED_MEMCACHED_REPLACE_END() \ + __dtrace_libmemcached___memcached_replace_end() +#define LIBMEMCACHED_MEMCACHED_REPLACE_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_replace_end() +#define LIBMEMCACHED_MEMCACHED_REPLACE_START() \ + __dtrace_libmemcached___memcached_replace_start() +#define LIBMEMCACHED_MEMCACHED_REPLACE_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_replace_start() +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END() \ + __dtrace_libmemcached___memcached_server_add_end() +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_server_add_end() +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START() \ + __dtrace_libmemcached___memcached_server_add_start() +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_server_add_start() +#define LIBMEMCACHED_MEMCACHED_SET_END() \ + __dtrace_libmemcached___memcached_set_end() +#define LIBMEMCACHED_MEMCACHED_SET_END_ENABLED() \ + __dtraceenabled_libmemcached___memcached_set_end() +#define LIBMEMCACHED_MEMCACHED_SET_START() \ + __dtrace_libmemcached___memcached_set_start() +#define LIBMEMCACHED_MEMCACHED_SET_START_ENABLED() \ + __dtraceenabled_libmemcached___memcached_set_start() + + +extern void __dtrace_libmemcached___memcached_add_end(void); +extern int __dtraceenabled_libmemcached___memcached_add_end(void); +extern void __dtrace_libmemcached___memcached_add_start(void); +extern int __dtraceenabled_libmemcached___memcached_add_start(void); +extern void __dtrace_libmemcached___memcached_connect_end(void); +extern int __dtraceenabled_libmemcached___memcached_connect_end(void); +extern void __dtrace_libmemcached___memcached_connect_start(void); +extern int __dtraceenabled_libmemcached___memcached_connect_start(void); +extern void __dtrace_libmemcached___memcached_decrement_end(void); +extern int __dtraceenabled_libmemcached___memcached_decrement_end(void); +extern void __dtrace_libmemcached___memcached_decrement_start(void); +extern int __dtraceenabled_libmemcached___memcached_decrement_start(void); +extern void __dtrace_libmemcached___memcached_delete_end(void); +extern int __dtraceenabled_libmemcached___memcached_delete_end(void); +extern void __dtrace_libmemcached___memcached_delete_start(void); +extern int __dtraceenabled_libmemcached___memcached_delete_start(void); +extern void __dtrace_libmemcached___memcached_flush_end(void); +extern int __dtraceenabled_libmemcached___memcached_flush_end(void); +extern void __dtrace_libmemcached___memcached_flush_start(void); +extern int __dtraceenabled_libmemcached___memcached_flush_start(void); +extern void __dtrace_libmemcached___memcached_get_end(void); +extern int __dtraceenabled_libmemcached___memcached_get_end(void); +extern void __dtrace_libmemcached___memcached_get_start(void); +extern int __dtraceenabled_libmemcached___memcached_get_start(void); +extern void __dtrace_libmemcached___memcached_increment_end(void); +extern int __dtraceenabled_libmemcached___memcached_increment_end(void); +extern void __dtrace_libmemcached___memcached_increment_start(void); +extern int __dtraceenabled_libmemcached___memcached_increment_start(void); +extern void __dtrace_libmemcached___memcached_mget_end(void); +extern int __dtraceenabled_libmemcached___memcached_mget_end(void); +extern void __dtrace_libmemcached___memcached_mget_start(void); +extern int __dtraceenabled_libmemcached___memcached_mget_start(void); +extern void __dtrace_libmemcached___memcached_replace_end(void); +extern int __dtraceenabled_libmemcached___memcached_replace_end(void); +extern void __dtrace_libmemcached___memcached_replace_start(void); +extern int __dtraceenabled_libmemcached___memcached_replace_start(void); +extern void __dtrace_libmemcached___memcached_server_add_end(void); +extern int __dtraceenabled_libmemcached___memcached_server_add_end(void); +extern void __dtrace_libmemcached___memcached_server_add_start(void); +extern int __dtraceenabled_libmemcached___memcached_server_add_start(void); +extern void __dtrace_libmemcached___memcached_set_end(void); +extern int __dtraceenabled_libmemcached___memcached_set_end(void); +extern void __dtrace_libmemcached___memcached_set_start(void); +extern int __dtraceenabled_libmemcached___memcached_set_start(void); + +#else + +#define LIBMEMCACHED_MEMCACHED_ADD_END() +#define LIBMEMCACHED_MEMCACHED_ADD_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_ADD_START() +#define LIBMEMCACHED_MEMCACHED_ADD_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_CONNECT_END() +#define LIBMEMCACHED_MEMCACHED_CONNECT_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_CONNECT_START() +#define LIBMEMCACHED_MEMCACHED_CONNECT_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_DECREMENT_END() +#define LIBMEMCACHED_MEMCACHED_DECREMENT_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_DECREMENT_START() +#define LIBMEMCACHED_MEMCACHED_DECREMENT_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_DELETE_END() +#define LIBMEMCACHED_MEMCACHED_DELETE_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_DELETE_START() +#define LIBMEMCACHED_MEMCACHED_DELETE_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_FLUSH_END() +#define LIBMEMCACHED_MEMCACHED_FLUSH_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_FLUSH_START() +#define LIBMEMCACHED_MEMCACHED_FLUSH_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_GET_END() +#define LIBMEMCACHED_MEMCACHED_GET_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_GET_START() +#define LIBMEMCACHED_MEMCACHED_GET_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_INCREMENT_END() +#define LIBMEMCACHED_MEMCACHED_INCREMENT_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_INCREMENT_START() +#define LIBMEMCACHED_MEMCACHED_INCREMENT_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_MGET_END() +#define LIBMEMCACHED_MEMCACHED_MGET_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_MGET_START() +#define LIBMEMCACHED_MEMCACHED_MGET_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_REPLACE_END() +#define LIBMEMCACHED_MEMCACHED_REPLACE_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_REPLACE_START() +#define LIBMEMCACHED_MEMCACHED_REPLACE_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END() +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START() +#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_SET_END() +#define LIBMEMCACHED_MEMCACHED_SET_END_ENABLED() (0) +#define LIBMEMCACHED_MEMCACHED_SET_START() +#define LIBMEMCACHED_MEMCACHED_SET_START_ENABLED() (0) + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBMEMCACHED_PROBES_H */ diff --git a/lib/memcached.c b/lib/memcached.c index 8122e1e8..6cf81c73 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -1,7 +1,7 @@ /* Memcached library */ -#include +#include "common.h" memcached_st *memcached_init(memcached_st *ptr) { diff --git a/lib/memcached_auto.c b/lib/memcached_auto.c index aa7ce5df..e779f279 100644 --- a/lib/memcached_auto.c +++ b/lib/memcached_auto.c @@ -1,4 +1,4 @@ -#include +#include "common.h" static memcached_return memcached_auto(memcached_st *ptr, char *verb, @@ -56,7 +56,13 @@ memcached_return memcached_increment(memcached_st *ptr, unsigned int offset, unsigned int *value) { - return memcached_auto(ptr, "incr", key, key_length, offset, value); + memcached_return rc; + + LIBMEMCACHED_MEMCACHED_INCREMENT_START(); + rc= memcached_auto(ptr, "incr", key, key_length, offset, value); + LIBMEMCACHED_MEMCACHED_INCREMENT_END(); + + return rc; } memcached_return memcached_decrement(memcached_st *ptr, @@ -64,5 +70,11 @@ memcached_return memcached_decrement(memcached_st *ptr, unsigned int offset, unsigned int *value) { - return memcached_auto(ptr, "decr", key, key_length, offset, value); + memcached_return rc; + + LIBMEMCACHED_MEMCACHED_DECREMENT_START(); + rc= memcached_auto(ptr, "decr", key, key_length, offset, value); + LIBMEMCACHED_MEMCACHED_DECREMENT_END(); + + return rc; } diff --git a/lib/memcached_connect.c b/lib/memcached_connect.c index 899101a2..516b5db3 100644 --- a/lib/memcached_connect.c +++ b/lib/memcached_connect.c @@ -1,9 +1,10 @@ -#include +#include "common.h" memcached_return memcached_server_add(memcached_st *ptr, char *hostname, unsigned int port) { memcached_server_st *new_host_list; char *new_hostname; + LIBMEMCACHED_MEMCACHED_SERVER_ADD_START(); if (!port) port= MEMCACHED_DEFAULT_PORT; @@ -34,6 +35,8 @@ memcached_return memcached_server_add(memcached_st *ptr, char *hostname, unsigne ptr->hosts[ptr->number_of_hosts].fd= -1; ptr->number_of_hosts++; + LIBMEMCACHED_MEMCACHED_SERVER_ADD_END(); + return MEMCACHED_SUCCESS; } @@ -43,6 +46,8 @@ memcached_return memcached_connect(memcached_st *ptr) struct sockaddr_in localAddr, servAddr; struct hostent *h; + LIBMEMCACHED_MEMCACHED_CONNECT_START(); + if (ptr->connected == ptr->number_of_hosts) return MEMCACHED_SUCCESS; @@ -82,6 +87,7 @@ memcached_return memcached_connect(memcached_st *ptr) ptr->connected++; } } + LIBMEMCACHED_MEMCACHED_CONNECT_END(); return MEMCACHED_SUCCESS; } diff --git a/lib/memcached_delete.c b/lib/memcached_delete.c index 8af15424..5ec5d1b4 100644 --- a/lib/memcached_delete.c +++ b/lib/memcached_delete.c @@ -1,4 +1,4 @@ -#include +#include "common.h" memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length, time_t expiration) @@ -8,6 +8,8 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_lengt char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unsigned int server_key; + LIBMEMCACHED_MEMCACHED_DELETE_START(); + rc= memcached_connect(ptr); if (rc != MEMCACHED_SUCCESS) @@ -31,5 +33,8 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_lengt if (sent_length == -1 || sent_length != send_length) return MEMCACHED_WRITE_FAILURE; - return memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, server_key); + rc= memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, server_key); + LIBMEMCACHED_MEMCACHED_DELETE_END(); + + return rc; } diff --git a/lib/memcached_flush.c b/lib/memcached_flush.c index 209a7e0f..96735462 100644 --- a/lib/memcached_flush.c +++ b/lib/memcached_flush.c @@ -1,4 +1,4 @@ -#include +#include "common.h" memcached_return memcached_flush(memcached_st *ptr, time_t expiration) { @@ -6,6 +6,7 @@ memcached_return memcached_flush(memcached_st *ptr, time_t expiration) size_t send_length, sent_length; memcached_return rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; + LIBMEMCACHED_MEMCACHED_FLUSH_START(); rc= memcached_connect(ptr); @@ -36,5 +37,6 @@ memcached_return memcached_flush(memcached_st *ptr, time_t expiration) rc= MEMCACHED_SOME_ERRORS; } + LIBMEMCACHED_MEMCACHED_FLUSH_END(); return rc; } diff --git a/lib/memcached_get.c b/lib/memcached_get.c index 0b775d3d..5bef0c04 100644 --- a/lib/memcached_get.c +++ b/lib/memcached_get.c @@ -1,4 +1,4 @@ -#include +#include "common.h" static char *memcached_value_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, @@ -128,6 +128,8 @@ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, size_t send_length; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unsigned int server_key; + char *value; + LIBMEMCACHED_MEMCACHED_GET_START(); *value_length= 0; *error= memcached_connect(ptr); @@ -148,8 +150,11 @@ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, return NULL; } - return memcached_value_fetch(ptr, key, &key_length, value_length, flags, + value= memcached_value_fetch(ptr, key, &key_length, value_length, flags, error, 0, server_key); + LIBMEMCACHED_MEMCACHED_GET_END(); + + return value; } memcached_return memcached_mget(memcached_st *ptr, @@ -160,6 +165,7 @@ memcached_return memcached_mget(memcached_st *ptr, unsigned int x; memcached_return rc; memcached_string_st **cursor_key_exec; + LIBMEMCACHED_MEMCACHED_MGET_START(); ptr->cursor_server= 0; memset(buffer, 0, HUGE_STRING_LEN); @@ -225,6 +231,7 @@ memcached_return memcached_mget(memcached_st *ptr, free(cursor_key_exec); + LIBMEMCACHED_MEMCACHED_MGET_END(); return rc; } diff --git a/lib/memcached_hash.c b/lib/memcached_hash.c index 74cd6360..3e5eddfe 100644 --- a/lib/memcached_hash.c +++ b/lib/memcached_hash.c @@ -1,4 +1,4 @@ -#include +#include "common.h" unsigned int memcached_generate_hash(char *key, size_t key_length) { diff --git a/lib/memcached_quit.c b/lib/memcached_quit.c index 8481b990..89a55ecf 100644 --- a/lib/memcached_quit.c +++ b/lib/memcached_quit.c @@ -1,4 +1,4 @@ -#include +#include "common.h" /* This closes all connections (forces flush of input as well). diff --git a/lib/memcached_response.c b/lib/memcached_response.c index ce129aee..12763513 100644 --- a/lib/memcached_response.c +++ b/lib/memcached_response.c @@ -5,7 +5,7 @@ from an issued command. */ -#include +#include "common.h" memcached_return memcached_response(memcached_st *ptr, char *buffer, size_t buffer_length, diff --git a/lib/memcached_stats.c b/lib/memcached_stats.c index 717ca455..1e3c425b 100644 --- a/lib/memcached_stats.c +++ b/lib/memcached_stats.c @@ -1,7 +1,7 @@ /* */ -#include +#include "common.h" static char *memcached_stat_keys[] = { "pid", @@ -338,6 +338,8 @@ char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat, { char **list= (char **)malloc(sizeof(memcached_stat_keys)); + memset(list, 0, sizeof(memcached_stat_keys)); + if (!list) { *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index 499fb7c8..da5a9ac6 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -7,7 +7,7 @@ */ -#include +#include "common.h" static memcached_return memcached_send(memcached_st *ptr, char *key, size_t key_length, @@ -64,8 +64,12 @@ memcached_return memcached_set(memcached_st *ptr, char *key, size_t key_length, time_t expiration, uint16_t flags) { - return memcached_send(ptr, key, key_length, value, value_length, + memcached_return rc; + LIBMEMCACHED_MEMCACHED_SET_START(); + rc= memcached_send(ptr, key, key_length, value, value_length, expiration, flags, "set"); + LIBMEMCACHED_MEMCACHED_SET_END(); + return rc; } memcached_return memcached_add(memcached_st *ptr, char *key, size_t key_length, @@ -73,8 +77,12 @@ memcached_return memcached_add(memcached_st *ptr, char *key, size_t key_length, time_t expiration, uint16_t flags) { - return memcached_send(ptr, key, key_length, value, value_length, + memcached_return rc; + LIBMEMCACHED_MEMCACHED_ADD_START(); + rc= memcached_send(ptr, key, key_length, value, value_length, expiration, flags, "add"); + LIBMEMCACHED_MEMCACHED_ADD_END(); + return rc; } memcached_return memcached_replace(memcached_st *ptr, char *key, size_t key_length, @@ -82,6 +90,10 @@ memcached_return memcached_replace(memcached_st *ptr, char *key, size_t key_leng time_t expiration, uint16_t flags) { - return memcached_send(ptr, key, key_length, value, value_length, + memcached_return rc; + LIBMEMCACHED_MEMCACHED_REPLACE_START(); + rc= memcached_send(ptr, key, key_length, value, value_length, expiration, flags, "replace"); + LIBMEMCACHED_MEMCACHED_REPLACE_END(); + return rc; } diff --git a/lib/memcached_strerror.c b/lib/memcached_strerror.c index 854df8b9..f987b3cc 100644 --- a/lib/memcached_strerror.c +++ b/lib/memcached_strerror.c @@ -1,4 +1,4 @@ -#include +#include "common.h" char *memcached_strerror(memcached_st *ptr, memcached_return rc) { diff --git a/lib/memcached_string.c b/lib/memcached_string.c index 5e4f9016..63ffb59a 100644 --- a/lib/memcached_string.c +++ b/lib/memcached_string.c @@ -1,4 +1,4 @@ -#include +#include "common.h" memcached_return memcached_string_check(memcached_string_st *string, size_t need) { diff --git a/lib/memcached_verbosity.c b/lib/memcached_verbosity.c index c60e7b22..0be5fd4b 100644 --- a/lib/memcached_verbosity.c +++ b/lib/memcached_verbosity.c @@ -1,4 +1,4 @@ -#include +#include "common.h" memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity) { diff --git a/src/memcat.c b/src/memcat.c index d263e60d..05011c0a 100644 --- a/src/memcat.c +++ b/src/memcat.c @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) free(opt_servers); return 0; -}; +} void options_parse(int argc, char *argv[]) diff --git a/tests/test.c b/tests/test.c index abd4c8ae..d457cf50 100644 --- a/tests/test.c +++ b/tests/test.c @@ -29,7 +29,7 @@ void connection_test(void) memcached_st *memc; memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); assert(memc); memcached_deinit(memc); @@ -59,7 +59,7 @@ void set_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), value, strlen(value), @@ -78,7 +78,7 @@ void add_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_add(memc, key, strlen(key), value, strlen(value), @@ -97,7 +97,7 @@ void replace_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_replace(memc, key, strlen(key), value, strlen(value), @@ -116,7 +116,7 @@ void delete_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), value, strlen(value), @@ -136,7 +136,7 @@ void flush_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_flush(memc, 0); assert(rc == MEMCACHED_SUCCESS); @@ -155,7 +155,7 @@ void get_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); string= memcached_get(memc, key, strlen(key), @@ -180,7 +180,7 @@ void get_test2(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), @@ -221,7 +221,7 @@ void get_test3(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), @@ -248,7 +248,7 @@ void stats_servername_test(void) memcached_return rc; memcached_stat_st stat; rc= memcached_stat_servername(&stat, NULL, - "zim.tangent.org", + "localhost", MEMCACHED_DEFAULT_PORT); } @@ -262,7 +262,7 @@ void increment_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), @@ -293,7 +293,7 @@ void decrement_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), @@ -323,7 +323,7 @@ void quit_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); rc= memcached_set(memc, key, strlen(key), @@ -356,7 +356,7 @@ void mget_test(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); /* We need to empty the server before continueing test */ @@ -432,7 +432,7 @@ void get_stats(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); stat= memcached_stat(memc, NULL, &rc); @@ -466,9 +466,9 @@ void get_stats_multiple(void) memc= memcached_init(NULL); assert(memc); - rc= memcached_server_add(memc, "zim.tangent.org", 0); + rc= memcached_server_add(memc, "localhost", 0); assert(rc == MEMCACHED_SUCCESS); - rc= memcached_server_add(memc, "zim.tangent.org", 5555); + rc= memcached_server_add(memc, "localhost", 5555); assert(rc == MEMCACHED_SUCCESS); stat= memcached_stat(memc, NULL, &rc);