author | Tero Marttila <terom@fixme.fi> |
Thu, 28 Aug 2008 01:34:14 +0300 | |
changeset 44 | 03a7e064f833 |
parent 43 | e5b714190dee |
child 48 | 1c67f512779b |
permissions | -rw-r--r-- |
38
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef MEMCACHE_SERVER_H |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define MEMCACHE_SERVER_H |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
#include <sys/queue.h> |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
#include "../memcache.h" |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
#include "../config.h" |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
struct memcache_server { |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
struct config_endpoint *endpoint; |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
// we are a member of struct memcache.server_list |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
LIST_ENTRY(memcache_server) serverlist_node; |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
// a list of connections for this server |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
LIST_HEAD(memcache_connlist_head, memcache_conn) conn_list; |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
// a list of enqueued requests waiting for a connection |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
TAILQ_HEAD(memcache_reqqueue_head, memcache_req) req_queue; |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
21 |
// how many connections we should have at most |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
int max_connections; |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
}; |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
/* |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
* Alloc and return a new memcache_server |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
*/ |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
struct memcache_server *memcache_server_alloc (struct config_endpoint *endpoint, int max_connections); |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
/* |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
* Attempt to grow the connection pool by one connection. Doesn't do anything if we already have too many connections, |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
* otherwise the new connection will be opened and added to the conn_list. |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
*/ |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
int memcache_server_grow_connpool (struct memcache_server *server); |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
/* |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
* Process the given request on this server. |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
*/ |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
int memcache_server_add_req (struct memcache_server *server, struct memcache_req *req); |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
|
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
/* |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
* The given connection is ready for use |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
*/ |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
void memcache_server_conn_ready (struct memcache_server *server, struct memcache_conn *conn); |
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
|
39
0e21a65074a6
memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents:
38
diff
changeset
|
46 |
/* |
43
e5b714190dee
the request/reply code should be complete now, but still needs testing
Tero Marttila <terom@fixme.fi>
parents:
39
diff
changeset
|
47 |
* The given connection failed/died. This will take care of freeing it/reconnecting it |
39
0e21a65074a6
memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents:
38
diff
changeset
|
48 |
*/ |
0e21a65074a6
memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents:
38
diff
changeset
|
49 |
void memcache_server_conn_dead (struct memcache_server *server, struct memcache_conn *conn); |
0e21a65074a6
memcache connect error handling and req queuein
Tero Marttila <terom@fixme.fi>
parents:
38
diff
changeset
|
50 |
|
38
9894df13b779
added the beginnings of the memcache client module (only up to connect() yet)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
51 |
#endif /* MEMCACHE_SERVER_H */ |