diff options
author | Brian Aker <brian@tangent.org> | 2010-09-14 17:44:32 -0700 |
---|---|---|
committer | Brian Aker <brian@tangent.org> | 2010-09-14 17:44:32 -0700 |
commit | 3fca91c00a13fa7d6650bfe65aabf074fa5579b5 (patch) | |
tree | 3feff7a04209b21d5b5b03b1d76ae61e8568ca70 | |
parent | 3e49b97973fffed605aaa7a706c3ea0e23963ac2 (diff) | |
parent | e17d20233058cc5a918c134669df0e81ee56640e (diff) | |
download | libmemcached-3fca91c00a13fa7d6650bfe65aabf074fa5579b5.tar.gz |
Merge Trond
-rw-r--r-- | .bzrignore | 1 | ||||
-rw-r--r-- | clients/memcapable.c | 56 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | libhashkit/common.h | 8 | ||||
-rw-r--r-- | libmemcached/auto.c | 6 | ||||
-rw-r--r-- | libmemcached/connect.c | 3 | ||||
-rw-r--r-- | libmemcached/delete.c | 4 | ||||
-rw-r--r-- | libmemcached/do.c | 6 | ||||
-rw-r--r-- | libmemcached/do.h | 4 | ||||
-rw-r--r-- | libmemcached/get.c | 24 | ||||
-rw-r--r-- | libmemcached/include.am | 2 | ||||
-rw-r--r-- | libmemcached/io.c | 2 | ||||
-rw-r--r-- | libmemcached/io.h | 4 | ||||
-rw-r--r-- | libmemcached/memcached.c | 7 | ||||
-rw-r--r-- | libmemcached/memcached.h | 2 | ||||
-rw-r--r-- | libmemcached/sasl.c | 95 | ||||
-rw-r--r-- | libmemcached/stats.c | 6 | ||||
-rw-r--r-- | libmemcached/storage.c | 8 | ||||
-rw-r--r-- | libmemcached/watchpoint.h | 21 | ||||
-rw-r--r-- | tests/include.am | 6 |
20 files changed, 157 insertions, 110 deletions
@@ -72,6 +72,7 @@ libmemcached-0.37-1.x86_64.rpm libmemcached-?.??/ libmemcached.pop libmemcached/configure.h +libmemcached/dtrace_probes.h libmemcached/memcached_configure.h libmemcached_examples.pop libmemcachedutil.pop diff --git a/clients/memcapable.c b/clients/memcapable.c index 25278617..6ef5bc69 100644 --- a/clients/memcapable.c +++ b/clients/memcapable.c @@ -303,6 +303,7 @@ static enum test_return retry_read(void *buf, size_t len) ssize_t nr= timeout_io_op(sock, POLLIN, ((char*) buf) + offset, len - offset); switch (nr) { case -1 : + fprintf(stderr, "Errno: %d %s\n", get_socket_errno(), strerror(errno)); verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN); break; case 0: @@ -321,7 +322,7 @@ static enum test_return retry_read(void *buf, size_t len) */ static enum test_return recv_packet(response *rsp) { - execute(retry_read(rsp, sizeof (protocol_binary_response_no_extras))); + execute(retry_read(rsp, sizeof(protocol_binary_response_no_extras))); /* Fix the byte order in the packet header */ rsp->plain.message.header.response.keylen= @@ -693,10 +694,12 @@ static enum test_return test_binary_set_impl(const char* key, uint8_t cc) cmd.plain.message.header.request.cas= htonll(rsp.plain.message.header.response.cas - 1); execute(resend_packet(&cmd)); + execute(send_binary_noop()); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS)); + execute(receive_binary_noop()); - return test_binary_noop(); + return TEST_PASS; } static enum test_return test_binary_set(void) @@ -733,7 +736,9 @@ static enum test_return test_binary_add_impl(const char* key, uint8_t cc) else expected_result= PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS; + execute(send_binary_noop()); execute(recv_packet(&rsp)); + execute(receive_binary_noop()); verify(validate_response_header(&rsp, cc, expected_result)); } else @@ -790,7 +795,9 @@ static enum test_return test_binary_replace_impl(const char* key, uint8_t cc) else expected_result=PROTOCOL_BINARY_RESPONSE_SUCCESS; + execute(send_binary_noop()); execute(recv_packet(&rsp)); + execute(receive_binary_noop()); verify(validate_response_header(&rsp, cc, expected_result)); if (ii == 0) @@ -817,7 +824,9 @@ static enum test_return test_binary_replace_impl(const char* key, uint8_t cc) cmd.plain.message.header.request.cas= htonll(rsp.plain.message.header.response.cas - 1); execute(resend_packet(&cmd)); + execute(send_binary_noop()); execute(recv_packet(&rsp)); + execute(receive_binary_noop()); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS)); return TEST_PASS; @@ -841,8 +850,10 @@ static enum test_return test_binary_delete_impl(const char *key, uint8_t cc) /* The delete shouldn't work the first time, because the item isn't there */ execute(send_packet(&cmd)); + execute(send_binary_noop()); execute(recv_packet(&rsp)); verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)); + execute(receive_binary_noop()); execute(binary_set_item(key, key)); /* The item should be present now, resend*/ @@ -1869,8 +1880,10 @@ int main(int argc, char **argv) const char *hostname= "localhost"; const char *port= "11211"; int cmd; + bool prompt= false; + const char *testname= NULL; - while ((cmd= getopt(argc, argv, "t:vch:p:?")) != EOF) + while ((cmd= getopt(argc, argv, "t:vch:p:PT:?")) != EOF) { switch (cmd) { case 't': @@ -1889,11 +1902,21 @@ int main(int argc, char **argv) break; case 'p': port= optarg; break; + case 'P': prompt= true; + break; + case 'T': testname= optarg; + break; default: - fprintf(stderr, "Usage: %s [-h hostname] [-p port] [-c] [-v] [-t n]\n" + fprintf(stderr, "Usage: %s [-h hostname] [-p port] [-c] [-v] [-t n]" + " [-P] [-T testname]'\n" "\t-c\tGenerate coredump if a test fails\n" "\t-v\tVerbose test output (print out the assertion)\n" - "\t-t n\tSet the timeout for io-operations to n seconds\n", + "\t-t n\tSet the timeout for io-operations to n seconds\n" + "\t-P\tPrompt the user before starting a test.\n" + "\t\t\t\"skip\" will skip the test\n" + "\t\t\t\"quit\" will terminate memcapable\n" + "\t\t\tEverything else will start the test\n" + "\t-T n\tJust run the test named n\n", argv[0]); return 1; } @@ -1910,10 +1933,33 @@ int main(int argc, char **argv) for (int ii= 0; testcases[ii].description != NULL; ++ii) { + if (testname != NULL && strcmp(testcases[ii].description, testname) != 0) + continue; + ++total; fprintf(stdout, "%-40s", testcases[ii].description); fflush(stdout); + if (prompt) + { + fprintf(stdout, "\nPress <return> when you are ready? "); + char buffer[80] = {0}; + if (fgets(buffer, sizeof(buffer), stdin) != NULL) { + if (strncmp(buffer, "skip", 4) == 0) + { + fprintf(stdout, "%-40s%s\n", testcases[ii].description, + status_msg[TEST_SKIP]); + fflush(stdout); + continue; + } + if (strncmp(buffer, "quit", 4) == 0) + exit(0); + } + + fprintf(stdout, "%-40s", testcases[ii].description); + fflush(stdout); + } + bool reconnect= false; enum test_return ret= testcases[ii].function(); if (ret == TEST_FAIL) diff --git a/configure.ac b/configure.ac index a2faafd6..4137fb4d 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ PANDORA_CANONICAL_TARGET #shared library versioning MEMCACHED_UTIL_LIBRARY_VERSION=1:0:0 MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0 -MEMCACHED_LIBRARY_VERSION=5:2:0 +MEMCACHED_LIBRARY_VERSION=6:0:0 # | | | # +------+ | +---+ # | | | diff --git a/libhashkit/common.h b/libhashkit/common.h index b2aaf0e2..dff3ab0b 100644 --- a/libhashkit/common.h +++ b/libhashkit/common.h @@ -9,10 +9,6 @@ #ifndef HASHKIT_COMMON_H #define HASHKIT_COMMON_H -#ifdef __cplusplus -extern "C" { -#endif - #include "config.h" #include <assert.h> @@ -23,6 +19,10 @@ extern "C" { #include "hashkit.h" +#ifdef __cplusplus +extern "C" { +#endif + HASHKIT_LOCAL void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result); diff --git a/libmemcached/auto.c b/libmemcached/auto.c index b73425f0..ce2d0261 100644 --- a/libmemcached/auto.c +++ b/libmemcached/auto.c @@ -60,7 +60,7 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, { *value= 0; rc= MEMCACHED_PROTOCOL_ERROR; - } + } else if (! strncmp(buffer, "CLIENT_ERROR\r\n", 14)) { *value= 0; @@ -116,12 +116,12 @@ static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd, request.message.body.initial= htonll(initial); request.message.body.expiration= htonl((uint32_t) expiration); - struct __write_vector_st vector[]= + struct libmemcached_io_vector_st vector[]= { { .length= sizeof(request.bytes), .buffer= request.bytes }, { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, { .length= key_length, .buffer= key } - }; + }; memcached_return_t rc; if ((rc= memcached_vdo(instance, vector, 3, true)) != MEMCACHED_SUCCESS) diff --git a/libmemcached/connect.c b/libmemcached/connect.c index 7b38def9..c4b263e1 100644 --- a/libmemcached/connect.c +++ b/libmemcached/connect.c @@ -80,7 +80,6 @@ static memcached_return_t connect_poll(memcached_server_st *ptr) return MEMCACHED_ERRNO; } } - WATCHPOINT_ASSERT(0); // Programming error } // This should only be possible from ERESTART or EINTR; @@ -537,7 +536,7 @@ memcached_return_t memcached_connect(memcached_server_write_instance_st ptr) case MEMCACHED_CONNECTION_TCP: rc= network_connect(ptr); #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT - if (ptr->fd != INVALID_SOCKET && ptr->root->sasl && ptr->root->sasl->callbacks) + if (ptr->fd != INVALID_SOCKET && ptr->root->sasl.callbacks) { rc= memcached_sasl_authenticate_connection(ptr); if (rc != MEMCACHED_SUCCESS) diff --git a/libmemcached/delete.c b/libmemcached/delete.c index 70553d94..84a34271 100644 --- a/libmemcached/delete.c +++ b/libmemcached/delete.c @@ -175,12 +175,12 @@ static inline memcached_return_t binary_delete(memcached_st *ptr, memcached_io_write(instance, NULL, 0, true); } - struct __write_vector_st vector[]= + struct libmemcached_io_vector_st vector[]= { { .length= sizeof(request.bytes), .buffer= request.bytes}, { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, { .length= key_length, .buffer= key }, - }; + }; memcached_return_t rc= MEMCACHED_SUCCESS; diff --git a/libmemcached/do.c b/libmemcached/do.c index 1a274cd3..14824a64 100644 --- a/libmemcached/do.c +++ b/libmemcached/do.c @@ -5,13 +5,13 @@ * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * - * Summary: + * Summary: * */ #include "common.h" -memcached_return_t memcached_do(memcached_server_write_instance_st ptr, const void *command, +memcached_return_t memcached_do(memcached_server_write_instance_st ptr, const void *command, size_t command_length, bool with_flush) { memcached_return_t rc; @@ -51,7 +51,7 @@ memcached_return_t memcached_do(memcached_server_write_instance_st ptr, const vo } memcached_return_t memcached_vdo(memcached_server_write_instance_st ptr, - const struct __write_vector_st *vector, size_t count, + const struct libmemcached_io_vector_st *vector, size_t count, bool with_flush) { memcached_return_t rc; diff --git a/libmemcached/do.h b/libmemcached/do.h index d6d018d9..2506ddf2 100644 --- a/libmemcached/do.h +++ b/libmemcached/do.h @@ -17,14 +17,14 @@ extern "C" { #endif LIBMEMCACHED_LOCAL -memcached_return_t memcached_do(memcached_server_write_instance_st ptr, +memcached_return_t memcached_do(memcached_server_write_instance_st ptr, const void *commmand, size_t command_length, bool with_flush); LIBMEMCACHED_LOCAL memcached_return_t memcached_vdo(memcached_server_write_instance_st ptr, - const struct __write_vector_st *vector, size_t count, + const struct libmemcached_io_vector_st *vector, size_t count, bool with_flush); #ifdef __cplusplus diff --git a/libmemcached/get.c b/libmemcached/get.c index 55457f7f..8d76507c 100644 --- a/libmemcached/get.c +++ b/libmemcached/get.c @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See @@ -227,13 +227,13 @@ static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, instance= memcached_server_instance_fetch(ptr, server_key); - struct __write_vector_st vector[]= - { - { .length= get_command_length, .buffer= get_command }, - { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, - { .length= key_length[x], .buffer= keys[x] }, - { .length= 1, .buffer= " " } - }; + struct libmemcached_io_vector_st vector[]= + { + { .length= get_command_length, .buffer= get_command }, + { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, + { .length= key_length[x], .buffer= keys[x] }, + { .length= 1, .buffer= " " } + }; if (memcached_server_response_count(instance) == 0) @@ -399,12 +399,12 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr, request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; request.message.header.request.bodylen= htonl((uint32_t)( key_length[x] + ptr->prefix_key_length)); - struct __write_vector_st vector[]= + struct libmemcached_io_vector_st vector[]= { { .length= sizeof(request.bytes), .buffer= request.bytes }, { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, { .length= key_length[x], .buffer= keys[x] } - }; + }; if (memcached_io_writev(instance, vector, 3, flush) == -1) { @@ -533,12 +533,12 @@ static memcached_return_t replication_binary_mget(memcached_st *ptr, * that we might have processed some of the responses etc. For now, * just make sure we work _correctly_ */ - struct __write_vector_st vector[]= + struct libmemcached_io_vector_st vector[]= { { .length= sizeof(request.bytes), .buffer= request.bytes }, { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, { .length= key_length[x], .buffer= keys[x] } - }; + }; if (memcached_io_writev(instance, vector, 3, true) == -1) { diff --git a/libmemcached/include.am b/libmemcached/include.am index fccced99..c348cb3d 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -172,5 +172,5 @@ libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_la_OBJECTS} config.h .d.o: - $(DTRACE) $(DTRACEFLAGS) -o libmemcached/libmemcached_probes.o -G -s ${top_srcdir}/libmemcached/libmemcached_probes.d `grep '^pic_object' ${top_builddir}/libmemcached/*.lo | cut -f 2 -d\' | sed "s/^/${top_builddir}\//"` + $(DTRACE) $(DTRACEFLAGS) -o libmemcached/libmemcached_probes.o -G -s ${top_srcdir}/libmemcached/libmemcached_probes.d `grep '^pic_object' ${top_builddir}/libmemcached/*.lo | cut -f 2 -d\' | sed "s/^/${top_builddir}\/libmemcached\//"` diff --git a/libmemcached/io.c b/libmemcached/io.c index 299242f6..bc74af7d 100644 --- a/libmemcached/io.c +++ b/libmemcached/io.c @@ -440,7 +440,7 @@ ssize_t memcached_io_write(memcached_server_write_instance_st ptr, } ssize_t memcached_io_writev(memcached_server_write_instance_st ptr, - const struct __write_vector_st *vector, + const struct libmemcached_io_vector_st *vector, size_t number_of, bool with_flush) { ssize_t total= 0; diff --git a/libmemcached/io.h b/libmemcached/io.h index 30145823..9d5087e0 100644 --- a/libmemcached/io.h +++ b/libmemcached/io.h @@ -40,7 +40,7 @@ struct udp_datagram_header_st uint16_t reserved; }; -struct __write_vector_st +struct libmemcached_io_vector_st { size_t length; const void *buffer; @@ -48,7 +48,7 @@ struct __write_vector_st LIBMEMCACHED_LOCAL ssize_t memcached_io_writev(memcached_server_write_instance_st ptr, - const struct __write_vector_st *vector, + const struct libmemcached_io_vector_st *vector, size_t number_of, bool with_flush); LIBMEMCACHED_LOCAL diff --git a/libmemcached/memcached.c b/libmemcached/memcached.c index d5411e86..81895afa 100644 --- a/libmemcached/memcached.c +++ b/libmemcached/memcached.c @@ -92,7 +92,8 @@ static inline bool _memcached_init(memcached_st *self) self->get_key_failure= NULL; self->delete_trigger= NULL; self->callbacks= NULL; - self->sasl= NULL; + self->sasl.callbacks= NULL; + self->sasl.is_allocated= false; return true; } @@ -176,7 +177,7 @@ void memcached_free(memcached_st *ptr) if (ptr->continuum) libmemcached_free(ptr, ptr->continuum); - if (ptr->sasl) + if (ptr->sasl.callbacks) { #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT memcached_destroy_sasl_auth_data(ptr); @@ -273,7 +274,7 @@ memcached_st *memcached_clone(memcached_st *clone, const memcached_st *source) } #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT - if (source->sasl && source->sasl->callbacks) + if (source->sasl.callbacks) { if (memcached_clone_sasl(new_clone, source) != MEMCACHED_SUCCESS) { diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 58f9f673..c099d76e 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -124,7 +124,7 @@ struct memcached_st { memcached_trigger_key_fn get_key_failure; memcached_trigger_delete_key_fn delete_trigger; memcached_callback_st *callbacks; - struct memcached_sasl_st *sasl; + struct memcached_sasl_st sasl; char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE]; struct { bool is_allocated:1; diff --git a/libmemcached/sasl.c b/libmemcached/sasl.c index 85edeb3d..ef52c7c3 100644 --- a/libmemcached/sasl.c +++ b/libmemcached/sasl.c @@ -14,16 +14,13 @@ void memcached_set_sasl_callbacks(memcached_st *ptr, const sasl_callback_t *callbacks) { - ptr->sasl->callbacks= callbacks; - ptr->sasl->is_allocated= false; + ptr->sasl.callbacks= callbacks; + ptr->sasl.is_allocated= false; } const sasl_callback_t *memcached_get_sasl_callbacks(memcached_st *ptr) { - if (ptr->sasl) - return ptr->sasl->callbacks; - - return NULL; + return ptr->sasl.callbacks; } /** @@ -119,7 +116,7 @@ memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *s sasl_conn_t *conn; int ret= sasl_client_new("memcached", server->hostname, laddr, raddr, - server->root->sasl->callbacks, 0, &conn); + server->root->sasl.callbacks, 0, &conn); if (ret != SASL_OK) { return MEMCACHED_AUTH_PROBLEM; @@ -144,12 +141,12 @@ memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *s do { /* send the packet */ - struct __write_vector_st vector[]= - { - { .length= sizeof(request.bytes), .buffer= request.bytes }, - { .length= keylen, .buffer= chosenmech }, - { .length= len, .buffer= data } - }; + struct libmemcached_io_vector_st vector[]= + { + { .length= sizeof(request.bytes), .buffer= request.bytes }, + { .length= keylen, .buffer= chosenmech }, + { .length= len, .buffer= data } + }; if (memcached_io_writev(server, vector, 3, true) == -1) { @@ -221,7 +218,7 @@ memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, const char *password) { if (ptr == NULL || username == NULL || - password == NULL || ptr->sasl->callbacks != NULL) + password == NULL || ptr->sasl.callbacks != NULL) { return MEMCACHED_FAILURE; } @@ -252,62 +249,52 @@ memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, cb[2].context= secret; cb[3].id= SASL_CB_LIST_END; - ptr->sasl->callbacks= cb; - ptr->sasl->is_allocated= true; + ptr->sasl.callbacks= cb; + ptr->sasl.is_allocated= true; return MEMCACHED_SUCCESS; } memcached_return_t memcached_destroy_sasl_auth_data(memcached_st *ptr) { - if (ptr == NULL || ptr->sasl->callbacks == NULL) + if (ptr == NULL || ptr->sasl.callbacks == NULL) { return MEMCACHED_FAILURE; } - if (ptr->sasl->is_allocated) + if (ptr->sasl.is_allocated) { - libmemcached_free(ptr, ptr->sasl->callbacks[0].context); - libmemcached_free(ptr, ptr->sasl->callbacks[2].context); - libmemcached_free(ptr, (void*)ptr->sasl->callbacks); - ptr->sasl->is_allocated= false; + libmemcached_free(ptr, ptr->sasl.callbacks[0].context); + libmemcached_free(ptr, ptr->sasl.callbacks[2].context); + libmemcached_free(ptr, (void*)ptr->sasl.callbacks); + ptr->sasl.is_allocated= false; } - ptr->sasl->callbacks= NULL; - libmemcached_free(ptr, ptr->sasl); - ptr->sasl= NULL; + ptr->sasl.callbacks= NULL; return MEMCACHED_SUCCESS; } memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st *source) { - if (source->sasl == NULL) + + if (source->sasl.callbacks == NULL) { return MEMCACHED_SUCCESS; } - else - { - clone->sasl= libmemcached_malloc(source, sizeof(struct memcached_sasl_st)); - - if (clone->sasl == NULL) - { - return MEMCACHED_MEMORY_ALLOCATION_FAILURE; - } - } /* Hopefully we are using our own callback mechanisms.. */ - if (source->sasl->callbacks[0].id == SASL_CB_USER && - source->sasl->callbacks[0].proc == get_username && - source->sasl->callbacks[1].id == SASL_CB_AUTHNAME && - source->sasl->callbacks[1].proc == get_username && - source->sasl->callbacks[2].id == SASL_CB_PASS && - source->sasl->callbacks[2].proc == get_password && - source->sasl->callbacks[3].id == SASL_CB_LIST_END) + if (source->sasl.callbacks[0].id == SASL_CB_USER && + source->sasl.callbacks[0].proc == get_username && + source->sasl.callbacks[1].id == SASL_CB_AUTHNAME && + source->sasl.callbacks[1].proc == get_username && + source->sasl.callbacks[2].id == SASL_CB_PASS && + source->sasl.callbacks[2].proc == get_password && + source->sasl.callbacks[3].id == SASL_CB_LIST_END) { - sasl_secret_t *secret= source->sasl->callbacks[2].context; + sasl_secret_t *secret= source->sasl.callbacks[2].context; return memcached_set_sasl_auth_data(clone, - source->sasl->callbacks[0].context, + source->sasl.callbacks[0].context, (const char*)secret->data); } @@ -318,9 +305,9 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st */ size_t total= 0; - while (source->sasl->callbacks[total].id != SASL_CB_LIST_END) + while (source->sasl.callbacks[total].id != SASL_CB_LIST_END) { - switch (source->sasl->callbacks[total].id) + switch (source->sasl.callbacks[total].id) { case SASL_CB_USER: case SASL_CB_AUTHNAME: @@ -339,38 +326,38 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } - memcpy(cb, source->sasl->callbacks, (total + 1) * sizeof(sasl_callback_t)); + memcpy(cb, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t)); /* Now update the context... */ for (size_t x= 0; x < total; ++x) { if (cb[x].id == SASL_CB_USER || cb[x].id == SASL_CB_AUTHNAME) { - cb[x].context= libmemcached_malloc(clone, strlen(source->sasl->callbacks[x].context)); + cb[x].context= libmemcached_malloc(clone, strlen(source->sasl.callbacks[x].context)); if (cb[x].context == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ for (size_t y= 0; y < x; ++y) { - libmemcached_free(clone, clone->sasl->callbacks[y].context); + libmemcached_free(clone, clone->sasl.callbacks[y].context); } libmemcached_free(clone, cb); return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } - strcpy(cb[x].context, source->sasl->callbacks[x].context); + strcpy(cb[x].context, source->sasl.callbacks[x].context); } else { - sasl_secret_t *src = source->sasl->callbacks[x].context; + sasl_secret_t *src = source->sasl.callbacks[x].context; sasl_secret_t *n = libmemcached_malloc(clone, src->len + 1 + sizeof(*n)); if (n == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ for (size_t y= 0; y < x; ++y) { - libmemcached_free(clone, clone->sasl->callbacks[y].context); + libmemcached_free(clone, clone->sasl.callbacks[y].context); } libmemcached_free(clone, cb); @@ -381,8 +368,8 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st } } - clone->sasl->callbacks= cb; - clone->sasl->is_allocated= true; + clone->sasl.callbacks= cb; + clone->sasl.is_allocated= true; return MEMCACHED_SUCCESS; } diff --git a/libmemcached/stats.c b/libmemcached/stats.c index 731c1cc0..0c52d97a 100644 --- a/libmemcached/stats.c +++ b/libmemcached/stats.c @@ -258,11 +258,11 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, request.message.header.request.keylen= htons((uint16_t)len); request.message.header.request.bodylen= htonl((uint32_t) len); - struct __write_vector_st vector[]= + struct libmemcached_io_vector_st vector[]= { { .length= sizeof(request.bytes), .buffer= request.bytes }, { .length= len, .buffer= args } - }; + }; if (memcached_vdo(instance, vector, 2, true) != MEMCACHED_SUCCESS) { @@ -302,7 +302,7 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, WATCHPOINT_ASSERT(0); } } - + if (check && check->func) { size_t key_length= strlen(buffer); diff --git a/libmemcached/storage.c b/libmemcached/storage.c index dce5fec3..25aaba30 100644 --- a/libmemcached/storage.c +++ b/libmemcached/storage.c @@ -155,12 +155,12 @@ static inline memcached_return_t memcached_send(memcached_st *ptr, } else { - struct __write_vector_st vector[]= + struct libmemcached_io_vector_st vector[]= { { .length= write_length, .buffer= buffer }, { .length= value_length, .buffer= value }, { .length= 2, .buffer= "\r\n" } - }; + }; if (ptr->flags.buffer_requests && verb == SET_OP) { @@ -492,13 +492,13 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, } } - struct __write_vector_st vector[]= + struct libmemcached_io_vector_st vector[]= { { .length= send_length, .buffer= request.bytes }, { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, { .length= key_length, .buffer= key }, { .length= value_length, .buffer= value } - }; + }; /* write the header */ memcached_return_t rc; diff --git a/libmemcached/watchpoint.h b/libmemcached/watchpoint.h index 31d0a12b..fc25eb5c 100644 --- a/libmemcached/watchpoint.h +++ b/libmemcached/watchpoint.h @@ -16,7 +16,7 @@ #if defined(DEBUG) #ifdef TARGET_OS_LINUX -static inline void __stack_dump(void) +static inline void libmemcached_stack_dump(void) { void *array[10]; int size; @@ -35,12 +35,21 @@ static inline void __stack_dump(void) fflush(stderr); } +#elif defined(__sun) +#include <ucontext.h> + +static inline void libmemcached_stack_dump(void) +{ + fflush(stderr); + printstack(fileno(stderr)); +} + #else -static inline void __stack_dump(void) +static inline void libmemcached_stack_dump(void) { } -#endif // __stack_dump() +#endif // libmemcached_stack_dump() #include <assert.h> @@ -53,9 +62,9 @@ static inline void __stack_dump(void) #define WATCHPOINT_LABELED_NUMBER(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%zu\n", __FILE__, __LINE__,__func__,(A),(size_t)(B));fflush(stdout); } while (0) #define WATCHPOINT_IF_LABELED_NUMBER(A,B,C) do { if(A) {fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%zu\n", __FILE__, __LINE__,__func__,(B),(size_t)(C));fflush(stdout);} } while (0) #define WATCHPOINT_ERRNO(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout); } while (0) -#define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWATCHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, (B),(C));fprintf(stderr,"\n");fflush(stdout); __stack_dump(); } assert((A)); } while (0) -#define WATCHPOINT_ASSERT(A) do { if (! (A)) {__stack_dump();} assert((A)); } while (0) -#define WATCHPOINT_ASSERT_INITIALIZED(A) do { if (! (A)) { __stack_dump(); } assert(memcached_is_initialized((A))); } while (0); +#define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWATCHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, (B),(C));fprintf(stderr,"\n");fflush(stdout); libmemcached_stack_dump(); } assert((A)); } while (0) +#define WATCHPOINT_ASSERT(A) do { if (! (A)) {libmemcached_stack_dump();} assert((A)); } while (0) +#define WATCHPOINT_ASSERT_INITIALIZED(A) do { if (! (A)) { libmemcached_stack_dump(); } assert(memcached_is_initialized((A))); } while (0); #define WATCHPOINT_SET(A) do { A; } while(0); #else diff --git a/tests/include.am b/tests/include.am index 501939df..27a7bf51 100644 --- a/tests/include.am +++ b/tests/include.am @@ -47,7 +47,11 @@ tests_testapp_DEPENDENCIES= \ tests/libtest.la \ libmemcached/libmemcachedinternal.la \ $(TESTS_LDADDS) -tests_testapp_LDADD= $(tests_testapp_DEPENDENCIES) $(LIBSASL) +tests_testapp_LDADD= clients/libgenexec.la \ + tests/libserver.la \ + tests/libtest.la \ + libmemcached/libmemcachedinternal.la \ + $(TESTS_LDADDS) $(LIBSASL) tests_testplus_SOURCES= tests/plus.cpp tests_testplus_CXXFLAGS = $(AM_CXXFLAGS) $(NO_EFF_CXX) |