From: Brian Aker Date: Thu, 14 Apr 2011 04:24:05 +0000 (-0700) Subject: Update for deprecated functions. X-Git-Tag: 0.51~13^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=93e6d035437caee63345d1d9dcf2738e84456f9f;p=m6w6%2Flibmemcached Update for deprecated functions. --- diff --git a/docs/libmemcached.rst b/docs/libmemcached.rst index ddf3108e..f7202c43 100644 --- a/docs/libmemcached.rst +++ b/docs/libmemcached.rst @@ -138,12 +138,35 @@ SEE ALSO -------- -:manpage:`memcached(1)` :manpage:`libmemcached_examples(3)` :manpage:`libmemcached(1)` :manpage:`memcat(1)` :manpage:`memcp(1)` :manpage:`memflush(1)` :manpage:`memrm(1)` :manpage:`memslap(1)` :manpage:`memstat(1)` :manpage:`memcached_fetch(3)` :manpage:`memcached_replace(3)` :manpage:`memcached_server_list_free(3)` :manpage:`libmemcached_examples(3)` :manpage:`memcached_clone(3)` :manpage:`memcached_free(3)` -:manpage:`memcached_server_add(3)` :manpage:`memcached_server_push(3)` :manpage:`memcached_add(3)` :manpage:`memcached_get(3)` :manpage:`memcached_server_count(3)` :manpage:`memcached_servers_parse(3)` :manpage:`memcached_create(3)` :manpage:`memcached_increment(3)` :manpage:`memcached_server_list(3)` :manpage:`memcached_set(3)` -:manpage:`memcached_decrement(3)` :manpage:`memcached_mget(3)` :manpage:`memcached_server_list_append(3)` :manpage:`memcached_strerror(3)` :manpage:`memcached_delete(3)` :manpage:`memcached_quit(3)` :manpage:`memcached_server_list_count(3)` :manpage:`memcached_verbosity(3)` :manpage:`memcached_server_add_unix_socket(3)` :manpage:`memcached_result_create(3)` :manpage:`memcached_result_free(3)` -:manpage:`memcached_result_key_value(3)` :manpage:`memcached_result_key_length(3)` :manpage:`memcached_result_value(3)` :manpage:`memcached_result_length(3)` :manpage:`memcached_result_flags(3)` -:manpage:`memcached_result_cas(3)` :manpage:`memcached_result_st(3)` :manpage:`memcached_append(3)` :manpage:`memcached_prepend(3)` :manpage:`memcached_fetch_result(3)` -:manpage:`memerror(1)` :manpage:`memcached_get_by_key(3)` :manpage:`memcached_mget_by_key(3)` :manpage:`memcached_delete_by_key(3)` -:manpage:`memcached_fetch_execute(3)` :manpage:`memcached_callback_get(3)` :manpage:`memcached_callback_set(3)` :manpage:`memcached_version(3)` -:manpage:`memcached_lib_version(3)` :manpage:`memcached_result_set_value(3)` :manpage:`memcached_dump(3)` :manpage:`memdump(1)` -:manpage:`memcached_set_memory_allocators(3)` :manpage:`memcached_get_memory_allocators(3)` :manpage:`memcached_get_user_data(3)` :manpage:`memcached_set_user_data(3)` +:manpage:`memcached(1)` :manpage:`libmemcached_examples(3)` +:manpage:`libmemcached(1)` :manpage:`memcat(1)` :manpage:`memcp(1)` +:manpage:`memflush(1)` :manpage:`memrm(1)` :manpage:`memslap(1)` +:manpage:`memstat(1)` :manpage:`memcached_fetch(3)` +:manpage:`memcached_replace(3)` :manpage:`memcached_server_list_free(3)` +:manpage:`libmemcached_examples(3)` :manpage:`memcached_clone(3)` +:manpage:`memcached_free(3)` :manpage:`memcached_server_add(3)` +:manpage:`memcached_server_push(3)` :manpage:`memcached_add(3)` +:manpage:`memcached_get(3)` :manpage:`memcached_server_count(3)` +:manpage:`memcached_create(3)` :manpage:`memcached_increment(3)` +:manpage:`memcached_server_list(3)` :manpage:`memcached_set(3)` +:manpage:`memcached_decrement(3)` :manpage:`memcached_mget(3)` +:manpage:`memcached_server_list_append(3)` :manpage:`memcached_strerror(3)` +:manpage:`memcached_delete(3)` :manpage:`memcached_quit(3)` +:manpage:`memcached_server_list_count(3)` :manpage:`memcached_verbosity(3)` +:manpage:`memcached_server_add_unix_socket(3)` +:manpage:`memcached_result_create(3)` :manpage:`memcached_result_free(3)` +:manpage:`memcached_result_key_value(3)` +:manpage:`memcached_result_key_length(3)` +:manpage:`memcached_result_value(3)` :manpage:`memcached_result_length(3)` +:manpage:`memcached_result_flags(3)` :manpage:`memcached_result_cas(3)` +:manpage:`memcached_result_st(3)` :manpage:`memcached_append(3)` +:manpage:`memcached_prepend(3)` :manpage:`memcached_fetch_result(3)` +:manpage:`memerror(1)` :manpage:`memcached_get_by_key(3)` +:manpage:`memcached_mget_by_key(3)` :manpage:`memcached_delete_by_key(3)` +:manpage:`memcached_fetch_execute(3)` :manpage:`memcached_callback_get(3)` +:manpage:`memcached_callback_set(3)` :manpage:`memcached_version(3)` +:manpage:`memcached_lib_version(3)` :manpage:`memcached_result_set_value(3)` +:manpage:`memcached_dump(3)` :manpage:`memdump(1)` +:manpage:`memcached_set_memory_allocators(3)` +:manpage:`memcached_get_memory_allocators(3)` +:manpage:`memcached_get_user_data(3)` :manpage:`memcached_set_user_data(3)` diff --git a/docs/memcached_server_st.rst b/docs/memcached_server_st.rst index eff7bf92..7f419f26 100644 --- a/docs/memcached_server_st.rst +++ b/docs/memcached_server_st.rst @@ -3,16 +3,6 @@ Managing lists of servers ========================= -Manage server list - - -******* -LIBRARY -******* - - -C Client Library for memcached (libmemcached, -lmemcached) - -------- SYNOPSIS @@ -20,30 +10,22 @@ SYNOPSIS -.. code-block:: perl - - #include +#include - const memcached_server_instance_st - memcached_server_list (memcached_st *ptr); - - void memcached_server_list_free (memcached_server_list_st list); - - memcached_server_list_st - memcached_server_list_append (memcached_server_list_st list, - const char *hostname, - unsigned int port, - memcached_return_t *error); +.. c:function:: const memcached_server_instance_st memcached_server_list (memcached_st *ptr); + +.. c:function:: void memcached_server_list_free (memcached_server_list_st list); - uint32_t memcached_server_list_count (memcached_server_list_st list); +.. c:function:: memcached_server_list_st memcached_server_list_append (memcached_server_list_st list, const char *hostname, unsigned int port, memcached_return_t *error); - memcached_server_list_st memcached_servers_parse (const char *server_strings); +.. c:function:: uint32_t memcached_server_list_count (memcached_server_list_st list); - const char *memcached_server_error (memcached_server_instance_st instance); +.. c:function:: const char *memcached_server_error (memcached_server_instance_st instance); - DEPRECATED - void memcached_server_error_reset (memcached_server_instance_st list); +.. c:function:: void memcached_server_error_reset (memcached_server_instance_st list); DEPRECATED + +Compile and link with -lmemcached ----------- @@ -68,10 +50,7 @@ memcached_return_t pointer you passed into the function will be set with the appropriate error. If the value of port is zero, it is set to the default port of a memcached server. -memcached_servers_parse() takes a string, the type that is used for the -command line applications, and parse it to an array of memcached_server_st. -The example is "localhost, foo:555, foo, bar". All hosts except foo:555 will -be set to the default port, while that host will have a port of 555. +DEPRECATED memcached_servers_parse(), please see :manpage:`memcached(3)` memcached_server_error() can be used to look at the text of the last error message sent by the server to to the client. @@ -81,30 +60,23 @@ memcached_server_st \* was aliased to memcached_server_list_st. This was done for a style reason/to help clean up some concepts in the code. -****** +------ RETURN -****** +------ Varies, see particular functions. -**** +---- HOME -**** +---- To find out more information please check: `https://launchpad.net/libmemcached `_ -****** -AUTHOR -****** - - -Brian Aker, - -------- SEE ALSO diff --git a/tests/deprecated.cc b/tests/deprecated.cc new file mode 100644 index 00000000..03cfdaaa --- /dev/null +++ b/tests/deprecated.cc @@ -0,0 +1,73 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker 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. + * + * * The names of its contributors may not 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. + * + */ + +#include + +#include + +#include +#include +#include + +test_return_t server_list_null_test(memcached_st *ptr) +{ + memcached_server_st *server_list; + memcached_return_t rc; + (void)ptr; + + server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, NULL); + test_true(server_list == NULL); + + server_list= memcached_server_list_append_with_weight(NULL, "localhost", 0, 0, NULL); + test_true(server_list == NULL); + + server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, &rc); + test_true(server_list == NULL); + + return TEST_SUCCESS; +} + +// Look for memory leak +test_return_t regression_bug_728286(memcached_st *) +{ + memcached_server_st *servers = memcached_servers_parse("1.2.3.4:99"); + assert(servers); + memcached_server_free(servers); + + return TEST_SUCCESS; +} + diff --git a/tests/deprecated.h b/tests/deprecated.h new file mode 100644 index 00000000..d3d2e1f9 --- /dev/null +++ b/tests/deprecated.h @@ -0,0 +1,49 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker 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. + * + * * The names of its contributors may not 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. + * + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +test_return_t server_list_null_test(memcached_st *ptr); +test_return_t regression_bug_728286(memcached_st *); + +#ifdef __cplusplus +} +#endif diff --git a/tests/include.am b/tests/include.am index 420435d5..2a3e5cb8 100644 --- a/tests/include.am +++ b/tests/include.am @@ -35,6 +35,7 @@ noinst_HEADERS+= \ tests/ketama_test_cases_spy.h \ tests/libmemcached_world.h \ tests/parser.h \ + tests/deprecated.h \ tests/pool.h \ tests/print.h \ tests/replication.h \ @@ -54,6 +55,7 @@ noinst_PROGRAMS+= \ tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING) tests_testapp_SOURCES= \ tests/basic.cc \ + tests/deprecated.cc \ tests/error_conditions.cc \ tests/mem_functions.c \ tests/parser.cc \ diff --git a/tests/mem_functions.c b/tests/mem_functions.c index 72b3b193..a5e28e69 100644 --- a/tests/mem_functions.c +++ b/tests/mem_functions.c @@ -1,11 +1,41 @@ -/* libMemcached Functions Test - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2006-2009 Brian Aker 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. + * + * * The names of its contributors may not 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. * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. */ + /* Sample test application. */ @@ -34,6 +64,7 @@ #define SMALL_STRING_LEN 1024 #include +#include "tests/deprecated.h" #include "tests/parser.h" #include "tests/pool.h" #include "tests/string.h" @@ -75,24 +106,6 @@ static test_return_t init_test(memcached_st *not_used) return TEST_SUCCESS; } -static test_return_t server_list_null_test(memcached_st *ptr) -{ - memcached_server_st *server_list; - memcached_return_t rc; - (void)ptr; - - server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, NULL); - test_true(server_list == NULL); - - server_list= memcached_server_list_append_with_weight(NULL, "localhost", 0, 0, NULL); - test_true(server_list == NULL); - - server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, &rc); - test_true(server_list == NULL); - - return TEST_SUCCESS; -} - #define TEST_PORT_COUNT 7 in_port_t test_ports[TEST_PORT_COUNT]; @@ -199,23 +212,13 @@ static test_return_t server_sort2_test(memcached_st *ptr) static test_return_t memcached_server_remove_test(memcached_st *ptr) { - memcached_return_t rc; - memcached_st local_memc; - memcached_st *memc; - memcached_server_st *servers; - memcached_server_fn callbacks[1]; - - const char *server_string= "localhost:4444, localhost:4445, localhost:4446, localhost:4447, localhost, memcache1.memcache.bk.sapo.pt:11211, memcache1.memcache.bk.sapo.pt:11212, memcache1.memcache.bk.sapo.pt:11213, memcache1.memcache.bk.sapo.pt:11214, memcache2.memcache.bk.sapo.pt:11211, memcache2.memcache.bk.sapo.pt:11212, memcache2.memcache.bk.sapo.pt:11213, memcache2.memcache.bk.sapo.pt:11214"; + const char *server_string= "--server=localhost:4444 --server=localhost:4445 --server=localhost:4446 --server=localhost:4447 --server=localhost --server=memcache1.memcache.bk.sapo.pt:11211 --server=memcache1.memcache.bk.sapo.pt:11212 --server=memcache1.memcache.bk.sapo.pt:11213 --server=memcache1.memcache.bk.sapo.pt:11214 --server=memcache2.memcache.bk.sapo.pt:11211 --server=memcache2.memcache.bk.sapo.pt:11212 --server=memcache2.memcache.bk.sapo.pt:11213 --server=memcache2.memcache.bk.sapo.pt:11214"; (void)ptr; - memc= memcached_create(&local_memc); - - servers= memcached_servers_parse(server_string); - assert(servers); - - rc= memcached_server_push(memc, servers); - memcached_server_list_free(servers); + memcached_st *memc= memcached(server_string, strlen(server_string)); + test_true(memc); + memcached_server_fn callbacks[1]; callbacks[0]= server_print_callback; memcached_server_cursor(memc, callbacks, NULL, 1); @@ -5757,17 +5760,6 @@ static test_return_t regression_bug_583031(memcached_st *unused) return TEST_SUCCESS; } -// Look for memory leak -static test_return_t regression_bug_728286(memcached_st *unused) -{ - (void)unused; - memcached_server_st *servers = memcached_servers_parse("1.2.3.4:99"); - assert(servers); - memcached_server_free(servers); - - return TEST_SUCCESS; -} - static test_return_t regression_bug_581030(memcached_st *unused) { (void)unused; diff --git a/tests/parser.cc b/tests/parser.cc index 91408911..1c2fc504 100644 --- a/tests/parser.cc +++ b/tests/parser.cc @@ -44,7 +44,6 @@ #define BUILDING_LIBMEMCACHED #include -#include #include "tests/parser.h" #include "tests/print.h"