1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following disclaimer
18 * in the documentation and/or other materials provided with the
21 * * The names of its contributors may not be used to endorse or
22 * promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 Common include file for libmemached
45 #include <mem_config.h>
82 #ifdef HAVE_SYS_TIME_H
83 # include <sys/time.h>
90 #ifdef HAVE_SYS_TYPES_H
91 # include <sys/types.h>
98 #ifdef HAVE_SYS_SOCKET_H
99 # include <sys/socket.h>
102 #ifdef HAVE_STRINGS_H
103 # include <strings.h>
110 #if defined(WIN32) || defined(__MINGW32__)
111 # include "libmemcached/windows.hpp"
114 #include <libmemcached-1.0/memcached.h>
115 #include <libmemcached/watchpoint.h>
116 #include <libmemcached/is.h>
119 # include "libmemcached/instance.hpp"
121 #include <libmemcached/server_instance.h>
126 # include "libmemcached/poll.h"
133 typedef memcached_return_t (*memcached_server_execute_fn
)(memcached_st
*ptr
, memcached_server_write_instance_st server
, void *context
);
141 org::libmemcached::Instance
* memcached_instance_fetch(memcached_st
*ptr
, uint32_t server_key
);
144 memcached_return_t
memcached_server_execute(memcached_st
*ptr
,
145 memcached_server_execute_fn callback
,
147 /* These are private not to be installed headers */
148 #include <libmemcached/error.hpp>
149 #include <libmemcached/memory.h>
150 #include <libmemcached/io.h>
152 #include <libmemcached/string.hpp>
153 #include <libmemcached/memcached/protocol_binary.h>
154 #include <libmemcached/io.hpp>
155 #include <libmemcached/udp.hpp>
156 #include <libmemcached/do.hpp>
157 #include <libmemcached/socket.hpp>
158 #include <libmemcached/connect.hpp>
159 #include <libmemcached/allocators.hpp>
160 #include <libmemcached/hash.hpp>
161 #include <libmemcached/quit.hpp>
162 #include <libmemcached/instance.hpp>
163 #include <libmemcached/server.hpp>
164 #include <libmemcached/flag.hpp>
165 #include <libmemcached/behavior.hpp>
166 #include <libmemcached/sasl.hpp>
167 #include <libmemcached/server_list.hpp>
169 #include <libmemcached/internal.h>
170 #include <libmemcached/array.h>
171 #include <libmemcached/libmemcached_probes.h>
172 #include <libmemcached/byteorder.h>
173 #include <libmemcached/initialize_query.h>
175 #include <libmemcached/response.h>
177 #include <libmemcached/namespace.h>
178 #include <libmemcached/virtual_bucket.h>
181 #include <libmemcached/backtrace.hpp>
182 #include <libmemcached/assert.hpp>
183 #include <libmemcached/server.hpp>
184 #include <libmemcached/key.hpp>
185 #include <libmemcached/encoding_key.h>
186 #include <libmemcached/result.h>
187 #include <libmemcached/version.hpp>
190 #include <libmemcached/continuum.hpp>
192 #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
194 #define likely(x) if((x))
195 #define unlikely(x) if((x))
199 #define likely(x) if(__builtin_expect((x) != 0, 1))
200 #define unlikely(x) if(__builtin_expect((x) != 0, 0))
203 #define MEMCACHED_BLOCK_SIZE 1024
204 #define MEMCACHED_DEFAULT_COMMAND_SIZE 350
205 #define SMALL_STRING_LEN 1024
206 #define HUGE_STRING_LEN 8196
212 memcached_return_t
run_distribution(memcached_st
*ptr
);
215 static inline void memcached_server_response_increment(org::libmemcached::Instance
* instance
)
217 instance
->events(POLLIN
);
218 instance
->cursor_active_
++;
222 #define memcached_server_response_decrement(A) (A)->cursor_active_--
223 #define memcached_server_response_reset(A) (A)->cursor_active_=0
225 #define memcached_instance_response_increment(A) (A)->cursor_active_++
226 #define memcached_instance_response_decrement(A) (A)->cursor_active_--
227 #define memcached_instance_response_reset(A) (A)->cursor_active_=0
234 bool memcached_purge(org::libmemcached::Instance
*);
235 org::libmemcached::Instance
* memcached_instance_by_position(const memcached_st
*ptr
, uint32_t server_key
);