fix doc tpyos, rename some enums, fix printf format len for non-zero terminated strings (hg status), pass args to memcache_cmd_format_header via memcache_req_*, handle zero-length STORE requests, memcache_req is_buf_ours + free, other function name typos (keymemcache_req_key), fix req state behaviour re *_DATA_* for STORE requests and FETCH/END, better memcache_server connpool events/management, modular memcache_test with a working benchmark. This is a long commit message.
#ifndef MEMCACHE_SERVER_H
#define MEMCACHE_SERVER_H
#include <sys/queue.h>
#include "../memcache.h"
#include "../config.h"
struct memcache_server {
struct config_endpoint *endpoint;
// we are a member of struct memcache.server_list
LIST_ENTRY(memcache_server) serverlist_node;
// a list of connections for this server
LIST_HEAD(memcache_connlist_head, memcache_conn) conn_list;
// a list of enqueued requests waiting for a connection
TAILQ_HEAD(memcache_reqqueue_head, memcache_req) req_queue;
// how many connections we should have at most
int max_connections;
};
/*
* Alloc and return a new memcache_server
*/
struct memcache_server *memcache_server_alloc (struct config_endpoint *endpoint, int max_connections);
/*
* Attempt to grow the connection pool by one connection. Doesn't do anything if we already have too many connections,
* otherwise the new connection will be opened and added to the conn_list.
*/
void memcache_server_grow_connpool (struct memcache_server *server);
/*
* Process the given request on this server.
*/
int memcache_server_add_req (struct memcache_server *server, struct memcache_req *req);
/*
* The given connection is ready for use
*/
void memcache_server_conn_ready (struct memcache_server *server, struct memcache_conn *conn);
/*
* The given connection failed/died. This will take care of freeing it/reconnecting it
*/
void memcache_server_conn_dead (struct memcache_server *server, struct memcache_conn *conn);
#endif /* MEMCACHE_SERVER_H */