memcache/server.h
changeset 49 10c7dce1a043
parent 48 1c67f512779b
equal deleted inserted replaced
48:1c67f512779b 49:10c7dce1a043
     2 #define MEMCACHE_SERVER_H
     2 #define MEMCACHE_SERVER_H
     3 
     3 
     4 #include <sys/queue.h>
     4 #include <sys/queue.h>
     5 
     5 
     6 #include "../memcache.h"
     6 #include "../memcache.h"
       
     7 #include "request.h"
     7 #include "../config.h"
     8 #include "../config.h"
     8 
     9 
     9 struct memcache_server {
    10 struct memcache_server {
       
    11     // the memcache context we belong to
       
    12     struct memcache *mc;
       
    13     
       
    14     // our endpoint
    10     struct config_endpoint *endpoint;
    15     struct config_endpoint *endpoint;
    11     
    16     
    12     // we are a member of struct memcache.server_list
    17     // we are a member of struct memcache.server_list
    13     LIST_ENTRY(memcache_server) serverlist_node;
    18     LIST_ENTRY(memcache_server) serverlist_node;
    14 
    19 
    15     // a list of connections for this server
    20     // a list of connections for this server
    16     LIST_HEAD(memcache_connlist_head, memcache_conn) conn_list;
    21     LIST_HEAD(memcache_connlist_head, memcache_conn) conn_list;
    17 
    22 
    18     // a list of enqueued requests waiting for a connection
    23     // a list of enqueued requests waiting for a connection
    19     TAILQ_HEAD(memcache_reqqueue_head, memcache_req) req_queue;
    24     struct memcache_reqqueue_head req_queue;
    20 
    25 
    21     // how many connections we should have at most
    26     // how many connections we should have at most
    22     int max_connections;
    27     int max_connections;
    23 };
    28 };
    24 
    29 
    25 /*
    30 /*
    26  * Alloc and return a new memcache_server
    31  * Alloc and return a new memcache_server
    27  */
    32  */
    28 struct memcache_server *memcache_server_alloc (struct config_endpoint *endpoint, int max_connections);
    33 struct memcache_server *memcache_server_alloc (struct memcache *mc, struct config_endpoint *endpoint, int max_connections);
    29 
    34 
    30 /*
    35 /*
    31  * Attempt to grow the connection pool by one connection. Doesn't do anything if we already have too many connections,
    36  * 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.
    37  * otherwise the new connection will be opened and added to the conn_list.
    33  */
    38  */