memcache/request.c
changeset 42 0e503189af2f
parent 41 540737bf6bac
child 43 e5b714190dee
--- a/memcache/request.c	Wed Aug 27 21:30:32 2008 +0300
+++ b/memcache/request.c	Wed Aug 27 22:42:27 2008 +0300
@@ -41,20 +41,47 @@
     return NULL;
 }
 
-static int _memcache_req_notify (struct memcache_req *req) {
-    return req->mc->cb_fn(req, req->cb_arg);
+static void _memcache_req_notify (struct memcache_req *req) {
+    req->mc->cb_fn(req, req->cb_arg);
 }
 
 void memcache_req_error (struct memcache_req *req) {
     // forget our connection
     req->conn = NULL;
-    
-    // enter ERROR state
+
     req->state = MEMCACHE_STATE_ERROR;
 
-    // notify
-    if (_memcache_req_notify(req))
-        WARNING("req error callback failed, ignoring");
+    _memcache_req_notify(req);
+}
+
+void memcache_req_queued (struct memcache_req *req) {
+    req->state = MEMCACHE_STATE_QUEUED;
+
+//    _memcache_req_notify(req);
+}
+
+void memcache_req_send (struct memcache_req *req) {
+    req->state = MEMCACHE_STATE_SEND;
+    
+//    _memcache_req_notify(req);
+}
+
+void memcache_req_reply (struct memcache_req *req, enum memcache_reply reply_type) {
+    req->state = MEMCACHE_STATE_REPLY;
+    req->reply_type = reply_type;
+
+    _memcache_req_notify(req);
+}
+
+void memcache_req_done (struct memcache_req *req) {
+    // make sure we are in the STATE_SEND state
+    assert(req->state == MEMCACHE_STATE_SEND);
+
+    // forget the connection
+    req->conn = NULL;
+
+    // our state is currently indeterminate until req_reply is called
+    req->state = MEMCACHE_STATE_INVALID;
 }
 
 void memcache_req_free (struct memcache_req *req) {