terom@38: #ifndef MEMCACHE_REQ_H terom@38: #define MEMCACHE_REQ_H terom@38: terom@38: #include terom@38: terom@38: #include "../memcache.h" terom@38: #include "connection.h" terom@38: terom@38: struct memcache_req { terom@39: // the memcache context that we belong to terom@39: struct memcache *mc; terom@39: terom@41: // the command to execute terom@41: enum memcache_command cmd_type; terom@41: terom@42: // the reply we have received, or MEMCACHE_REPLY_INVALID terom@42: enum memcache_reply reply_type; terom@42: terom@39: // our key/obj terom@39: struct memcache_key key; terom@41: struct memcache_obj obj; terom@41: struct memcache_buf buf; terom@39: terom@39: // our state terom@39: enum memcache_req_state state; terom@39: terom@39: // our user callback argument terom@39: void *cb_arg; terom@39: terom@39: // the conn terom@39: struct memcache_connection *conn; terom@38: terom@38: // we are a member of struct memcache_server.req_queue terom@38: TAILQ_ENTRY(memcache_req) reqqueue_node; terom@38: }; terom@38: terom@39: /* terom@39: * Allocate and return a new req, or NULL if unsuccesfull. terom@39: */ terom@41: struct memcache_req *memcache_req_alloc (struct memcache *mc, enum memcache_command cmd_type, const struct memcache_key *key, void *cb_arg); terom@39: terom@39: /* terom@39: * An error occurred, and the request must be abandoned. This will assume that the req is not active or enqueued terom@39: * anymore, and the req should not be accessed by memcache_* code after this. terom@39: */ terom@39: void memcache_req_error (struct memcache_req *req); terom@39: terom@39: /* terom@42: * The request has been queued. terom@42: */ terom@42: void memcache_req_queued (struct memcache_req *req); terom@42: terom@42: /* terom@42: * The request is being sent. terom@42: */ terom@42: void memcache_req_send (struct memcache_req *req); terom@42: terom@42: /* terom@42: * The response has been received, although if the respones also contains data, that will be notified separately terom@42: */ terom@42: void memcache_req_reply (struct memcache_req *req, enum memcache_reply reply_type); terom@42: terom@42: /* terom@42: * The request was sent and is now done, and is not associated with the connection anymore. terom@42: * terom@42: * This will be called before req_reply/req_data, but not before/after req_error. terom@42: */ terom@42: void memcache_req_done (struct memcache_req *req); terom@42: terom@42: /* terom@39: * Free an unused req. Should always be called by the user, not via internal means. terom@39: */ terom@39: void memcache_req_free (struct memcache_req *req); terom@39: terom@38: #endif /* MEMCACHE_REQ_H */