#include <sys/types.h>#include <sys/socket.h>#include <sys/time.h>#include <netinet/in.h>#include <event.h>#include <netdb.h>#include <stdbool.h>#include <stdint.h>#include <pthread.h>#include "protocol_binary.h"#include "cache.h"#include "stats.h"#include "slabs.h"#include "assoc.h"#include "items.h"#include "trace.h"#include "hash.h"#include "util.h"Go to the source code of this file.
Classes | |
| struct | slab_stats |
| struct | thread_stats |
| struct | stats |
| struct | settings |
| struct | _stritem |
| struct | LIBEVENT_THREAD |
| struct | LIBEVENT_DISPATCHER_THREAD |
| struct | conn |
Defines | |
| #define | KEY_MAX_LENGTH 250 |
| #define | INCR_MAX_STORAGE_LEN 24 |
| #define | DATA_BUFFER_SIZE 2048 |
| #define | UDP_READ_BUFFER_SIZE 65536 |
| #define | UDP_MAX_PAYLOAD_SIZE 1400 |
| #define | UDP_HEADER_SIZE 8 |
| #define | MAX_SENDBUF_SIZE (256 * 1024 * 1024) |
| #define | SUFFIX_SIZE 24 |
| #define | ITEM_LIST_INITIAL 200 |
| #define | SUFFIX_LIST_INITIAL 20 |
| #define | IOV_LIST_INITIAL 400 |
| #define | MSG_LIST_INITIAL 10 |
| #define | READ_BUFFER_HIGHWAT 8192 |
| #define | ITEM_LIST_HIGHWAT 400 |
| #define | IOV_LIST_HIGHWAT 600 |
| #define | MSG_LIST_HIGHWAT 100 |
| #define | MIN_BIN_PKT_LENGTH 16 |
| #define | BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t)) |
| #define | POWER_SMALLEST 1 |
| #define | POWER_LARGEST 200 |
| #define | CHUNK_ALIGN_BYTES 8 |
| #define | DONT_PREALLOC_SLABS |
| #define | MAX_NUMBER_OF_SLAB_CLASSES (POWER_LARGEST + 1) |
| #define | TAIL_REPAIR_TIME (3 * 3600) |
| #define | ITEM_get_cas(i) |
| #define | ITEM_set_cas(i, v) |
| #define | ITEM_key(item) |
| #define | ITEM_suffix(item) |
| #define | ITEM_data(item) |
| #define | ITEM_ntotal(item) |
| #define | STAT_KEY_LEN 128 |
| #define | STAT_VAL_LEN 128 |
| #define | APPEND_STAT(name, fmt, val) append_stat(name, add_stats, c, fmt, val); |
| #define | APPEND_NUM_FMT_STAT(name_fmt, num, name, fmt, val) |
| #define | APPEND_NUM_STAT(num, name, fmt, val) APPEND_NUM_FMT_STAT("%d:%s", num, name, fmt, val) |
| #define | IS_UDP(x) (x == udp_transport) |
| #define | NREAD_ADD 1 |
| #define | NREAD_SET 2 |
| #define | NREAD_REPLACE 3 |
| #define | NREAD_APPEND 4 |
| #define | NREAD_PREPEND 5 |
| #define | NREAD_CAS 6 |
| #define | MAX_VERBOSITY_LEVEL 2 |
| #define | ITEM_LINKED 1 |
| #define | ITEM_CAS 2 |
| #define | ITEM_SLABBED 4 |
| #define | drop_privileges() |
| #define | __builtin_expect(x, expected_value) (x) |
| #define | likely(x) __builtin_expect((x),1) |
| #define | unlikely(x) __builtin_expect((x),0) |
Typedefs | |
| typedef void(* | ADD_STAT )(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, const void *cookie) |
| typedef unsigned int | rel_time_t |
| typedef struct _stritem | item |
| typedef struct conn | conn |
Enumerations | |
| enum | conn_states { conn_listening, conn_new_cmd, conn_waiting, conn_read, conn_parse_cmd, conn_write, conn_nread, conn_swallow, conn_closing, conn_mwrite, conn_max_state } |
| enum | bin_substates { bin_no_state, bin_reading_set_header, bin_reading_cas_header, bin_read_set_value, bin_reading_get_key, bin_reading_stat, bin_reading_del_header, bin_reading_incr_header, bin_read_flush_exptime } |
| enum | protocol { ascii_prot = 3, binary_prot, negotiating_prot } |
| enum | network_transport { local_transport, tcp_transport, udp_transport } |
| enum | store_item_type { NOT_STORED = 0, STORED, EXISTS, NOT_FOUND } |
| enum | delta_result_type { OK, NON_NUMERIC, EOM } |
Functions | |
| void | do_accept_new_conns (const bool do_accept) |
| enum delta_result_type | do_add_delta (conn *c, item *item, const bool incr, const int64_t delta, char *buf) |
| enum store_item_type | do_store_item (item *item, int comm, conn *c) |
| conn * | conn_new (const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base) |
| int | daemonize (int nochdir, int noclose) |
| void | thread_init (int nthreads, struct event_base *main_base) |
| int | dispatch_event_add (int thread, conn *c) |
| void | dispatch_conn_new (int sfd, enum conn_states init_state, int event_flags, int read_buffer_size, enum network_transport transport) |
| enum delta_result_type | add_delta (conn *c, item *item, const int incr, const int64_t delta, char *buf) |
| void | accept_new_conns (const bool do_accept) |
| conn * | conn_from_freelist (void) |
| bool | conn_add_to_freelist (conn *c) |
| int | is_listen_thread (void) |
| item * | item_alloc (char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes) |
| char * | item_cachedump (const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes) |
| void | item_flush_expired (void) |
| item * | item_get (const char *key, const size_t nkey) |
| int | item_link (item *it) |
| void | item_remove (item *it) |
| int | item_replace (item *it, item *new_it) |
| void | item_stats (ADD_STAT add_stats, void *c) |
| void | item_stats_sizes (ADD_STAT add_stats, void *c) |
| void | item_unlink (item *it) |
| void | item_update (item *it) |
| void | STATS_LOCK (void) |
| void | STATS_UNLOCK (void) |
| void | threadlocal_stats_reset (void) |
| void | threadlocal_stats_aggregate (struct thread_stats *stats) |
| void | slab_stats_aggregate (struct thread_stats *stats, struct slab_stats *out) |
| void | append_stat (const char *name, ADD_STAT add_stats, conn *c, const char *fmt,...) |
| enum store_item_type | store_item (item *item, int comm, conn *c) |
Variables | |
| struct stats | stats |
| time_t | process_started |
| struct settings | settings |
| volatile rel_time_t | current_time |
| #define APPEND_NUM_FMT_STAT | ( | name_fmt, | |||
| num, | |||||
| name, | |||||
| fmt, | |||||
| val | ) |
Value:
klen = snprintf(key_str, STAT_KEY_LEN, name_fmt, num, name); \
vlen = snprintf(val_str, STAT_VAL_LEN, fmt, val); \
add_stats(key_str, klen, val_str, vlen, c);
| #define APPEND_NUM_STAT | ( | num, | |||
| name, | |||||
| fmt, | |||||
| val | ) | APPEND_NUM_FMT_STAT("%d:%s", num, name, fmt, val) |
Common APPEND_NUM_FMT_STAT format.
| #define APPEND_STAT | ( | name, | |||
| fmt, | |||||
| val | ) | append_stat(name, add_stats, c, fmt, val); |
Append a simple stat with a stat name, value format and value
| #define INCR_MAX_STORAGE_LEN 24 |
Size of an incr buf.
| #define IOV_LIST_INITIAL 400 |
Initial size of the sendmsg() scatter/gather array.
| #define ITEM_data | ( | item | ) |
| #define ITEM_get_cas | ( | i | ) |
Value:
((uint64_t)(((i)->it_flags & ITEM_CAS) ? \
*(uint64_t*)&((i)->end[0]) : 0x0))
| #define ITEM_key | ( | item | ) |
| #define ITEM_LIST_INITIAL 200 |
Initial size of list of items being returned by "get".
| #define ITEM_ntotal | ( | item | ) |
| #define ITEM_set_cas | ( | i, | |||
| v | ) |
Value:
{ if ((i)->it_flags & ITEM_CAS) { \
*(uint64_t*)&((i)->end[0]) = v; } }
| #define ITEM_suffix | ( | item | ) |
| #define KEY_MAX_LENGTH 250 |
Maximum length of a key.
| #define MSG_LIST_INITIAL 10 |
Initial number of sendmsg() argument structures to allocate.
| #define READ_BUFFER_HIGHWAT 8192 |
High water marks for buffer shrinking
| #define SUFFIX_LIST_INITIAL 20 |
Initial size of list of CAS suffixes appended to "gets" lines.
| #define TAIL_REPAIR_TIME (3 * 3600) |
How long an object can reasonably be assumed to be locked before harvesting it on a low memory condition.
| typedef void(* ADD_STAT)(const char *key, const uint16_t klen, const char *val, const uint32_t vlen, const void *cookie) |
Callback for any function producing stats.
| key | the stat's key | |
| klen | length of the key | |
| val | the stat's value in an ascii form (e.g. text form of a number) | |
| vlen | length of the value cookie magic callback cookie |
| typedef unsigned int rel_time_t |
Time relative to server start. Smaller than time_t on 64-bit systems.
| enum conn_states |
Possible states of a connection.
1.5.9