summaryrefslogtreecommitdiff
path: root/memcached.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-01-09 18:08:26 -0800
committerdormando <dormando@rydia.net>2023-01-11 13:24:22 -0800
commitfccf7b9efdfb0deb11f111496ce53c5892647dab (patch)
treea3c2f6bafee2d80a609806627bd3922e0aa6cd08 /memcached.h
parent8bb9d9a3e5ca93c38db97181d4c15b03d48a644d (diff)
downloadmemcached-fccf7b9efdfb0deb11f111496ce53c5892647dab.tar.gz
core: remove *conn object from cache commands
We want to start using cache commands in contexts without a client connection, but the client object has always been passed to all functions. In most cases we only need the worker thread (LIBEVENT_THREAD *t), so this change adjusts the arguments passed in.
Diffstat (limited to 'memcached.h')
-rw-r--r--memcached.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/memcached.h b/memcached.h
index 860fae4..94a2550 100644
--- a/memcached.h
+++ b/memcached.h
@@ -273,6 +273,9 @@ enum close_reasons {
#define NREAD_PREPEND 5
#define NREAD_CAS 6
+#define CAS_ALLOW_STALE true
+#define CAS_NO_STALE false
+
enum store_item_type {
NOT_STORED=0, STORED, EXISTS, NOT_FOUND, TOO_LARGE, NO_MEMORY
};
@@ -711,6 +714,7 @@ typedef struct {
int notify_receive_fd; /* receiving end of notify pipe */
int notify_send_fd; /* sending end of notify pipe */
#endif
+ int cur_sfd; /* client fd for logging commands */
struct thread_stats stats; /* Stats generated by this thread */
io_queue_cb_t io_queues[IO_QUEUE_COUNT];
struct conn_queue *ev_queue; /* Worker/conn event queue */
@@ -914,12 +918,12 @@ extern void *ext_storage;
* Functions
*/
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(LIBEVENT_THREAD *t, const char *key,
const size_t nkey, const bool incr,
const int64_t delta, char *buf,
uint64_t *cas, const uint32_t hv,
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, LIBEVENT_THREAD *t, const uint32_t hv, uint64_t *cas, bool cas_stale);
void thread_io_queue_add(LIBEVENT_THREAD *t, int type, void *ctx, io_queue_stack_cb cb, io_queue_stack_cb com_cb, io_queue_cb ret_cb, io_queue_cb fin_cb);
void conn_io_queue_setup(conn *c);
io_queue_t *conn_io_queue_get(conn *c, int type);
@@ -961,19 +965,19 @@ void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags, in
void sidethread_conn_close(conn *c);
/* Lock wrappers for cache functions that are called from main loop. */
-enum delta_result_type add_delta(conn *c, const char *key,
+enum delta_result_type add_delta(LIBEVENT_THREAD *t, const char *key,
const size_t nkey, bool incr,
const int64_t delta, char *buf,
uint64_t *cas);
void accept_new_conns(const bool do_accept);
void conn_close_idle(conn *c);
void conn_close_all(void);
-item *item_alloc(char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes);
+item *item_alloc(const char *key, size_t nkey, int flags, rel_time_t exptime, int nbytes);
#define DO_UPDATE true
#define DONT_UPDATE false
-item *item_get(const char *key, const size_t nkey, conn *c, const bool do_update);
-item *item_get_locked(const char *key, const size_t nkey, conn *c, const bool do_update, uint32_t *hv);
-item *item_touch(const char *key, const size_t nkey, uint32_t exptime, conn *c);
+item *item_get(const char *key, const size_t nkey, LIBEVENT_THREAD *t, const bool do_update);
+item *item_get_locked(const char *key, const size_t nkey, LIBEVENT_THREAD *t, const bool do_update, uint32_t *hv);
+item *item_touch(const char *key, const size_t nkey, uint32_t exptime, LIBEVENT_THREAD *t);
int item_link(item *it);
void item_remove(item *it);
int item_replace(item *it, item *new_it, const uint32_t hv);
@@ -1002,7 +1006,7 @@ LIBEVENT_THREAD *get_worker_thread(int id);
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);
+enum store_item_type store_item(item *item, int comm, LIBEVENT_THREAD *t, uint64_t *cas, bool cas_stale);
/* Protocol related code */
void out_string(conn *c, const char *str);
@@ -1013,8 +1017,8 @@ void out_string(conn *c, const char *str);
#define EXPTIME_TO_POSITIVE_TIME(exptime) (exptime < 0) ? \
REALTIME_MAXDELTA + 1 : exptime
rel_time_t realtime(const time_t exptime);
-item* limited_get(char *key, size_t nkey, conn *c, uint32_t exptime, bool should_touch, bool do_update, bool *overflow);
-item* limited_get_locked(char *key, size_t nkey, conn *c, bool do_update, uint32_t *hv, bool *overflow);
+item* limited_get(const char *key, size_t nkey, LIBEVENT_THREAD *t, uint32_t exptime, bool should_touch, bool do_update, bool *overflow);
+item* limited_get_locked(const char *key, size_t nkey, LIBEVENT_THREAD *t, bool do_update, uint32_t *hv, bool *overflow);
// Read/Response object handlers.
void resp_reset(mc_resp *resp);
void resp_add_iov(mc_resp *resp, const void *buf, int len);