From: Brian Aker Date: Tue, 29 Nov 2011 19:41:49 +0000 (-0800) Subject: Try to setup initial DNS a bit earlier in the process so that we can make use of... X-Git-Tag: 1.0.3~4^2~2^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=682c9be93c10b245db9a943459ca6fcde0918138;p=m6w6%2Flibmemcached Try to setup initial DNS a bit earlier in the process so that we can make use of a few more cycles. --- diff --git a/libmemcached/common.h b/libmemcached/common.h index ba0b4063..7239ca60 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -107,6 +107,7 @@ memcached_return_t memcached_server_execute(memcached_st *ptr, #include #include #include +#include #endif #include #include diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 6cad60d5..e04098c4 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -129,7 +129,7 @@ static memcached_return_t connect_poll(memcached_server_st *server) return memcached_set_errno(*server, get_socket_errno(), MEMCACHED_AT); } -static memcached_return_t set_hostinfo(memcached_server_st *server) +memcached_return_t set_hostinfo(memcached_server_st *server) { if (server->address_info) { diff --git a/libmemcached/connect.hpp b/libmemcached/connect.hpp new file mode 100644 index 00000000..78ed7960 --- /dev/null +++ b/libmemcached/connect.hpp @@ -0,0 +1,40 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * 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 + +memcached_return_t set_hostinfo(memcached_server_st *server); diff --git a/libmemcached/get.cc b/libmemcached/get.cc index 6dfb7a79..4ad49a41 100644 --- a/libmemcached/get.cc +++ b/libmemcached/get.cc @@ -68,12 +68,16 @@ char *memcached_get_by_key(memcached_st *ptr, { memcached_return_t unused; if (error == NULL) + { error= &unused; + } - unlikely (ptr->flags.use_udp) + if (ptr->flags.use_udp) { if (value_length) + { *value_length= 0; + } *error= memcached_set_error(*ptr, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT); return NULL; diff --git a/libmemcached/include.am b/libmemcached/include.am index 0da3de33..69385463 100644 --- a/libmemcached/include.am +++ b/libmemcached/include.am @@ -20,9 +20,10 @@ noinst_HEADERS+= \ libmemcached/assert.hpp \ libmemcached/backtrace.hpp \ libmemcached/byteorder.h \ + libmemcached/close_socket.hpp \ libmemcached/common.h \ + libmemcached/connect.hpp \ libmemcached/continuum.hpp \ - libmemcached/close_socket.hpp \ libmemcached/do.hpp \ libmemcached/error.hpp \ libmemcached/initialize_query.h \ diff --git a/libmemcached/initialize_query.cc b/libmemcached/initialize_query.cc index 5950158b..84fc2290 100644 --- a/libmemcached/initialize_query.cc +++ b/libmemcached/initialize_query.cc @@ -55,12 +55,14 @@ memcached_return_t initialize_query(memcached_st *self) return memcached_set_error(*self, MEMCACHED_NO_SERVERS, MEMCACHED_AT); } + memcached_error_free(*self); + return MEMCACHED_SUCCESS; } memcached_return_t initialize_const_query(const memcached_st *self) { - if (not self) + if (self == NULL) { return MEMCACHED_INVALID_ARGUMENTS; } diff --git a/libmemcached/server.cc b/libmemcached/server.cc index cf63f4ca..e1b91b94 100644 --- a/libmemcached/server.cc +++ b/libmemcached/server.cc @@ -138,6 +138,11 @@ memcached_server_st *__server_create_with(memcached_st *memc, memcached_io_init_udp_header(self, 0); } + if (memc) + { + set_hostinfo(self); + } + return self; } @@ -197,14 +202,6 @@ memcached_server_st *memcached_server_clone(memcached_server_st *destination, hostname, source->port, source->weight, source->type); - if (destination) - { - if (source->error_messages) - { - destination->error_messages= memcached_error_copy(*source); - } - } - return destination; } diff --git a/libtest/run.gdb b/libtest/run.gdb index 320407a2..a520ae87 100644 --- a/libtest/run.gdb +++ b/libtest/run.gdb @@ -1,2 +1,3 @@ set environment LIBTEST_IN_GDB=1 run +quit