memcache/request.c
changeset 42 0e503189af2f
parent 41 540737bf6bac
child 43 e5b714190dee
equal deleted inserted replaced
41:540737bf6bac 42:0e503189af2f
    39     }
    39     }
    40 
    40 
    41     return NULL;
    41     return NULL;
    42 }
    42 }
    43 
    43 
    44 static int _memcache_req_notify (struct memcache_req *req) {
    44 static void _memcache_req_notify (struct memcache_req *req) {
    45     return req->mc->cb_fn(req, req->cb_arg);
    45     req->mc->cb_fn(req, req->cb_arg);
    46 }
    46 }
    47 
    47 
    48 void memcache_req_error (struct memcache_req *req) {
    48 void memcache_req_error (struct memcache_req *req) {
    49     // forget our connection
    49     // forget our connection
    50     req->conn = NULL;
    50     req->conn = NULL;
    51     
    51 
    52     // enter ERROR state
       
    53     req->state = MEMCACHE_STATE_ERROR;
    52     req->state = MEMCACHE_STATE_ERROR;
    54 
    53 
    55     // notify
    54     _memcache_req_notify(req);
    56     if (_memcache_req_notify(req))
    55 }
    57         WARNING("req error callback failed, ignoring");
    56 
       
    57 void memcache_req_queued (struct memcache_req *req) {
       
    58     req->state = MEMCACHE_STATE_QUEUED;
       
    59 
       
    60 //    _memcache_req_notify(req);
       
    61 }
       
    62 
       
    63 void memcache_req_send (struct memcache_req *req) {
       
    64     req->state = MEMCACHE_STATE_SEND;
       
    65     
       
    66 //    _memcache_req_notify(req);
       
    67 }
       
    68 
       
    69 void memcache_req_reply (struct memcache_req *req, enum memcache_reply reply_type) {
       
    70     req->state = MEMCACHE_STATE_REPLY;
       
    71     req->reply_type = reply_type;
       
    72 
       
    73     _memcache_req_notify(req);
       
    74 }
       
    75 
       
    76 void memcache_req_done (struct memcache_req *req) {
       
    77     // make sure we are in the STATE_SEND state
       
    78     assert(req->state == MEMCACHE_STATE_SEND);
       
    79 
       
    80     // forget the connection
       
    81     req->conn = NULL;
       
    82 
       
    83     // our state is currently indeterminate until req_reply is called
       
    84     req->state = MEMCACHE_STATE_INVALID;
    58 }
    85 }
    59 
    86 
    60 void memcache_req_free (struct memcache_req *req) {
    87 void memcache_req_free (struct memcache_req *req) {
    61     // must be unused
    88     // must be unused
    62     assert(req->conn == NULL);
    89     assert(req->conn == NULL);