equal
deleted
inserted
replaced
4 #include "memcache.h" |
4 #include "memcache.h" |
5 #include "server.h" |
5 #include "server.h" |
6 #include "request.h" |
6 #include "request.h" |
7 #include "../common.h" |
7 #include "../common.h" |
8 |
8 |
9 struct memcache *memcache_alloc (memcache_cb cb_fn) { |
9 struct memcache *memcache_alloc (memcache_cb cb_fn, char pipeline_requests) { |
10 struct memcache *mc = NULL; |
10 struct memcache *mc = NULL; |
11 |
11 |
12 if ((mc = calloc(1, sizeof(*mc))) == NULL) |
12 if ((mc = calloc(1, sizeof(*mc))) == NULL) |
13 ERROR("calloc"); |
13 ERROR("calloc"); |
14 |
14 |
15 // store callback |
15 // store attributes |
16 mc->cb_fn = cb_fn; |
16 mc->cb_fn = cb_fn; |
|
17 mc->pipeline_requests = pipeline_requests; |
17 |
18 |
18 // init server list |
19 // init server list |
19 LIST_INIT(&mc->server_list); |
20 LIST_INIT(&mc->server_list); |
20 |
21 |
21 // success |
22 // success |
30 |
31 |
31 int memcache_add_server (struct memcache *mc, struct config_endpoint *endpoint, int max_connections) { |
32 int memcache_add_server (struct memcache *mc, struct config_endpoint *endpoint, int max_connections) { |
32 struct memcache_server *server = NULL; |
33 struct memcache_server *server = NULL; |
33 |
34 |
34 // alloc the server |
35 // alloc the server |
35 if ((server = memcache_server_alloc(endpoint, max_connections)) == NULL) |
36 if ((server = memcache_server_alloc(mc, endpoint, max_connections)) == NULL) |
36 goto error; |
37 goto error; |
37 |
38 |
38 // enlist it |
39 // enlist it |
39 LIST_INSERT_HEAD(&mc->server_list, server, serverlist_node); |
40 LIST_INSERT_HEAD(&mc->server_list, server, serverlist_node); |
40 |
41 |