memcache/request.h
author Tero Marttila <terom@fixme.fi>
Wed, 27 Aug 2008 21:30:32 +0300
changeset 41 540737bf6bac
parent 39 0e21a65074a6
child 42 0e503189af2f
permissions -rw-r--r--
sending requests, and partial support for receiving -- incomplete, not tested
#ifndef MEMCACHE_REQ_H
#define MEMCACHE_REQ_H

#include <sys/queue.h>

#include "../memcache.h"
#include "connection.h"

struct memcache_req {
    // the memcache context that we belong to
    struct memcache *mc;

    // the command to execute
    enum memcache_command cmd_type;

    // our key/obj
    struct memcache_key key;
    struct memcache_obj obj;
    struct memcache_buf buf;

    // our state
    enum memcache_req_state state;

    // our user callback argument
    void *cb_arg;

    // the conn 
    struct memcache_connection *conn;
    
    // we are a member of struct memcache_server.req_queue
    TAILQ_ENTRY(memcache_req) reqqueue_node;
};

/*
 * Allocate and return a new req, or NULL if unsuccesfull.
 */
struct memcache_req *memcache_req_alloc (struct memcache *mc, enum memcache_command cmd_type, const struct memcache_key *key, void *cb_arg);


/*
 * An error occurred, and the request must be abandoned. This will assume that the req is not active or enqueued
 * anymore, and the req should not be accessed by memcache_* code after this.
 */
void memcache_req_error (struct memcache_req *req);

/*
 * Free an unused req. Should always be called by the user, not via internal means.
 */
void memcache_req_free (struct memcache_req *req);

#endif /* MEMCACHE_REQ_H */