equal
deleted
inserted
replaced
57 int memcache_server_add_req (struct memcache_server *server, struct memcache_req *req) { |
57 int memcache_server_add_req (struct memcache_server *server, struct memcache_req *req) { |
58 struct memcache_conn *conn; |
58 struct memcache_conn *conn; |
59 |
59 |
60 // look for an idle connection |
60 // look for an idle connection |
61 for (conn = server->conn_list.lh_first; conn != NULL; conn = conn->connlist_node.le_next) { |
61 for (conn = server->conn_list.lh_first; conn != NULL; conn = conn->connlist_node.le_next) { |
62 if (conn->req == NULL) { |
62 if (memcache_conn_is_available(conn)) { |
63 // we found an idle connection |
63 // we found an idle connection |
64 break; |
64 break; |
65 } |
65 } |
66 } |
66 } |
67 |
67 |
89 // remove it from the queue and execute it |
89 // remove it from the queue and execute it |
90 TAILQ_REMOVE(&server->req_queue, req, reqqueue_node); |
90 TAILQ_REMOVE(&server->req_queue, req, reqqueue_node); |
91 |
91 |
92 if (memcache_conn_do_req(conn, req)) { |
92 if (memcache_conn_do_req(conn, req)) { |
93 WARNING("processing enqueued request failed"); |
93 WARNING("processing enqueued request failed"); |
94 |
94 |
95 // XXX: error handling for req |
95 // notify the request/user, the req is now out of our hands |
|
96 memcache_req_error(req); |
96 } |
97 } |
97 } |
98 } |
98 } |
99 } |
99 |
100 |
|
101 void memcache_server_conn_dead (struct memcache_server *server, struct memcache_conn *conn) { |
|
102 assert(server == conn->server); |
|
103 |
|
104 // XXX: reconnect/error out requests? |
|
105 |
|
106 // remove it from the list |
|
107 LIST_REMOVE(conn, connlist_node); |
|
108 |
|
109 // free it |
|
110 memcache_conn_free(conn); |
|
111 } |
|
112 |