memcache/server.h
changeset 38 9894df13b779
child 39 0e21a65074a6
equal deleted inserted replaced
37:f0188b445c84 38:9894df13b779
       
     1 #ifndef MEMCACHE_SERVER_H
       
     2 #define MEMCACHE_SERVER_H
       
     3 
       
     4 #include <sys/queue.h>
       
     5 
       
     6 #include "../memcache.h"
       
     7 #include "../config.h"
       
     8 
       
     9 struct memcache_server {
       
    10     struct config_endpoint *endpoint;
       
    11     
       
    12     // we are a member of struct memcache.server_list
       
    13     LIST_ENTRY(memcache_server) serverlist_node;
       
    14 
       
    15     // a list of connections for this server
       
    16     LIST_HEAD(memcache_connlist_head, memcache_conn) conn_list;
       
    17 
       
    18     // a list of enqueued requests waiting for a connection
       
    19     TAILQ_HEAD(memcache_reqqueue_head, memcache_req) req_queue;
       
    20 
       
    21     // how many connections we should have at most
       
    22     int max_connections;
       
    23 };
       
    24 
       
    25 /*
       
    26  * Alloc and return a new memcache_server
       
    27  */
       
    28 struct memcache_server *memcache_server_alloc (struct config_endpoint *endpoint, int max_connections);
       
    29 
       
    30 /*
       
    31  * Attempt to grow the connection pool by one connection. Doesn't do anything if we already have too many connections,
       
    32  * otherwise the new connection will be opened and added to the conn_list.
       
    33  */
       
    34 int memcache_server_grow_connpool (struct memcache_server *server);
       
    35 
       
    36 /*
       
    37  * Process the given request on this server.
       
    38  */
       
    39 int memcache_server_add_req (struct memcache_server *server, struct memcache_req *req);
       
    40 
       
    41 /*
       
    42  * The given connection is ready for use
       
    43  */
       
    44 void memcache_server_conn_ready (struct memcache_server *server, struct memcache_conn *conn);
       
    45 
       
    46 #endif /* MEMCACHE_SERVER_H */