terom@38: #ifndef MEMCACHE_SERVER_H terom@38: #define MEMCACHE_SERVER_H terom@38: terom@38: #include terom@38: terom@38: #include "../memcache.h" terom@38: #include "../config.h" terom@38: terom@38: struct memcache_server { terom@38: struct config_endpoint *endpoint; terom@38: terom@38: // we are a member of struct memcache.server_list terom@38: LIST_ENTRY(memcache_server) serverlist_node; terom@38: terom@38: // a list of connections for this server terom@38: LIST_HEAD(memcache_connlist_head, memcache_conn) conn_list; terom@38: terom@38: // a list of enqueued requests waiting for a connection terom@38: TAILQ_HEAD(memcache_reqqueue_head, memcache_req) req_queue; terom@38: terom@38: // how many connections we should have at most terom@38: int max_connections; terom@38: }; terom@38: terom@38: /* terom@38: * Alloc and return a new memcache_server terom@38: */ terom@38: struct memcache_server *memcache_server_alloc (struct config_endpoint *endpoint, int max_connections); terom@38: terom@38: /* terom@38: * Attempt to grow the connection pool by one connection. Doesn't do anything if we already have too many connections, terom@38: * otherwise the new connection will be opened and added to the conn_list. terom@38: */ terom@38: int memcache_server_grow_connpool (struct memcache_server *server); terom@38: terom@38: /* terom@38: * Process the given request on this server. terom@38: */ terom@38: int memcache_server_add_req (struct memcache_server *server, struct memcache_req *req); terom@38: terom@38: /* terom@38: * The given connection is ready for use terom@38: */ terom@38: void memcache_server_conn_ready (struct memcache_server *server, struct memcache_conn *conn); terom@38: terom@39: /* terom@43: * The given connection failed/died. This will take care of freeing it/reconnecting it terom@39: */ terom@39: void memcache_server_conn_dead (struct memcache_server *server, struct memcache_conn *conn); terom@39: terom@38: #endif /* MEMCACHE_SERVER_H */