"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "memcached.h" between
memcached-1.6.8.tar.gz and memcached-1.6.9.tar.gz

About: memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load.

memcached.h  (memcached-1.6.8):memcached.h  (memcached-1.6.9)
skipping to change at line 46 skipping to change at line 46
#endif #endif
#endif #endif
#endif #endif
#include "itoa_ljust.h" #include "itoa_ljust.h"
#include "protocol_binary.h" #include "protocol_binary.h"
#include "cache.h" #include "cache.h"
#include "logger.h" #include "logger.h"
#ifdef EXTSTORE #ifdef EXTSTORE
#include "extstore.h"
#include "crc32c.h" #include "crc32c.h"
#endif #endif
#include "sasl_defs.h" #include "sasl_defs.h"
#ifdef TLS #ifdef TLS
#include <openssl/ssl.h> #include <openssl/ssl.h>
#endif #endif
/* for NAPI pinning feature */
#ifndef SO_INCOMING_NAPI_ID
#define SO_INCOMING_NAPI_ID 56
#endif
/** Maximum length of a key. */ /** Maximum length of a key. */
#define KEY_MAX_LENGTH 250 #define KEY_MAX_LENGTH 250
/** Maximum length of a uri encoded key. */ /** Maximum length of a uri encoded key. */
#define KEY_MAX_URI_ENCODED_LENGTH (KEY_MAX_LENGTH * 3 + 1) #define KEY_MAX_URI_ENCODED_LENGTH (KEY_MAX_LENGTH * 3 + 1)
/** Size of an incr buf. */ /** Size of an incr buf. */
#define INCR_MAX_STORAGE_LEN 24 #define INCR_MAX_STORAGE_LEN 24
#define WRITE_BUFFER_SIZE 1024 #define WRITE_BUFFER_SIZE 1024
skipping to change at line 198 skipping to change at line 202
conn_waiting, /**< waiting for a readable socket */ conn_waiting, /**< waiting for a readable socket */
conn_read, /**< reading in a command line */ conn_read, /**< reading in a command line */
conn_parse_cmd, /**< try to parse a command from the input buffer */ conn_parse_cmd, /**< try to parse a command from the input buffer */
conn_write, /**< writing out a simple response */ conn_write, /**< writing out a simple response */
conn_nread, /**< reading in a fixed number of bytes */ conn_nread, /**< reading in a fixed number of bytes */
conn_swallow, /**< swallowing unnecessary bytes w/o storing */ conn_swallow, /**< swallowing unnecessary bytes w/o storing */
conn_closing, /**< closing this connection */ conn_closing, /**< closing this connection */
conn_mwrite, /**< writing out many items sequentially */ conn_mwrite, /**< writing out many items sequentially */
conn_closed, /**< connection is closed */ conn_closed, /**< connection is closed */
conn_watch, /**< held by the logger thread as a watcher */ conn_watch, /**< held by the logger thread as a watcher */
conn_io_queue, /**< wait on async. process to get response object */
conn_max_state /**< Max state value (used for assertion) */ conn_max_state /**< Max state value (used for assertion) */
}; };
enum bin_substates { enum bin_substates {
bin_no_state, bin_no_state,
bin_reading_set_header, bin_reading_set_header,
bin_reading_cas_header, bin_reading_cas_header,
bin_read_set_value, bin_read_set_value,
bin_reading_get_key, bin_reading_get_key,
bin_reading_stat, bin_reading_stat,
skipping to change at line 369 skipping to change at line 374
#ifdef EXTSTORE #ifdef EXTSTORE
uint64_t extstore_compact_lost; /* items lost because they were locked */ uint64_t extstore_compact_lost; /* items lost because they were locked */
uint64_t extstore_compact_rescues; /* items re-written during compactio n */ uint64_t extstore_compact_rescues; /* items re-written during compactio n */
uint64_t extstore_compact_skipped; /* unhit items skipped during compac tion */ uint64_t extstore_compact_skipped; /* unhit items skipped during compac tion */
#endif #endif
#ifdef TLS #ifdef TLS
uint64_t ssl_handshake_errors; /* TLS failures at accept/handshake time */ uint64_t ssl_handshake_errors; /* TLS failures at accept/handshake time */
uint64_t ssl_new_sessions; /* successfully negotiated new (non-reused) TLS sessions */ uint64_t ssl_new_sessions; /* successfully negotiated new (non-reused) TLS sessions */
#endif #endif
struct timeval maxconns_entered; /* last time maxconns entered */ struct timeval maxconns_entered; /* last time maxconns entered */
uint64_t unexpected_napi_ids; /* see doc/napi_ids.txt */
uint64_t round_robin_fallback; /* see doc/napi_ids.txt */
}; };
/** /**
* Global "state" stats. Reflects state that shouldn't be wiped ever. * Global "state" stats. Reflects state that shouldn't be wiped ever.
* Ordered for some cache line locality for commonly updated counters. * Ordered for some cache line locality for commonly updated counters.
*/ */
struct stats_state { struct stats_state {
uint64_t curr_items; uint64_t curr_items;
uint64_t curr_bytes; uint64_t curr_bytes;
uint64_t curr_conns; uint64_t curr_conns;
skipping to change at line 483 skipping to change at line 490
char *ssl_chain_cert; /* path to the server SSL chain certificate */ char *ssl_chain_cert; /* path to the server SSL chain certificate */
char *ssl_key; /* path to the server key */ char *ssl_key; /* path to the server key */
int ssl_verify_mode; /* client certificate verify mode */ int ssl_verify_mode; /* client certificate verify mode */
int ssl_keyformat; /* key format , defult is PEM */ int ssl_keyformat; /* key format , defult is PEM */
char *ssl_ciphers; /* list of SSL ciphers */ char *ssl_ciphers; /* list of SSL ciphers */
char *ssl_ca_cert; /* certificate with CAs. */ char *ssl_ca_cert; /* certificate with CAs. */
rel_time_t ssl_last_cert_refresh_time; /* time of the last server certificat e refresh */ rel_time_t ssl_last_cert_refresh_time; /* time of the last server certificat e refresh */
unsigned int ssl_wbuf_size; /* size of the write buffer used by ssl_sendmsg method */ unsigned int ssl_wbuf_size; /* size of the write buffer used by ssl_sendmsg method */
bool ssl_session_cache; /* enable SSL server session caching */ bool ssl_session_cache; /* enable SSL server session caching */
#endif #endif
int num_napi_ids; /* maximum number of NAPI IDs */
char *memory_file; /* warm restart memory file path */
}; };
extern struct stats stats; extern struct stats stats;
extern struct stats_state stats_state; extern struct stats_state stats_state;
extern time_t process_started; extern time_t process_started;
extern struct settings settings; extern struct settings settings;
#define ITEM_LINKED 1 #define ITEM_LINKED 1
#define ITEM_CAS 2 #define ITEM_CAS 2
skipping to change at line 614 skipping to change at line 623
typedef struct { typedef struct {
pthread_t thread_id; /* unique ID of this thread */ pthread_t thread_id; /* unique ID of this thread */
struct event_base *base; /* libevent handle this thread uses */ struct event_base *base; /* libevent handle this thread uses */
struct event notify_event; /* listen event for notify pipe */ struct event notify_event; /* listen event for notify pipe */
int notify_receive_fd; /* receiving end of notify pipe */ int notify_receive_fd; /* receiving end of notify pipe */
int notify_send_fd; /* sending end of notify pipe */ int notify_send_fd; /* sending end of notify pipe */
struct thread_stats stats; /* Stats generated by this thread */ struct thread_stats stats; /* Stats generated by this thread */
struct conn_queue *new_conn_queue; /* queue of new connections to handle */ struct conn_queue *new_conn_queue; /* queue of new connections to handle */
cache_t *rbuf_cache; /* static-sized read buffers */ cache_t *rbuf_cache; /* static-sized read buffers */
mc_resp_bundle *open_bundle; mc_resp_bundle *open_bundle;
#ifdef EXTSTORE
cache_t *io_cache; /* IO objects */ cache_t *io_cache; /* IO objects */
#ifdef EXTSTORE
void *storage; /* data object for storage system */ void *storage; /* data object for storage system */
#endif #endif
logger *l; /* logger buffer */ logger *l; /* logger buffer */
void *lru_bump_buf; /* async LRU bump buffer */ void *lru_bump_buf; /* async LRU bump buffer */
#ifdef TLS #ifdef TLS
char *ssl_wbuf; char *ssl_wbuf;
#endif #endif
int napi_id; /* napi id associated with this thread */
} LIBEVENT_THREAD; } LIBEVENT_THREAD;
/** /**
* Response objects * Response objects
*/ */
typedef struct _io_pending_t io_pending_t;
#define MC_RESP_IOVCOUNT 4 #define MC_RESP_IOVCOUNT 4
typedef struct _mc_resp { typedef struct _mc_resp {
mc_resp_bundle *bundle; // ptr back to bundle mc_resp_bundle *bundle; // ptr back to bundle
struct _mc_resp *next; // choo choo. struct _mc_resp *next; // choo choo.
int wbytes; // bytes to write out of wbuf: might be able to nuke this. int wbytes; // bytes to write out of wbuf: might be able to nuke this.
int tosend; // total bytes to send for this response int tosend; // total bytes to send for this response
void *write_and_free; /** free this memory after finishing writing */ void *write_and_free; /** free this memory after finishing writing */
io_pending_t *io_pending; /* pending IO descriptor for this response */
item *item; /* item associated with this response object, with reference hel d */ item *item; /* item associated with this response object, with reference hel d */
struct iovec iov[MC_RESP_IOVCOUNT]; /* built-in iovecs to simplify network c ode */ struct iovec iov[MC_RESP_IOVCOUNT]; /* built-in iovecs to simplify network c ode */
int chunked_total; /* total amount of chunked item data to send. */ int chunked_total; /* total amount of chunked item data to send. */
uint8_t iovcnt; uint8_t iovcnt;
uint8_t chunked_data_iov; /* this iov is a pointer to chunked data header */ uint8_t chunked_data_iov; /* this iov is a pointer to chunked data header */
/* instruct transmit to skip this response object. used by storage engines /* instruct transmit to skip this response object. used by storage engines
* to asynchronously kill an object that was queued to write * to asynchronously kill an object that was queued to write
*/ */
skipping to change at line 668 skipping to change at line 680
#define MAX_RESP_PER_BUNDLE ((READ_BUFFER_SIZE - sizeof(mc_resp_bundle)) / sizeo f(mc_resp)) #define MAX_RESP_PER_BUNDLE ((READ_BUFFER_SIZE - sizeof(mc_resp_bundle)) / sizeo f(mc_resp))
struct _mc_resp_bundle { struct _mc_resp_bundle {
uint8_t refcount; uint8_t refcount;
uint8_t next_check; // next object to check on assignment. uint8_t next_check; // next object to check on assignment.
struct _mc_resp_bundle *next; struct _mc_resp_bundle *next;
struct _mc_resp_bundle *prev; struct _mc_resp_bundle *prev;
mc_resp r[]; mc_resp r[];
}; };
typedef struct conn conn; typedef struct conn conn;
#ifdef EXTSTORE
typedef struct _io_wrap { #define IO_QUEUE_NONE 0
obj_io io; #define IO_QUEUE_EXTSTORE 1
struct _io_wrap *next;
typedef void (*io_queue_stack_cb)(void *ctx, void *stack);
typedef void (*io_queue_cb)(io_pending_t *pending);
// this structure's ownership gets passed between threads:
// - owned normally by the worker thread.
// - multiple queues can be submitted at the same time.
// - each queue can be sent to different background threads.
// - each submitted queue needs to know when to return to the worker.
// - the worker needs to know when all queues have returned so it can process.
//
// io_queue_t's count field is owned by worker until submitted. Then owned by
// side thread until returned.
// conn->io_queues_submitted is always owned by the worker thread. it is
// incremented as the worker submits queues, and decremented as it gets pinged
// for returned threads.
//
// All of this is to avoid having to hit a mutex owned by the connection
// thread that gets pinged for each thread (or an equivalent atomic).
typedef struct {
void *ctx; // untouched ptr for specific context
void *stack_ctx; // module-specific context to be batch-submitted
io_queue_stack_cb submit_cb; // callback given a full stack of pending IO's
at once.
io_queue_stack_cb complete_cb;
io_queue_cb finalize_cb; // called back on the worker thread.
int type;
int count; // ios to process before returning. only accessed by queue proces
sor once submitted
} io_queue_t;
struct _io_pending_t {
io_queue_t *q;
conn *c; conn *c;
item *hdr_it; /* original header item. */ mc_resp *resp; // associated response object
mc_resp *resp; /* associated response object */ char data[120];
unsigned int iovec_data; /* specific index of data iovec */ };
bool noreply; /* whether the response had noreply set */
bool miss; /* signal a miss to unlink hdr_it */
bool badcrc; /* signal a crc failure */
bool active; /* tells if IO was dispatched or not */
} io_wrap;
#endif
/** /**
* The structure representing a connection into memcached. * The structure representing a connection into memcached.
*/ */
struct conn { struct conn {
sasl_conn_t *sasl_conn; sasl_conn_t *sasl_conn;
int sfd; int sfd;
bool sasl_started; bool sasl_started;
bool authenticated; bool authenticated;
bool set_stale; bool set_stale;
bool mset_res; /** uses mset format for return code */ bool mset_res; /** uses mset format for return code */
skipping to change at line 727 skipping to change at line 763
* item is used to hold an item structure created after reading the command * item is used to hold an item structure created after reading the command
* line of set/add/replace commands, but before we finished reading the actu al * line of set/add/replace commands, but before we finished reading the actu al
* data. The data is read into ITEM_data(item) to avoid extra copying. * data. The data is read into ITEM_data(item) to avoid extra copying.
*/ */
void *item; /* for commands set/add/replace */ void *item; /* for commands set/add/replace */
/* data for the swallow state */ /* data for the swallow state */
int sbytes; /* how many bytes to swallow */ int sbytes; /* how many bytes to swallow */
int io_queues_submitted; /* see notes on io_queue_t */
io_queue_t io_queues[3]; /* set of deferred IO queues. */
#ifdef EXTSTORE #ifdef EXTSTORE
int io_wrapleft;
unsigned int recache_counter; unsigned int recache_counter;
io_wrap *io_wraplist; /* linked list of io_wraps */
bool io_queued; /* FIXME: debugging flag */
#endif #endif
enum protocol protocol; /* which protocol this connection speaks */ enum protocol protocol; /* which protocol this connection speaks */
enum network_transport transport; /* what transport is used by this connecti on */ enum network_transport transport; /* what transport is used by this connecti on */
/* data for UDP clients */ /* data for UDP clients */
int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */ int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */
struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request * / struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request * /
socklen_t request_addr_size; socklen_t request_addr_size;
bool noreply; /* True if the reply should not be sent. */ bool noreply; /* True if the reply should not be sent. */
skipping to change at line 804 skipping to change at line 839
/* /*
* Functions * Functions
*/ */
void do_accept_new_conns(const bool do_accept); void do_accept_new_conns(const bool do_accept);
enum delta_result_type do_add_delta(conn *c, const char *key, enum delta_result_type do_add_delta(conn *c, const char *key,
const size_t nkey, const bool incr, const size_t nkey, const bool incr,
const int64_t delta, char *buf, const int64_t delta, char *buf,
uint64_t *cas, const uint32_t hv, uint64_t *cas, const uint32_t hv,
item **it_ret); item **it_ret);
enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t hv); enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t hv);
void conn_io_queue_add(conn *c, int type, void *ctx, io_queue_stack_cb cb, io_qu
eue_stack_cb com_cb, io_queue_cb fin_cb);
io_queue_t *conn_io_queue_get(conn *c, int type);
conn *conn_new(const int sfd, const enum conn_states init_state, const int event _flags, const int read_buffer_size, 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, void *ssl); enum network_transport transport, struct event_base *base, void *ssl);
void conn_worker_readd(conn *c); void conn_worker_readd(conn *c);
extern int daemonize(int nochdir, int noclose); extern int daemonize(int nochdir, int noclose);
#define mutex_lock(x) pthread_mutex_lock(x) #define mutex_lock(x) pthread_mutex_lock(x)
#define mutex_unlock(x) pthread_mutex_unlock(x) #define mutex_unlock(x) pthread_mutex_unlock(x)
#include "stats_prefix.h" #include "stats_prefix.h"
skipping to change at line 910 skipping to change at line 947
void server_stats(ADD_STAT add_stats, conn *c); void server_stats(ADD_STAT add_stats, conn *c);
void append_stats(const char *key, const uint16_t klen, void append_stats(const char *key, const uint16_t klen,
const char *val, const uint32_t vlen, const char *val, const uint32_t vlen,
const void *cookie); const void *cookie);
/** Return a datum for stats in binary protocol */ /** Return a datum for stats in binary protocol */
bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c); bool get_stats(const char *stat_type, int nkey, ADD_STAT add_stats, void *c);
void stats_reset(void); void stats_reset(void);
void process_stat_settings(ADD_STAT add_stats, void *c); void process_stat_settings(ADD_STAT add_stats, void *c);
void process_stats_conns(ADD_STAT add_stats, void *c); void process_stats_conns(ADD_STAT add_stats, void *c);
#ifdef EXTSTORE
void process_extstore_stats(ADD_STAT add_stats, conn *c);
int _get_extstore(conn *c, item *it, mc_resp *resp);
#endif
#if HAVE_DROP_PRIVILEGES #if HAVE_DROP_PRIVILEGES
extern void setup_privilege_violations_handler(void); extern void setup_privilege_violations_handler(void);
extern void drop_privileges(void); extern void drop_privileges(void);
#else #else
#define setup_privilege_violations_handler() #define setup_privilege_violations_handler()
#define drop_privileges() #define drop_privileges()
#endif #endif
#if HAVE_DROP_WORKER_PRIVILEGES #if HAVE_DROP_WORKER_PRIVILEGES
extern void drop_worker_privileges(void); extern void drop_worker_privileges(void);
 End of changes. 17 change blocks. 
23 lines changed or deleted 58 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)